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 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #100389
    Member
    MarkG_108

      Hello. I’m looking for a small timer application with an alarm. So, something that counts down and lets me know when the countdown is finished. I searched, but generally timers seem associated with desktop environment panels (widgets for them). I simply want a small program on its own. I tried gtimer and stopwatch, but neither of these has a countdown and alarm function.

      #100395
      Forum Admin
      Dave
        Helpful
        Up
        1
        ::

        Maybe something like?

         #!/bin/bash
        #alarm.sh - one line script to play alarm after X seconds
        sleep $1 && ogg123 /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga

        saved in a file named alarm.sh; made executable; and called like “alarm.sh 60”. Where 60 is the number of seconds till the alarm triggers.
        or if you need a specific time of day add the “ogg123 *” command as a cron job?

        Maybe this is too raw/bare for the job?

        Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown

        #100403
        Member
        PPC
          Helpful
          Up
          1
          ::

          There’s a more elaborate timer, with alarm, included in the package ft10-transformation.
          Install that package, then go to antiX Menu > Applications > Accessories > Clocks > Select “Timers”

          Just like on any mobile device, you have a world clock, an alarm, a timer (that can even be used to suspend the system, when it finishes running) and a very basic CLI stopwatch.
          It also adds a tiny script to let you see a weather forecast using wttr.in, etc. One of the package’s aims is to have all the features even the most basic smartphone has, available in antiX

          Note: You do not need to enable any change to the toolbar/menu to be able to use all the extra apps FT10 provides.

          P.

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

            Some time ago I was messing around with scripts to build myself a simple clock, using a variety of languages.
            Of course, we already have a clock available; this was just an exercise for me.

            One of them I was working on was in Yad, so I found an old discussion about an alarm clock in an archived version of the PCLinuxOS Magazine.
            This may be of some help to you if you want to write something with yad yourself.
            https://pclosmag.com/html/Issues/201201/page12.html

            Here is another one that may prove useful if you actually want to build something yourself.

            https://forums.bunsenlabs.org/viewtopic.php?pid=93773#p93773

            --
            Brian Masinick

            #100495
            Moderator
            Brian Masinick
              Helpful
              Up
              2
              ::

              I actually copied this alarm clock, made it executable and ran it and it works.

              #!/bin/bash
              # AlarmClock.bash
              
              # 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

              #100555
              Member
              MarkG_108
                Helpful
                Up
                0
                ::

                Thanks. This works well (that being, the package ft10-transformation). So, this thread could be marked as “solved”.

                • This reply was modified 2 months, 2 weeks ago by MarkG_108.
                #100557
                Member
                MarkG_108
                  Helpful
                  Up
                  0
                  ::

                  This does work, though it doesn’t reflect the current time. Rather, for some reason, it reflects the time that my user signed in (see image –> I signed in at 9:02, and the current time as of the screenshot is 9:12). And the other issue is there doesn’t seem to be any way to check in on the progress of the countdown.

                  • This reply was modified 2 months, 2 weeks ago by MarkG_108.
                  #100564
                  Moderator
                  Brian Masinick
                    Helpful
                    Up
                    0
                    ::

                    @markg_108: In fairness to the tool, all it does it set an alarm based on the current time.
                    There are two ways to get the “correct time”. One is like many of us do with our classic clocks – we manually adjust the time.
                    The other way is to obtain the correct “network time”, using NTP or an application that obtains the correct time from an NTP service.

                    The “correct time” is managed by sites throughout the world and it is accurate to fractions of a second.
                    https://ntp.org/ will provide you with general information about this.
                    The command apt-cache search ntp on my system provides quite a few references to things containing ntp in the name.
                    As far as the packages that actually pertain to a time service, ntp, ntpdate, sntp, and ntpsec (plus utilities pertaining to these) are possibilities.

                    I happen to have ntp and ntpdate installed on my system. You may try that, or you may want a more modern, secure implementation, your choice; I would install something so you don’t have to worry about setting the time.

                    --
                    Brian Masinick

                    #100577
                    Member
                    Xunzi_23
                      Helpful
                      Up
                      0
                      ::

                      Hi Brian
                      you forgot conmann, it provides NTP too, if you let it.
                      I do not :-).

                      #100578
                      Moderator
                      Brian Masinick
                        Helpful
                        Up
                        0
                        ::

                        Hi Brian
                        you forgot conmann, it provides NTP too, if you let it.
                        I do not :-).

                        I don’t do that either. I prefer to use a known service to handle specific things using classic “daemon” processes.
                        Unless something else emerges that proves itself to be reliable, efficient and effective, I won’t be going in a different direction any time soon.

                        On one of my systems the other day, the connmand was running but network services were unstable at best.
                        Whether it was because of the Connman daemon or not, I’m not going to put even more responsibility on that group of processes and procedures.

                        --
                        Brian Masinick

                        #100649
                        Member
                        MarkG_108
                          Helpful
                          Up
                          0
                          ::

                          @markg_108: In fairness to the tool, all it does it set an alarm based on the current time.
                          There are two ways to get the “correct time”. One is like many of us do with our classic clocks – we manually adjust the time.
                          The other way is to obtain the correct “network time”, using NTP or an application that obtains the correct time from an NTP service.

                          [..]

                          I happen to have ntp and ntpdate installed on my system. You may try that, or you may want a more modern, secure implementation, your choice; I would install something so you don’t have to worry about setting the time.

                          I do have ntp and ntpdate installed. And yet, the script still gives the incorrect time.

                          Attachments:
                          #100653
                          Moderator
                          Brian Masinick
                            Helpful
                            Up
                            0
                            ::

                            If that is the case, it can be resolved, especially since you do have the tools; I don’t know why they’re not correcting the time, but here’s another way:
                            Menu –> Applications –> antiX –> Date and Time.
                            Once it comes up, navigate to Use Internet Time Server to set automatically time/date
                            press Enter to activate that selection, then check whether or not the time and date are adjusted properly; they should be.
                            If yes, then you can navigate down one spot to Quit the tool; again, press Enter once that selection is highlighted, and you can exit the tool.
                            If THIS does not properly set the date and time, then your Internet Time Server is not being appropriately reached, set, and updated.

                            --
                            Brian Masinick

                            #100655
                            Member
                            MarkG_108
                              Helpful
                              Up
                              0
                              ::

                              The time for the system is fine. It’s only the time in the script that is off. For instance:

                              $ date
                              Sat 25 Feb 2023 07:14:05 PM EST
                              

                              The above time reading and date is correct. However, when I run the AlarmClock.bash script, it says the time is 19:02. The time that it reads is always something:02 (something being an accurate portrayal of the hour of the day, with the minutes, from the times I’ve run the script, always reading “02”)

                              #100656
                              Moderator
                              Brian Masinick
                                Helpful
                                Up
                                0
                                ::

                                I suspect that something was accidentally changed, either in the code I copied here or in your copy.

                                I’ll look into my end.

                                If you are able to check your script for a mistake that would hard code the 2 or 02, please correct and share.

                                --
                                Brian Masinick

                                #100670
                                Moderator
                                Brian Masinick
                                  Helpful
                                  Up
                                  1
                                  ::

                                  I found the issue:
                                  COUNTDOWN=$(yad --entry --text "Time now is $(date +"%H:%m")" --entry-label "Enter minutes until alarm..." --numeric --title="$TITLE" --window-icon=$ICON \
                                  The string should be “%H:%M” because %m is “month”, and the current month is February, hence 02.
                                  Another useful string in a format I happen to like is “%r” instead of “%H:%M”. The 24 hour equivalent is “%R”.

                                  I knew I could find it with well rested eyes!

                                  --
                                  Brian Masinick

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