Anyone know of a small timer application with an alarm?[solved]

Forum Forums New users New Users and General Questions Anyone know of a small timer application with an alarm?[solved]

  • This topic has 19 replies, 5 voices, and was last updated Feb 28-1:58 pm by Brian Masinick.
Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #100671
    Moderator
    Brian Masinick
      Helpful
      Up
      0
      ::
      #!/bin/bash
      # AlarmClock.bash
      # ( Corrected hours and minutes - "%H:%M" )
      # Alarm clock for PCLinuxOS
      #
      # Don't miss important times and events. Turn your computer 
      # into the perfect wake up system. Set the alarm and get the 
      # Pizza out of the oven in perfect time.
      #
      # Author: D.M-Wilhelm (Leiche)
      # Email: meisssw01 at gmail.com
      # Licence: GPL
      # First build: May Wed 11 2011
      # Last build: Jul Sun 10 2011
      # fixed icon display in systray, move zenity,
      # based now on yad.
      #
      Encoding=UTF-8
      #
      # i18n - Internationalization - Internationalisierung
      #
      export TEXTDOMAIN=alert_clock
      export TEXTDOMAINDIR="/usr/share/locale"
      #
      # define some variables - Definierung einiger Variablen 
      #
      TITLE="Alarm Clock"
      ICON="/usr/share/icons/Paper/48x48/apps/alarm-clock.png"
      
      #
      #question - Frage
      #
      function menu {
      COUNTDOWN=$(yad --entry --text "Time now is $(date +"%H:%M")" --entry-label "Enter minutes until alarm..." --numeric --title="$TITLE" --window-icon=$ICON \
                  --image=$ICON \
                  --button=$"Change alarm sound:2" \
                  --button=$"Test:3" \
                  --button="gtk-ok:0" \
                  --button="gtk-close:1" \
                 )
      ret=$?
      
      [[ $ret -eq 1 ]] && exit 0
      #
      #change sound - Sound ändern
      #
      if [[ $ret -eq 2 ]]; then
          CHANGE=$(yad --title="$TITLE" --window-icon=$ICON \
              --file --width=600 --height=500 \
              --text=$"<b>Choose your own audio file as alert!</b>
      ________________________________________________")
              if [ -z "$CHANGE" ];then 
              exec alert_clock
              exit 0
              else
              mkdir $HOME/.config/alert-clock
              rm -rf $HOME/.config/alert-clock/alert sleep 1
              ln -s "$CHANGE" $HOME/.config/alert-clock/alert
              yad --title $"$TITLE" \
                  --button="gtk-ok:0" \
                  --width 300 \
                  --window-icon=$ICON \
                  --text=$"Your own sound is set!!"
              fi
      menu        
      fi
      #
      #Test sound - Klang testen
      #
      if [[ $ret -eq 3 ]]; then
          if [ -f $HOME/.config/alert-clock/alert ]; then
          SOUND="$HOME/.config/alert-clock/alert"
          else
          SOUND='/usr/share/alert_clock/alarm.ogg'
          fi
      mpv "$SOUND" | yad --title $"$TITLE" \
                       --button="gtk-ok:0" \
                       --width 300 \
                       --window-icon=$ICON \
                       --text=$"Exit sound test!!"
      killall mpv
      menu                 
      fi
      }
      menu
      #
      #progress - Prozess
      #
      if [ "$COUNTDOWN" = "" ];then
      exit
      else
      echo you enter "$COUNTDOWN" minutes
      TIMER=$(echo $(($COUNTDOWN*60)))
      TASK1=$(date -s "+$TIMER seconds" 2>/dev/null | cut -d " " -f4)
      exec 3> >(yad --notification --command=CMD --image=$ICON --listen)
      echo tooltip: $"Alarm clock was set to $COUNTDOWN minutes and notifiers at $TASK1!" >&3
      sleep $TIMER
      exec 3>&-
      #
      #check wich sound - auf Audio prüfen
      #
      if [ -f $HOME/.config/alert-clock/alert ]; then
          SOUND="$HOME/.config/alert-clock/alert"
          else
          SOUND='/usr/share/alert_clock/alarm.ogg'
      fi
      #
      #alert output - Alarm Ausgabe
      #
      (mpv "$SOUND") | yad --title $"$TITLE" \
                       --button="gtk-ok:0" \
                       --width 300 --image=$ICON \
                       --window-icon=$ICON \
                       --text=$"<b>Time is over!!</b>"
                       exit;
      fi
      exit

      --
      Brian Masinick

      #100672
      Member
      MarkG_108
        Helpful
        Up
        0
        ::

        I did find something that seemed to fix it. Line 34 initially read:
        COUNTDOWN=$(yad --entry --text "Time now is $(date +"%H:%m")" --entry-label "Enter minutes until alarm..." --numeric --title="$TITLE" --window-icon=$ICON \

        Capitalizing the “m” seemed to fix it to give the current time as of the script’s launch:
        COUNTDOWN=$(yad --entry --text "Time now is $(date +"%H:%M")" --entry-label "Enter minutes until alarm..." --numeric --title="$TITLE" --window-icon=$ICON \

        Another kink in it is with the alarm sound set up. I did set it up to the file /usr/local/lib/ft10/ahooga-horn-vobis.ogg, since that existed on my system. But, if a user considers changing the alarm sound, but then changes her/his mind and cancels, the script will balk at that and kill itself while declaring:
        ./AlarmClock2.bash: line 53: exec: alert_clock: not found

        Anyway, it does work as a very basic countdown timer with an alarm, which is good. The “clocks” function from the package ft10-transformation (referenced here), is complete, though it requires entering the countdown time in seconds, which is a slight nuisance. Anyway, I now have some workable options for making sure I don’t overcook my oatmeal in the morning.

        #100673
        Moderator
        Brian Masinick
          Helpful
          Up
          0
          ::

          Yes, those sounds, images, and other items are quite likely to be “different” than what they are on our distribution because the original script was written about a decade ago by someone on a different forum using a different distribution. Look in the directories under /usr/share for something suitable to you.

          /usr/share/sounds/freedesktop/stereo contains more sounds.
          Perhaps /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga would be appropriate?

          • This reply was modified 2 months, 2 weeks ago by Brian Masinick.

          --
          Brian Masinick

          #100777
          Member
          MarkG_108
            Helpful
            Up
            0
            ::

            I had missed this reply of yours when I was testing it myself and made the discovery of capitalizing the “M”. Thanks again.

            #100779
            Moderator
            Brian Masinick
              Helpful
              Up
              1
              ::

              Did you also see my post with the different location for sounds?
              /usr/share/sounds has many different sounds; I found one in particular, at least on my system, that has a more appropriate alarm –
              /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga

              There may be others, so look through various folders beneath /usr/share/sounds for one you can use.

              --
              Brian Masinick

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