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.
-
AuthorPosts
-
February 26, 2023 at 3:24 pm #100671Moderator
Brian Masinick
::#!/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 MasinickFebruary 26, 2023 at 3:30 pm #100672MemberMarkG_108
::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 foundAnyway, 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.
February 26, 2023 at 3:35 pm #100673Moderator
Brian Masinick
::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 MasinickFebruary 28, 2023 at 12:17 pm #100777MemberMarkG_108
February 28, 2023 at 1:58 pm #100779Moderator
Brian Masinick
::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.ogaThere may be others, so look through various folders beneath /usr/share/sounds for one you can use.
--
Brian Masinick -
AuthorPosts
- You must be logged in to reply to this topic.