yad-calendar proposed update

Forum Forums General Software yad-calendar proposed update

  • This topic has 30 replies, 7 voices, and was last updated Jan 21-3:19 pm by Brian Masinick.
Viewing 15 posts - 16 through 30 (of 30 total)
  • Author
    Posts
  • #50004
    Moderator
    BobC
      Helpful
      Up
      0
      ::

      Sleep is a good thing. Yes, realistically, you just need to wait till the next alarm or end of day

      #50024
      Anonymous
        Helpful
        Up
        0
        ::

        ever heard about the “rtcwake” command? https://linux.die.net/man/8/rtcwake

        You can use it to suspend your pc and then wake it up at a certain time- and yes, use a script, in conjunction with that, to play an audio file/video at a certain time

        rtcwake [options] [-d device] [-m standby_mode] {-s seconds|-t time_t}

        great tip !

        #50030
        Member
        PPC
          Helpful
          Up
          0
          ::

          Tiny change, with big usability implications:
          I unified the calendar script with the alarm script. This means, that a single script is needed to have “antiX Calendar” and it’s event alarms. I did not incorporate the previous script that displayed the day’s events because I find that, with alarms correctly working, it’s not really needed. If someone wants that extra function, let me know and I’ll try to add it… After some rest, so, no promisses
          To activate calendar alarms, run the name of the calendar script with the “–alarm” argument.
          Example. Assumming your calendar script is called “antix-calendar.sh” and is placed in your home folder, to access the calendar just run this:

          ~/antix-calendar.sh

          To activate alarms for calendar events run this:

          ~/antix-calendar.sh --alarm

          Of course you can place, in your desktop’s start file this, to always have calendar alarms running (it takes about 700Kb of RAM, and no measurable CPU use)- If you have over 1 or 2 Gb of RAM, it’s safe to leave the script always running.

          ~/antix-calendar.sh --alarm &

          Warning: terminating the “sleep” process will deactivate the calendar alarms, rerun the script with the appropriate flag to activate them again.

          Now the code (otherwise the same as the previous version):

          Enjoy and please report any bugs not related with lack of time field validation…
          P.

          #!/bin/bash
          #Simple Calendar for antiX - dependencies: Yad. By PPC, GPL license, 15/01/2021. Please keep this line about Creator and license
          export calendar_file="$HOME/yad-calendar.txt"
          window_icon=/usr/share/icons/papirus-antix/22x22/apps/calendar.png
          ##Clean up calendar file (NOTE: because @ is a special character, in order for the sed comand to percieve it as an ordinary character, it has to be preceded by \, like so: "\@"):
          #Remove all empty lines
          sed -i '/^$/d' $calendar_file
          #Remove all empty lines
          sed -i '/^$/d' $calendar_file
          #Remove lines with only date and nothing more (orphan lines)- it removes all lines with less than 10 characters
          sed -i -r '/^.{,10}$/d' $calendar_file
          #Replace "@@" with a simple "@"
          sed -i -e 's/\@\@/\@/g'  $calendar_file
          #Replace "@ @" with "@"
          sed -i -e 's/\@ \@/\@/g'  $calendar_file
          #Remove any "@" left at the end of any line
          sed 's/\@$//' $calendar_file
          #Remove any "@ " left at the end of any line
          sed 's/\@ $//' $calendar_file
          
          buzzer()
          {
          	clear
          	echo "Sounding buzzer"
          speaker-test --frequency 200 --test sine & sleep 2 && pkill speaker-test	
          }
          
          alarm ()
          {
          killall sleep
          export -f buzzer
          today=$(date '+%d/%m/%Y')
          #read alarm and event from file $HOME/yad-calendar.txt (in format "dd/mm/YYY hh:mm event")
          todays_events=$(grep $today $HOME/yad-calendar.txt |cut -d' ' -f1 --complement)
          x=$(tr -dc '@' <<<"$todays_events" | awk '{ print length; }')
          # echo The number of events for today is $x
          let "x=x+2"
          i=2
          until [ $i -ge $x ]
          do
           grep $today $HOME/yad-calendar.txt |cut -d@ -f$i |cut -d" " -f1
           target_time=$(grep ^$today $HOME/yad-calendar.txt |cut -d@ -f$i |cut -d" " -f1 |cut -d"-" -f1)
           event_description=$(grep $today $HOME/yad-calendar.txt |cut -d@ -f$i |cut -d" " -f2)
           initial_time=$(date +"%H":"%M":"%S")
           diference=$(echo "$target_time
           $initial_time" | 
            (read later_time; read former_time;
              former_seconds=$(date --date="$former_time" +%s);
              later_seconds=$(date --date="$later_time" +%s);
              echo $((later_seconds-former_seconds)) ))
           echo $diference
                if [ $diference -gt 0 ]	;	then
            		clear
            		echo "There are new alarms for today"
            		echo Next Alarm will sound in $diference seconds
            		nohup sleep $diference 
            	    buzzer & 
            	    notify-send "$target_time $event_description ..." &
            	    yad --center --width=300 --no-buttons --window-icon="/usr/share/icons/papirus-antix/22x22/apps/calendar.png" --title="antiX Calendar" --text="\n $target_time - $event_description ... \n" --text-align=center 
               fi
               ((i=i+1))
          done
          # The number below is how many seconds the script should wait before checking for future alarm times (default=30)
          sleep 30 && $BASH_SOURCE --alarm &
          }
          
          Check_time ()
          {
          #Validate time format
          time=$inicio
          number_of_digits_in_time=$(echo -n "time" | wc -c)
          time_check="good"
          #Only procede if there's a initial time entered- to allow adding directly "all day events"
          #check is "time" value exists, store result in "time_inputed"
          [[ ! -z "$inicio" ]] && time_inputed=1 ||  time_inputed=0
          if [ $time_inputed -eq 1 ];then
          echo "USer entered start time, it's not an all day event, check if time is valid"
          hour=$(echo $time |cut -d':' -f1)
          number_of_digits_in_hour=$(echo -n "$hour" | wc -c)
          ##echo $number_of_digits_in_hour
          if [ "$number_of_digits_in_hour" -lt 2 ] ; then
          hour=$(echo 0$hour)
          fi
          if [ "$hour" -lt 24 ] ; then
           echo "Valid time pattern"
           #hour is ok, checking minutes
           minute=$(echo $time |cut -d':' -f2)
           number_of_digits_in_minute=$(echo -n "$minute" | wc -c)
          ## echo $number_of_digits_in_minute
           if [ "$number_of_digits_in_minute" -lt 2 ] ; then
             hour=$(echo 0$minute)
           fi
           if [ "$minute" -lt 60 ] ; then
          	echo "Valid time pattern"
          	else
          ##	 echo "InValid time pattern"
          export	time_check="bad"
           fi
           else
          ##	echo "InValid time pattern"
          export	time_check="bad"
          fi
          fi
          }
          
          Adicionar_evento ()
          {
          # Empty day, add an event
          entrada=$(yad --window-icon=$window_icon --title="$day" --center --form --field="Event:" --field="Start (optional):" --field="End (optional):" "$evento" "$inicio" "")
          echo Selected: $evento_a_editar
          export inicio=$(echo $entrada |cut -d'|' -f2)
          evento=$(echo $entrada |cut -d'|' -f1)
          export fim=$(echo $entrada |cut -d'|' -f3)
          
          Check_time inicio
          
           if [ $time_check == "bad" ]
          	then
                echo "time not ok "
                yad --center --window-icon=$window_icon --title="antiX Calendar" --text=" Incorrect time entered \n Enter a time between 00:00 and 23:59 " --button="X":1 --button="OK":2
          		foo=$?
          		if [[ $foo -eq 1 ]]; then
          			exit
          		fi
          		if [[ $foo -eq 2 ]]; then
          			 inicio=$(echo $inicio |cut -d' ' -f2)
          			 fim=$(echo $inicio |cut -d' ' -f3)
          			 Adicionar_evento
          		fi          
           fi
          #add "@" before the start time
          [[ ! -z "$inicio" ]] && inicio=$(echo \@ $inicio)
          #Add indication of end of event only if "end" was inputed
          [[ ! -z "$fim" ]] && inicio=$(echo $inicio-$fim)
          #Save entered data to file
          echo $day $inicio $evento >> $HOME/yad-calendar.txt
          exit
          }
          
          Editar_evento(){
          # Day with existing event(s)
          #Create array of the day's event(s)
          entrada=$(grep -h $day $calendar_file)
          reminder_time=$(echo $entrada|cut -d' ' -f2)
          reminder_date=$(echo $entrada|cut -d' ' -f1)
          line=($(grep -n $day $calendar_file | head -n 1 | cut -d: -f1))
          eventos_existentes=$(grep $day $calendar_file |cut -d' ' -f1 --complement)
          #Count existing timed events (indicated by "@", so, count "@" signs
          x=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
          echo The number of events for the day is $x
          let "x=x+2"
          numero_de_eventos_no_dia=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
          #clean temporary file
          echo "" > /tmp/listar_eventos_do_dia
          ##loop to check for each timed event, add each event to a different line of the temp file
          i=1
          until [ $i -ge $x ]
          do
          grep $day $calendar_file |cut -d@ -f$i >> /tmp/listar_eventos_do_dia
            ((i=i+1))
          done
          #remove empty lines
          sed -i '/^$/d' /tmp/listar_eventos_do_dia
          #list that day's event(s) in a yad window:
          evento_a_editar=$(yad --window-icon=$window_icon --title="$day"  --button="+":2 --width=550 --height=550 --center --separator=" " --list  --column="Double click an event to edit or cancel it, double click date to add an all day event"  < /tmp/listar_eventos_do_dia)
          foo=$?
          echo Selected: $evento_a_editar
          
          #START GUI to add (timed) event:
          if [[ $foo -eq 2 ]]; then
          
          #process result of user entry:
          date=$day
          input=$(yad --window-icon=$window_icon --title="$day" --center --form --field="Event" --field=Start --field="End (optional)")
          export start=$(echo $input |cut -d'|' -f2)
          event=$(echo $input |cut -d'|' -f1)
          export end=$(echo $input |cut -d'|' -f3)
          
          ##### TO DO - time validation not working here!!!!!!!!!!!!!!!1
          echo $start
          Check_time $start
           if [ $time_check == "bad" ]
          	then
                echo "time not ok "
                yad --center --window-icon=$window_icon --title="antiX Calendar" --text=" Incorrect time entered \n Enter a time between 00:00 and 23:59 " --button="X":1 --button="OK":2
          		foo=$?
          		if [[ $foo -eq 1 ]]; then
          			exit
          		fi
          		if [[ $foo -eq 2 ]]; then
          			 Editar_evento
          		fi          
           fi
          
          edited_day=$(echo $current_day @$start $event)
          
          #Generate list of current day's events (withouy all day events), in file /tmp/listar_eventos_do_dia
          eventos_existentes=$(grep ^$day $calendar_file |cut -d' ' -f1 --complement)
          echo $eventos_existentes
          x=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
          echo O Numero de Eventos no dia em causa é $x
          let "x=x+2"
          #Count envents (each @ sign)
          numero_de_eventos_no_dia=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
          echo "" > /tmp/listar_eventos_do_dia
          i=2
          #loop to add events to temporary file
          until [ $i -ge $x ]
          do
          grep $day $calendar_file |cut -d@ -f$i >> /tmp/listar_eventos_do_dia
            ((i=i+1))
          done
          #Remove empty lines
          sed -i '/^$/d' /tmp/listar_eventos_do_dia
          
          #add new entry to the end of the file
          input=$edited_day   ##############################simulate user input
          echo $input >> /tmp/listar_eventos_do_dia
          
          cat /tmp/listar_eventos_do_dia
          
          ####Put events in correct order
          date_and_all_day_events=$(egrep "^$day " $calendar_file |cut -d'@' -f1)
          sort /tmp/listar_eventos_do_dia > /tmp/temp0.txt
          tac /tmp/temp0.txt > /tmp/temp1.txt
          echo $date_and_all_day_events >> /tmp/temp1.txt
          tac /tmp/temp1.txt > /tmp/listar_eventos_do_dia_editados
          sed -i '/^$/d' /tmp/listar_eventos_do_dia_editados
          # New event's list, starting with date (and eventual all day's events) followed by timed events, in /tmp/listar_eventos_do_dia_editados
          
          ###Create line from /tmp/listar_eventos_do_dia_editados
          #Start by adding " @" at the begining of each line
          sed -i -e 's/^/ @/' /tmp/listar_eventos_do_dia_editados
          #Remove " @" from first line (date and eventual all day events)- it's the 2 first characters, so, repeat sed command 
          sed -i '1s/^.//' /tmp/listar_eventos_do_dia_editados
          sed -i '1s/^.//' /tmp/listar_eventos_do_dia_editados
          #Generate line from temporary file
          export linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
          echo "Current day's entry will be:"
          echo $linha_nova
          
          ###Save changes in correct day
          export day
          export ENTRADA_ATUAL=$(egrep "^$day " $calendar_file)
          while read -r line; do
          linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
          printf "%s\n" "${line/"${ENTRADA_ATUAL}"/"${linha_nova}"}"
          done < $calendar_file > ~/file.new
          #Replace "@@" with a simple "@"
          sed -i -e 's/\@\@/\@/g'  ~/file.new
          cat ~/file.new
          ## exit ##### STOP test HERE, dont edit real file ###############
          cp ~/file.new $calendar_file
          echo Generated entry for $day is
          egrep "^$day "  $calendar_file 
          exit
          fi
          ##END
          
          ##END of GUI to add (timed) event
          
          ### Process click in event from list:
          entrada=$(grep -h $day $calendar_file)
          echo Entrada completa a ser editada:
          echo $entrada
          echo Evento a editar:
          echo $evento_a_editar
          
          if [ -z "${evento_a_editar}" ]; then
              echo "No event selected for edition, exiting"
              exit
          fi
          
          input=$evento_a_editar
          echo $input > /tmp/tempor1
          evento_a_editar=$(cat /tmp/tempor1 |cut -d'|' -f1)
          input2=$(yad --window-icon=$window_icon --center --title="$day" --form --field="" "$evento_a_editar")
          echo $input2 > /tmp/tempor2
          alteracao=$(cat /tmp/tempor2 |cut -d'|' -f1)
          echo Alteração:
          echo $alteracao
          echo Resultado final, a editar no texto:
          export result=$(echo $entrada | awk -v srch="$evento_a_editar" -v repl="$alteracao" '{ sub(srch,repl,$0); print $0 }')
          echo $result
          echo Fim do processo
          
          ###Save changes in correct day
          export day
          export ENTRADA_ATUAL=$(egrep "^$day " $calendar_file)
          while read -r line; do
          linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
          printf "%s\n" "${line/"${ENTRADA_ATUAL}"/"${result}"}"
          done < $calendar_file > ~/file.new
          egrep "^$day " ~/file.new 
          cp ~/file.new  $calendar_file
          #Replace "@ @" with "@"
          sed -i -e 's/\@ \@/\@/g'  $calendar_file  ###############################be carefull with sed
          #Replace "@ " with "@"
          sed -i -e 's/\@ /\@/g'  $calendar_file  ###############################be carefull with sed
          #Remove any "@" left at the end of any line
          sed 's/\@$//' $calendar_file              ###############################be carefull with sed
          #Remove any "@ " left at the end of any line
          sed 's/\@ $//' $calendar_file              ###############################be carefull with sed
          egrep "^$day "  $calendar_file 
          
          #####Ugly way to to reorder day's entries:
          #Generate list of current day's events (withouy all day events), in file /tmp/listar_eventos_do_dia
          eventos_existentes=$(grep ^$day $calendar_file |cut -d' ' -f1 --complement)
          echo $eventos_existentes
          x=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
          echo O Numero de Eventos no dia em causa é $x
          let "x=x+2"
          #Count envents (each @ sign)
          numero_de_eventos_no_dia=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
          echo "" > /tmp/listar_eventos_do_dia
          i=2
          #loop to add events to temporary file
          until [ $i -ge $x ]
          do
          grep $day $calendar_file |cut -d@ -f$i >> /tmp/listar_eventos_do_dia
            ((i=i+1))
          done
          #Remove empty lines
          sed -i '/^$/d' /tmp/listar_eventos_do_dia
          
          ####Put events in correct order
          date_and_all_day_events=$(egrep "^$day " $calendar_file |cut -d'@' -f1)
          sort /tmp/listar_eventos_do_dia > /tmp/temp0.txt
          tac /tmp/temp0.txt > /tmp/temp1.txt
          echo $date_and_all_day_events >> /tmp/temp1.txt
          tac /tmp/temp1.txt > /tmp/listar_eventos_do_dia_editados
          sed -i '/^$/d' /tmp/listar_eventos_do_dia_editados
          
          ###Create line from /tmp/listar_eventos_do_dia_editados
          #Start by adding " @" at the begining of each line
          sed -i -e 's/^/ @/' /tmp/listar_eventos_do_dia_editados
          #Remove " @" from first line (date and eventual all day events)- it's the 2 first characters, so, repeat sed command 
          sed -i '1s/^.//' /tmp/listar_eventos_do_dia_editados
          sed -i '1s/^.//' /tmp/listar_eventos_do_dia_editados
          #Generate line from temporary file
          export linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
          echo "Current day's entry will be:"
          echo $linha_nova
          
          ###Save changes in correct day
          export day
          export ENTRADA_ATUAL=$(egrep "^$day " $calendar_file)
          while read -r line; do
          linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
          printf "%s\n" "${line/"${ENTRADA_ATUAL}"/"${linha_nova}"}"
          done < $calendar_file > ~/file.new
          #Replace "@@" with a simple "@"
          sed -i -e 's/\@\@/\@/g'  ~/file.new
          cat ~/file.new
          ## exit ##### STOP test HERE, dont edit real file ###############
          cp ~/file.new $calendar_file
          echo Generated entry for $day is
          egrep "^$day "  $calendar_file 
          exit
          ##END
          
          }
          
          search_event(){
           ###future entry to search for events:
            event_to_search=$( yad --window-icon=$window_icon --title="antiX Calendar" --center --entry --entry-label="" --button=" !/usr/share/icons/papirus-antix/22x22/actions/search.png")
            rm /tmp/agenda_search_results.txt
             grep -i $event_to_search $HOME/yad-calendar.txt > /tmp/agenda_search_results-desorganized.txt
             grep -i $event_to_search $HOME/yad-calendar.txt > /tmp/agenda_search_results-desorganized.txt
             sort -t- -k3.1,3.4 -k2,2 /tmp/agenda_search_results-desorganized.txt > /tmp/agenda_search_results.txt
          #Display results
          yad --window-icon=$window_icon --title="antiX Calendar" --no-buttons  --width=550 --height=550 --center --separator=" " --list  --column=""  < /tmp/agenda_search_results.txt
              pkill yad
              exit 1
            
            
          }
          
          export -f Adicionar_evento Editar_evento  search_event buzzer alarm
          touch $calendar_file && [ -s $calendar_file ] || echo "28/06/2020 This is how yad-calendar entries work! Add ONLY ONE line per day, starting with the date. If nothing shows up in the calendar, try another date format like dd-mm-yyyy" > $calendar_file
          
          #Process cli arguments. If user ran the script with the "--alarm" argument, activate alarm for calendar entries
          choise1="--alarm"
           if [ $1 == $choise1 ]; then
          	 clear
               alarm
               exit
           fi 
          
          #Main Calendar window
          day=$(yad --window-icon=$window_icon --title="antiX Calendar" --calendar --undecorated --mouse  --details=$calendar_file --button=" !/usr/share/icons/papirus-antix/22x22/actions/search.png":"bash -c search_event" --button="X":1)
           if [[ $foo -eq 1 ]]; then
              pkill yad
              exit 1
            fi
          
          if [[ $foo -eq 2 ]]; then
              exit 
            fi  
          
          #Exit if no day was selected
          [ -z "$day" ] && exit
          
          #If a day was selected, check if it has any events (a line starting with a date) and take the apropriate action
          if grep -q $day $calendar_file; then
             Editar_evento
             else
             Adicionar_evento
          fi
          
          #50031
          Moderator
          Brian Masinick
            Helpful
            Up
            0
            ::

            Thanks again for sharing your work.

            Whether an official application, tool, or simply “free” software that people share, this kind of work is precisely the thing that keeps the overall free software movement alive and well. I am one who appreciates this very much!

            --
            Brian Masinick

            #50032
            Member
            PPC
              Helpful
              Up
              0
              ::

              Thanks, Mr Masinick
              I was surprised by the ammount of work such a simple application implies…
              I almost did not write it- but, as I was developing it, I was tempted to create even more GUI’s, to more actions
              Well, why create one more calendar application? Even such a low on features one?
              Simple- I found no calendar (except for calcurse, the default antiX calendar app, that many people don’t even know it’s there) that ran on extremely low system resources and/or without the need to install dependencies.
              The script it self contained- if you have yad in your system you need nothing more- so no dependencies.
              There are some very good calendar apps: Thunderbird’s calendar plugin is great, and even works with google calendar, but, it takes a huge amount of RAM to run. Osmo and Day-planner are great but they take too much RAM to run permanently on a low specs machine…
              This script is not meant to be a full fledged calendar as those other apps- it’s meant to be an electronic version of a pen and paper pocket agenda- write stuff you need to do there, and check it any time you need to… but with some benefits – you can set alarms and you can search for events instantly.
              With some (a lot more) work there can be even more features added to it: time validation across all time input fields (that keeps bugging me) and repeated events (like birthdays/holidays), a snooze function on the alarm, and the possibility to set the alarm before the event – it all can be added, making this a much more complete PIM.
              In a time most of the civilized world carries small pocked computers, investing a lot of time creating a script that does work as well as a phone calendar seem a bit pointless- but it’s faster to set an alarm to leave work in the computer I’m already using than doing it on my android device… And it works from a simple text file, stored in my own computer, not accessible to some giant corporation!

              P.

              • This reply was modified 2 years, 3 months ago by PPC.
              #50035
              Moderator
              Brian Masinick
                Helpful
                Up
                0
                ::

                @PPC: What you just explained is precisely why the free software movement has had, and continues to have, considerable value, especially to those of us who either cannot afford, or choose not to spend our resources on the “latest and greatest” electronic creations, regardless of how “enticing” the marketing promotions may be.

                Your efforts are a prime example of what can still be done to produce simple, yet functional, fast, and often good looking software.

                I hope that you are able to maintain your enthusiasm for the kind of contributions you make. Remember, whether they make it into some distribution or not, people like you and others who are “like minded” will always value and appreciate simple, useful apps, tools, and ideas.

                --
                Brian Masinick

                #50043
                Moderator
                BobC
                  Helpful
                  Up
                  0
                  ::

                  Maybe its something odd about my system, but it looks like the alarm isn’t working due to it not getting the right date. My date is in whatever format it would default to (US keyboard,and time zone). I am trying to figure it out…

                  #50047
                  Moderator
                  BobC
                    Helpful
                    Up
                    0
                    ::

                    Yes, I think the program is expecting the date to be DD/MM/YYYY but mine go into the file in MM/DD/YYYY because that is what Yad returns from the main calendar.

                    I would say it would be best to get the format being displayed and use that, because that’s the way it is saving the date in the file. That way they will match.

                    #50061
                    Moderator
                    BobC
                      Helpful
                      Up
                      0
                      ::

                      PPC, That’s really a nice script and I could not have written it from scratch. Too many things I don’t know. Anyway since its pretty tricky, I’d suggest comparing to see what I changed, since you are the Yad pro.
                      Ok:
                      I centered the window (it was under the taskbar with automatic autohide)
                      I made the enter event window wider
                      I fixed the problem with date locales by using the local format and tried to fix the line #1 note, basically the date should be the same as their normal format mm/dd/yyyy or dd/mm/yyyy
                      I fixed the extra space after the @ (i think i fixed it correctly)
                      I widened the alarm window and included the word alarm in the title
                      I fixed it so you can add alarms on the same day before the current one by looking for ones within next 30 seconds, else sleeping for 30 seconds before looking again
                      I fixed the grep stuff to look for the date at the beginning of the line

                      todo:
                      in alarm window only the first word of the event description appears. i think this is due to how it cuts it out
                      better or configurable alarm noise. Idea: add 2nd parameter with sound file to play, and if no sound file given (or not found) and parameter #1 is –alarm, then give silent popup alarm

                      Getting very late here. I left my debug on.

                      #!/bin/bash
                      set -x
                      #Simple Calendar for antiX - dependencies: Yad. By PPC, GPL license, 15/01/2021. Please keep this line about Creator and license
                      export calendar_file="$HOME/yad-calendar.txt"
                      window_icon=/usr/share/icons/papirus-antix/22x22/apps/calendar.png
                      
                      ##Clean up calendar file (NOTE: because @ is a special character, in order for the sed comand to percieve it as an ordinary character, it has to be preceded by \, like so: "\@"):
                      #Remove all empty lines
                      sed -i '/^$/d' $calendar_file
                      #Remove all empty lines
                      sed -i '/^$/d' $calendar_file
                      #Remove lines with only date and nothing more (orphan lines)- it removes all lines with less than 10 characters
                      sed -i -r '/^.{,10}$/d' $calendar_file
                      #Replace "@ " with "@"
                      sed -i -e 's/\@ /\@/g'  $calendar_file
                      #Replace "@@" with a simple "@"
                      sed -i -e 's/\@\@/\@/g'  $calendar_file
                      #Replace "@ @" with "@"
                      sed -i -e 's/\@ \@/\@/g'  $calendar_file
                      #Remove any "@" left at the end of any line
                      sed 's/\@$//' $calendar_file
                      #Remove any "@ " left at the end of any line
                      sed 's/\@ $//' $calendar_file
                      
                      buzzer()
                      {
                      	echo "$(date) #############################################################################"
                      	###clear
                      	echo "$(date) Sounding buzzer"
                      	echo "$(date) Sounding buzzer" >> $logfile
                      speaker-test --frequency 200 --test sine & sleep 2 && pkill speaker-test	
                      }
                      
                      alarm ()
                      {
                      killall sleep
                      export -f buzzer
                      localfmt="+$(locale -k LC_TIME | grep ^d_fmt | cut -d= -f2)"
                      today=$(date $localfmt)
                      today2=^
                      today7=$today2${today:1:10}
                      echo "$(date) localfmt: $localfmt  today: $today  today7: $today7"
                      today=$today7
                      #read alarm and event from file $HOME/yad-calendar.txt (in format "dd/mm/YYY hh:mm event")
                      todays_events=$(grep -G "$today" $HOME/yad-calendar.txt |cut -d' ' -f1 --complement)
                      x=$(tr -dc '@' <<<"$todays_events" | awk '{ print length; }')
                      echo "$(date) $x Events: $todays_events"
                      echo "$(date) $x Events: $todays_events" >> $logfile
                      # echo The number of events for today is $x
                      let "x=x+2"
                      i=2
                      until [ $i -ge $x ]
                      do
                       grep -G $today $HOME/yad-calendar.txt |cut -d@ -f$i |cut -d" " -f1
                       target_time=$(grep $today $HOME/yad-calendar.txt |cut -d@ -f$i |cut -d" " -f1 |cut -d"-" -f1)
                       event_description=$(grep $today $HOME/yad-calendar.txt |cut -d@ -f$i |cut -d" " -f2)
                       initial_time=$(date +"%H":"%M":"%S")
                       diference=$(echo "$target_time
                       $initial_time" | 
                        (read later_time; read former_time;
                          former_seconds=$(date --date="$former_time" +%s);
                          later_seconds=$(date --date="$later_time" +%s);
                          echo $((later_seconds-former_seconds)) ))
                       echo $diference
                      	echo "$(date) target_time: $target_time   initial_time: $initial_time  diference: $diference  event_description: $event_description"
                            if [ $diference -gt 0 ] && [ $diference -lt 31 ]	;	then
                        		echo "$(date) #############################################################################"
                        		###clear
                        		echo "$(date) There are new alarms for today"
                        		echo Next Alarm will sound in $diference seconds
                        		nohup sleep $diference 
                        	    buzzer & 
                        	    notify-send "$target_time $event_description ..." &
                        	    yad --center --width=400 --no-buttons --window-icon="/usr/share/icons/papirus-antix/22x22/apps/calendar.png" --title="antiX Calendar Alarm" --text="\n$target_time\n  $event_description\n" --text-align=center 
                           fi
                           ((i=i+1))
                      done
                      # The number below is how many seconds the script should wait before checking for future alarm times (default=30)
                      echo "$(date) Time to sleep for 30 seconds then $BASH_SOURCE --alarm"
                      sleep 30 && $BASH_SOURCE --alarm &
                      }
                      
                      Check_time ()
                      {
                      #Validate time format
                      time=$inicio
                      number_of_digits_in_time=$(echo -n "time" | wc -c)
                      time_check="good"
                      #Only procede if there's a initial time entered- to allow adding directly "all day events"
                      #check is "time" value exists, store result in "time_inputed"
                      [[ ! -z "$inicio" ]] && time_inputed=1 ||  time_inputed=0
                      if [ $time_inputed -eq 1 ];then
                      echo "USer entered start time, it's not an all day event, check if time is valid"
                      hour=$(echo $time |cut -d':' -f1)
                      number_of_digits_in_hour=$(echo -n "$hour" | wc -c)
                      ##echo $number_of_digits_in_hour
                      if [ "$number_of_digits_in_hour" -lt 2 ] ; then
                      hour=$(echo 0$hour)
                      fi
                      if [ "$hour" -lt 24 ] ; then
                       echo "Valid time pattern"
                       #hour is ok, checking minutes
                       minute=$(echo $time |cut -d':' -f2)
                       number_of_digits_in_minute=$(echo -n "$minute" | wc -c)
                      ## echo $number_of_digits_in_minute
                       if [ "$number_of_digits_in_minute" -lt 2 ] ; then
                         hour=$(echo 0$minute)
                       fi
                       if [ "$minute" -lt 60 ] ; then
                      	echo "Valid time pattern"
                      	else
                      ##	 echo "InValid time pattern"
                      export	time_check="bad"
                       fi
                       else
                      ##	echo "InValid time pattern"
                      export	time_check="bad"
                      fi
                      fi
                      }
                      
                      Adicionar_evento ()
                      {
                      # Empty day, add an event
                      entrada=$(yad --window-icon=$window_icon --title="$day" --center --width=400 --form --field="Event:" --field="Start (optional):" --field="End (optional):" "$evento" "$inicio" "")
                      echo Selected: $evento_a_editar
                      export inicio=$(echo $entrada |cut -d'|' -f2)
                      evento=$(echo $entrada |cut -d'|' -f1)
                      export fim=$(echo $entrada |cut -d'|' -f3)
                      
                      Check_time inicio
                      
                       if [ $time_check == "bad" ]
                      	then
                            echo "time not ok "
                            yad --center --window-icon=$window_icon --title="antiX Calendar" --text=" Incorrect time entered \n Enter a time between 00:00 and 23:59 " --button="X":1 --button="OK":2
                      		foo=$?
                      		if [[ $foo -eq 1 ]]; then
                      			exit
                      		fi
                      		if [[ $foo -eq 2 ]]; then
                      			 inicio=$(echo $inicio |cut -d' ' -f2)
                      			 fim=$(echo $inicio |cut -d' ' -f3)
                      			 Adicionar_evento
                      		fi          
                       fi
                      #add "@" before the start time
                      [[ ! -z "$inicio" ]] && inicio=$(echo \@ $inicio)
                      #Add indication of end of event only if "end" was inputed
                      [[ ! -z "$fim" ]] && inicio=$(echo $inicio-$fim)
                      #Save entered data to file
                      echo $day $inicio $evento >> $HOME/yad-calendar.txt
                      exit
                      }
                      
                      Editar_evento(){
                      # Day with existing event(s)
                      #Create array of the day's event(s)
                      entrada=$(grep -h $day $calendar_file)
                      reminder_time=$(echo $entrada|cut -d' ' -f2)
                      reminder_date=$(echo $entrada|cut -d' ' -f1)
                      line=($(grep -n $day $calendar_file | head -n 1 | cut -d: -f1))
                      eventos_existentes=$(grep $day $calendar_file |cut -d' ' -f1 --complement)
                      #Count existing timed events (indicated by "@", so, count "@" signs
                      x=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
                      echo The number of events for the day is $x
                      let "x=x+2"
                      numero_de_eventos_no_dia=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
                      #clean temporary file
                      echo "" > /tmp/listar_eventos_do_dia
                      ##loop to check for each timed event, add each event to a different line of the temp file
                      i=1
                      until [ $i -ge $x ]
                      do
                      grep $day $calendar_file |cut -d@ -f$i >> /tmp/listar_eventos_do_dia
                        ((i=i+1))
                      done
                      #remove empty lines
                      sed -i '/^$/d' /tmp/listar_eventos_do_dia
                      #list that day's event(s) in a yad window:
                      evento_a_editar=$(yad --window-icon=$window_icon --title="$day"  --button="+":2 --width=550 --height=550 --center --separator=" " --list  --column="Double click an event to edit or cancel it, double click date to add an all day event"  < /tmp/listar_eventos_do_dia)
                      foo=$?
                      echo Selected: $evento_a_editar
                      
                      #START GUI to add (timed) event:
                      if [[ $foo -eq 2 ]]; then
                      
                      #process result of user entry:
                      date=$day
                      input=$(yad --window-icon=$window_icon --title="$day" --center --form --field="Event" --field=Start --field="End (optional)")
                      export start=$(echo $input |cut -d'|' -f2)
                      event=$(echo $input |cut -d'|' -f1)
                      export end=$(echo $input |cut -d'|' -f3)
                      
                      ##### TO DO - time validation not working here!!!!!!!!!!!!!!!1
                      echo $start
                      Check_time $start
                       if [ $time_check == "bad" ]
                      	then
                            echo "time not ok "
                            yad --center --window-icon=$window_icon --title="antiX Calendar" --text=" Incorrect time entered \n Enter a time between 00:00 and 23:59 " --button="X":1 --button="OK":2
                      		foo=$?
                      		if [[ $foo -eq 1 ]]; then
                      			exit
                      		fi
                      		if [[ $foo -eq 2 ]]; then
                      			 Editar_evento
                      		fi          
                       fi
                      
                      edited_day=$(echo $current_day @$start $event)
                      
                      #Generate list of current day's events (withouy all day events), in file /tmp/listar_eventos_do_dia
                      eventos_existentes=$(grep ^$day $calendar_file |cut -d' ' -f1 --complement)
                      echo $eventos_existentes
                      x=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
                      echo O Numero de Eventos no dia em causa é $x
                      let "x=x+2"
                      #Count envents (each @ sign)
                      numero_de_eventos_no_dia=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
                      echo "" > /tmp/listar_eventos_do_dia
                      i=2
                      #loop to add events to temporary file
                      until [ $i -ge $x ]
                      do
                      grep $day $calendar_file |cut -d@ -f$i >> /tmp/listar_eventos_do_dia
                        ((i=i+1))
                      done
                      #Remove empty lines
                      sed -i '/^$/d' /tmp/listar_eventos_do_dia
                      
                      #add new entry to the end of the file
                      input=$edited_day   ##############################simulate user input
                      echo $input >> /tmp/listar_eventos_do_dia
                      
                      cat /tmp/listar_eventos_do_dia
                      
                      ####Put events in correct order
                      date_and_all_day_events=$(egrep "^$day " $calendar_file |cut -d'@' -f1)
                      sort /tmp/listar_eventos_do_dia > /tmp/temp0.txt
                      tac /tmp/temp0.txt > /tmp/temp1.txt
                      echo $date_and_all_day_events >> /tmp/temp1.txt
                      tac /tmp/temp1.txt > /tmp/listar_eventos_do_dia_editados
                      sed -i '/^$/d' /tmp/listar_eventos_do_dia_editados
                      # New event's list, starting with date (and eventual all day's events) followed by timed events, in /tmp/listar_eventos_do_dia_editados
                      
                      ###Create line from /tmp/listar_eventos_do_dia_editados
                      #Start by adding " @" at the begining of each line
                      sed -i -e 's/^/ @/' /tmp/listar_eventos_do_dia_editados
                      #Remove " @" from first line (date and eventual all day events)- it's the 2 first characters, so, repeat sed command 
                      sed -i '1s/^.//' /tmp/listar_eventos_do_dia_editados
                      sed -i '1s/^.//' /tmp/listar_eventos_do_dia_editados
                      #Generate line from temporary file
                      export linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
                      echo "Current day's entry will be:"
                      echo $linha_nova
                      
                      ###Save changes in correct day
                      export day
                      export ENTRADA_ATUAL=$(egrep "^$day " $calendar_file)
                      while read -r line; do
                      linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
                      printf "%s\n" "${line/"${ENTRADA_ATUAL}"/"${linha_nova}"}"
                      done < $calendar_file > ~/file.new
                      #Replace "@@" with a simple "@"
                      sed -i -e 's/\@\@/\@/g'  ~/file.new
                      cat ~/file.new
                      ## exit ##### STOP test HERE, dont edit real file ###############
                      cp ~/file.new $calendar_file
                      echo Generated entry for $day is
                      egrep "^$day "  $calendar_file 
                      exit
                      fi
                      ##END
                      
                      ##END of GUI to add (timed) event
                      
                      ### Process click in event from list:
                      entrada=$(grep -h $day $calendar_file)
                      echo Entrada completa a ser editada:
                      echo $entrada
                      echo Evento a editar:
                      echo $evento_a_editar
                      
                      if [ -z "${evento_a_editar}" ]; then
                          echo "No event selected for edition, exiting"
                          exit
                      fi
                      
                      input=$evento_a_editar
                      echo $input > /tmp/tempor1
                      evento_a_editar=$(cat /tmp/tempor1 |cut -d'|' -f1)
                      input2=$(yad --window-icon=$window_icon --center --title="$day" --form --field="" "$evento_a_editar")
                      echo $input2 > /tmp/tempor2
                      alteracao=$(cat /tmp/tempor2 |cut -d'|' -f1)
                      echo Alteração:
                      echo $alteracao
                      echo Resultado final, a editar no texto:
                      export result=$(echo $entrada | awk -v srch="$evento_a_editar" -v repl="$alteracao" '{ sub(srch,repl,$0); print $0 }')
                      echo $result
                      echo Fim do processo
                      
                      ###Save changes in correct day
                      export day
                      export ENTRADA_ATUAL=$(egrep "^$day " $calendar_file)
                      while read -r line; do
                      linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
                      printf "%s\n" "${line/"${ENTRADA_ATUAL}"/"${result}"}"
                      done < $calendar_file > ~/file.new
                      egrep "^$day " ~/file.new 
                      cp ~/file.new  $calendar_file
                      #Replace "@ " with "@"
                      sed -i -e 's/\@ /\@/g'  $calendar_file
                      #Replace "@@" with a simple "@"
                      sed -i -e 's/\@\@/\@/g'  $calendar_file
                      #Replace "@ @" with "@"
                      sed -i -e 's/\@ \@/\@/g'  $calendar_file  ###############################be carefull with sed
                      #Replace "@ " with "@"
                      sed -i -e 's/\@ /\@/g'  $calendar_file  ###############################be carefull with sed
                      #Remove any "@" left at the end of any line
                      sed 's/\@$//' $calendar_file              ###############################be carefull with sed
                      #Remove any "@ " left at the end of any line
                      sed 's/\@ $//' $calendar_file              ###############################be carefull with sed
                      egrep "^$day "  $calendar_file 
                      
                      #####Ugly way to to reorder day's entries:
                      #Generate list of current day's events (withouy all day events), in file /tmp/listar_eventos_do_dia
                      eventos_existentes=$(grep ^$day $calendar_file |cut -d' ' -f1 --complement)
                      echo $eventos_existentes
                      x=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
                      echo O Numero de Eventos no dia em causa é $x
                      let "x=x+2"
                      #Count envents (each @ sign)
                      numero_de_eventos_no_dia=$(tr -dc '@' <<<"$eventos_existentes" | awk '{ print length; }')
                      echo "" > /tmp/listar_eventos_do_dia
                      i=2
                      #loop to add events to temporary file
                      until [ $i -ge $x ]
                      do
                      grep $day $calendar_file |cut -d@ -f$i >> /tmp/listar_eventos_do_dia
                        ((i=i+1))
                      done
                      #Remove empty lines
                      sed -i '/^$/d' /tmp/listar_eventos_do_dia
                      
                      ####Put events in correct order
                      date_and_all_day_events=$(egrep "^$day " $calendar_file |cut -d'@' -f1)
                      sort /tmp/listar_eventos_do_dia > /tmp/temp0.txt
                      tac /tmp/temp0.txt > /tmp/temp1.txt
                      echo $date_and_all_day_events >> /tmp/temp1.txt
                      tac /tmp/temp1.txt > /tmp/listar_eventos_do_dia_editados
                      sed -i '/^$/d' /tmp/listar_eventos_do_dia_editados
                      
                      ###Create line from /tmp/listar_eventos_do_dia_editados
                      #Start by adding " @" at the begining of each line
                      sed -i -e 's/^/ @/' /tmp/listar_eventos_do_dia_editados
                      #Remove " @" from first line (date and eventual all day events)- it's the 2 first characters, so, repeat sed command 
                      sed -i '1s/^.//' /tmp/listar_eventos_do_dia_editados
                      sed -i '1s/^.//' /tmp/listar_eventos_do_dia_editados
                      #Generate line from temporary file
                      export linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
                      echo "Current day's entry will be:"
                      echo $linha_nova
                      
                      ###Save changes in correct day
                      export day
                      export ENTRADA_ATUAL=$(egrep "^$day " $calendar_file)
                      while read -r line; do
                      linha_nova=$(tr -d '\n' < /tmp/listar_eventos_do_dia_editados)
                      printf "%s\n" "${line/"${ENTRADA_ATUAL}"/"${linha_nova}"}"
                      done < $calendar_file > ~/file.new
                      #Replace "@@" with a simple "@"
                      sed -i -e 's/\@\@/\@/g'  ~/file.new
                      cat ~/file.new
                      ## exit ##### STOP test HERE, dont edit real file ###############
                      cp ~/file.new $calendar_file
                      echo Generated entry for $day is
                      egrep "^$day "  $calendar_file 
                      exit
                      ##END
                      
                      }
                      
                      search_event(){
                       ###future entry to search for events:
                        event_to_search=$( yad --window-icon=$window_icon --title="antiX Calendar" --center --entry --entry-label="" --button=" !/usr/share/icons/papirus-antix/22x22/actions/search.png")
                        rm /tmp/agenda_search_results.txt
                         grep -i $event_to_search $HOME/yad-calendar.txt > /tmp/agenda_search_results-desorganized.txt
                         grep -i $event_to_search $HOME/yad-calendar.txt > /tmp/agenda_search_results-desorganized.txt
                         sort -t- -k3.1,3.4 -k2,2 /tmp/agenda_search_results-desorganized.txt > /tmp/agenda_search_results.txt
                      #Display results
                      yad --window-icon=$window_icon --title="antiX Calendar" --no-buttons  --width=550 --height=550 --center --separator=" " --list  --column=""  < /tmp/agenda_search_results.txt
                          pkill yad
                          exit 1
                        
                        
                      }
                      
                      export -f Adicionar_evento Editar_evento  search_event buzzer alarm
                      touch $calendar_file && [ -s $calendar_file ] || echo "28/06/2020 This is how yad-calendar entries work! Add ONLY ONE line per day, starting with the date. If nothing shows up in the calendar, try another date format like mm/dd/yyyy" > $calendar_file
                      
                      #Process cli arguments. If user ran the script with the "--alarm" argument, activate alarm for calendar entries
                      choise1="--alarm"
                       if [ $1 == $choise1 ]; then
                      	 ###clear
                           alarm
                           exit
                       fi 
                      
                      #Main Calendar window
                      day=$(yad --window-icon=$window_icon --title="antiX Calendar" --center --calendar --undecorated --mouse  --details=$calendar_file --button=" !/usr/share/icons/papirus-antix/22x22/actions/search.png":"bash -c search_event" --button="X":1)
                       if [[ $foo -eq 1 ]]; then
                          pkill yad
                          exit 1
                        fi
                      
                      if [[ $foo -eq 2 ]]; then
                          exit 
                        fi  
                      
                      #Exit if no day was selected
                      [ -z "$day" ] && exit
                      
                      #If a day was selected, check if it has any events (a line starting with a date) and take the apropriate action
                      if grep -q $day $calendar_file; then
                         Editar_evento
                         else
                         Adicionar_evento
                      fi
                      
                      • This reply was modified 2 years, 3 months ago by BobC. Reason: bad paste originally
                      • This reply was modified 2 years, 3 months ago by BobC.
                      #50071
                      Member
                      PPC
                        Helpful
                        Up
                        0
                        ::

                        @BobC – Thanks for making the Alarm work in all date formats! I had forgotten about that problem, since I made it work for my (very sane) format dd/mm/yyy 🙂
                        I wonder if there’s a less complex way to do that?
                        You are right about the event’s description only showing the first word in the alarm pop up window- it was by design- it show’s the time and the first word, then “…” – for privacy reasons.
                        If you want to display the full event, replace, in the Alarm function, the “event_description” line with this:

                        event_description=$(grep $today $HOME/yad-calendar.txt |cut -d@ -f$i)

                        That should fix it…

                        I worked hard in finding a way to have an audio alarm without needing to play an audio file- because, on my work computer I do not have any audio files- this ensured that everyone would get to have audible calendar alarms. I had thought about adding the option for silent alarms (simply disabling the “buzzer” function if the arguments “–alarm –silent” where used), but I can see the value in having also “–alarm –file:~/Highway_to_hell.mp3” has an alarm sound 🙂
                        I’ll probably be busy today, but I’ll try to take a look at that tomorrow.

                        EDIT:

                        If you had notifications working in you system, you’ll notice that you get 2 visual: the yad window and a notification.
                        I went for both, for testing purposes only – visually I prefer the system notification, but the yad window has the advantage of not automatically turning off. So, if you were away from your computer when the alarm sounded, you’ll notice it as soon as you get back.
                        With a bit of work the yad window can be configured to look like a system notification: poping up on the upper right corner of the screen, without decorations, and with a button saying “Dismiss” (and, eventually, one saying “Snooze for 5 minutes”)

                        It was handy, however, adding a notification to my startup file, saying “Calendar Alarms are on”, after adding the alarm script to it, so I get reminded that, in fact that feature is on, because I have a very bad memory.

                        P.

                        • This reply was modified 2 years, 3 months ago by PPC.
                        • This reply was modified 2 years, 3 months ago by PPC.
                        #50077
                        Moderator
                        BobC
                          Helpful
                          Up
                          0
                          ::

                          If I had been deciding the format it would have been YYYYMMDD@HH:MM Meet Tom at Cafe@HH:MM Watch TV show so the lines would easily sort, but once files exist the format isn’t easy to change, and you already figured out how to sort them, so it’s not an issue.

                          I have a little generic alarm.wav file I created to warn me when there are severe problems, like almost out of disk space or battery almost dead. I could create another, less severe one called reminder.wav to use for reminder alarms.

                          No, I don’t have notifications. I saw that code and was wondering what that was. Is is a program I don’t have that I should have? I would think that I would want those used if it was on, and if not, then use the Yad pop up, but not both.

                          I would say if using alarms, I would only type in things I wanted to see popping up.

                          Anyway, congrats on a great innovation… it’s totally useful and very light.

                          PS: Thinking better now awake, the best format would be one that could easily interface calendar/appointment entries with my Android phone app and MS outlook from work.

                          • This reply was modified 2 years, 3 months ago by BobC.
                          #50080
                          Member
                          PPC
                            Helpful
                            Up
                            0
                            ::

                            the best format would be one that could easily interface calendar/appointment entries with my Android phone app and MS outlook from work.

                            You are so very right… I thought about that that, but found no [easy] way to implement exporting “yad –calendar” files to any other format. So, for now, unfortunately “antiX Calendar” uses non exportable (and non importable) files 🙁
                            I thought about exporting files to calcurse’s format – a format that I understand and could use [with some effort], and use calcurse to export/import ical files… But, at least in my tests, for some reason, calcurse created .ical files are always empty – I’m not sure if I’m doing something wrong or if calcurse’s antiX version is broken in that function, for some reason.
                            Making calcurse’s export function work would probably allow to sync the calendar with google calendar, etc (since calcurse’s documentation says webcal are supported, if I recall correctly).
                            In practice, if a user wants to use Google Calendar (since most of the world has android devices), I guess that it’s best for them to use Google calendar directly (on the phone – since those devices are always next to them). That said, I do use my phone’s calendar all the time 🙂
                            If you, or any other user know how to implement importing/expoting calendar files to other formats, please, do share!

                            EDIT: thanks to this site- http://icalgen.yc.sg/ I generated a calendar file, opened it’s text file and now know how to right a script to import/export ical’s .ics files to/from yad-calendar files… But I’m too tired to write the script myself.
                            Any way, here’s an example of an ical file I generated:

                            BEGIN:VCALENDAR
                            VERSION:2.0
                            BEGIN:VEVENT
                            CLASS:PUBLIC
                            DESCRIPTION:teste1\nDate and Time - Jan 18\, 2021 4:00 PM to 6:00 PM\nVenue - \ntesting generating ical files\n
                            DTSTART:20210118T120000Z
                            DTEND:20210118T121000Z
                            LOCATION: 
                            SUMMARY;LANGUAGE=en-us:teste
                            END:VEVENT
                            BEGIN:VEVENT
                            CLASS:PUBLIC
                            DESCRIPTION:teste2\nDate and Time - Jan 18\, 2021 4:00 PM to 6:00 PM\nVenue - \ntesting generating ical files\n
                            DTSTART:20210119T120000Z
                            DTEND:20210119T121000Z
                            LOCATION: 
                            SUMMARY;LANGUAGE=en-us:teste
                            END:VEVENT
                            END:VCALENDAR

                            The relevant parts are the lines “DESCRIPTION”, “DTSTART” and “DTEND”
                            for events withtout end (I don’t use end time for events myself, but it can be handy when using calendar for meeting), simply reapeat clone line “DTSTART” to “DTEND”

                            That information can be obtained from yad-calendar files, using a loop to process from the first line to the last, and, inside that loop, use a variation of the same loop we already use in the alarm, to process each day’s events separately, generating the lines “DESCRIPTION”, “DTSTART” and “DTEND” from all events to export yad-calendar files to ics.
                            The opposite process can be used to import ics files to yad-calendar…
                            Any takers on writing such script?… Bob 🙂

                            P.

                            • This reply was modified 2 years, 3 months ago by PPC.
                            #50271
                            Moderator
                            BobC
                              Helpful
                              Up
                              0
                              ::

                              I looked at the .ics format, too. It reminds me of a 6 ton government designed mouse, LOL. .vcs was similar it looked.

                              I suppose there could be an “Import/Export Options” button and a script it would run…

                              Too tired from working at the moment.

                              I have these dreams of adding “Disk space monitors” and “Updates available” features to IceWM but don’t know C++ and it’s tough code, and the Devs don’t want to do it even after I offered to donate for beer (or whatever) for them. They don’t seem to realize that IceWM is becoming more popular because it is actually capable of running WELL on these low memory, low horsepower machines that many folks are stuck with, and we could buy them back more memory and CPU (to make it available for the greedy browsers) if we could get IceWM handling more of those totally common functions at a lower level than the alternative addon programs. One of these days I will figure it out, I hope.

                              #50273
                              Anonymous
                                Helpful
                                Up
                                0
                                ::

                                tried to submit a “food for thought” post, spamfilter ate it.
                                SIX is too many embedded links???

                                so I sent a copy to pastebin: https://pastebin.com/raw/rtdgVeUT

                                #50357
                                Moderator
                                Brian Masinick
                                  Helpful
                                  Up
                                  0
                                  ::

                                  From skidoo:
                                  >>> way to implement exporting “yad –calendar” files to any other format

                                  food for thought:
                                  bash script, 800 lines
                                  https://github.com/pmarin/ical2pcal
                                  ________________________________________________________

                                  ical2pcal v0.0.7 – Convert iCalendar (.ics) data files to pcal data files

                                  Usage: ical2pcal [-E] [-o <file>] [-h] file

                                  -E Use European date format (dd/mm/yyyy)

                                  -o <file> Write the output to file instead of to stdout

                                  -h Display this help

                                  The iCalendar format (.ics file extension) is a standard (RFC 2445)
                                  for calendar data exchange. Programs that support the iCalendar format
                                  are: Google Calendar, Apple iCal, Evolution, Orange, etc.

                                  The iCalendar format have many objects like events, to-do lists,
                                  alarms, journal entries etc. ical2pcal only use the events
                                  in the file showing in the pcal file the summary and the time of
                                  the event, the rest information of the event like
                                  description or location are commented in the pcal file (because
                                  usually this information does not fit in the day box).

                                  Currently automatic detection and conversion to local time of time values
                                  in UTC is implemented. All other time values are assumed as local times.

                                  ical2pcal does not support complex repeating events, like every first sunday in month.
                                  Only simple recurrence are allowed like:
                                  every n-th [day|week|month|year] from <DATE> [until <DATE> | count] except <DATE>,…
                                  ________________________________________________________

                                  also

                                  https://uriesk.wordpress.com/2014/03/13/edit-ics-calendarfiles-with-bash-scripts-and-sed/

                                  https://help.nextcloud.com/t/calcardbackup-bash-script-to-backup-nextcloud-calendars-and-addressbooks-as-ics-vcf-files/11978
                                  ^—v
                                  https://stackoverflow.com/questions/44225743/owncloud-calendar-ics-backup

                                  https://wiki.davical.org/index.php/How_can_I_migrate_to_DAViCal_using_already_generated_.ics_files%3F

                                  https://askubuntu.com/questions/827919/bash-script-to-edit-ics-files

                                  --
                                  Brian Masinick

                                Viewing 15 posts - 16 through 30 (of 30 total)
                                • You must be logged in to reply to this topic.