A simple timer
June 16, 2010
This post is really meant for me, to remind me later how to do this, but perhaps you’ll find something useful in it too.
This is a little script using zenity that functions as a timer . When I run the script I am asked to enter a task description and then in how many minutes I want to be reminded of that (“10” is ten seconds, “10m” is ten minutes). When the time is up, a simple dialog appears that reminds me to do the task I set myself.
#!/bin/bash # REMINDER=`zenity --entry --title="Timer" \ --text="What should I do?"` WAIT=`zenity --entry --title="Timer" \ --text="When should I do this?"` sleep $WAIT zenity --info --title="Timer" --text="$REMINDER"
Now I no longer need to launch a panel to run a timer panel applet (which I am sorry to admit I did for a while). This is simple and works great.
That looks very simple — what usually is all we need for simple tasks. But how about, when the reminder window pops up in the middle of writing, gaining focus. Wouldn’t that be a little irritating?
Your window manager should take care of that.
Nice! Finally a simple timer script. Would it be better to use one window with two fields instead of two windows to ask for the reminder and the time? Also, could it show a window containing a countdown until it’s time for the reminder? Still, this is useful!
Nice, quite useful. Thanks for sharing. 🙂
Someone on the Crunchbang forums posted a link here in response to a request for a light, simple timer.
Thank you very much for sharing.
Cheers
T
Just had to say thanks for this. It’s very simple and very handy.
[…] les critères cite dessus , j’ai trouve un petit script zenity qui est tres simple dans ce blog et je veux le partager avec […]
Wow. Thanks!! 🙂
I’m no coder, but i figured out how to add a sound with the alarm:
#!/bin/bash
#
REMINDER=`zenity –entry –title=”Timer” \
–text=”What should I do?”`
WAIT=`zenity –entry –title=”Timer” \
–text=”When should I do this?”`
sleep $WAIT
play [path to sound file] &
zenity –info –title=”Timer” –text=”$REMINDER”
path to sound file, e.g., /home/Mike/sounds/alarm.wav – or stick your favorite noise in /usr/share, etc.
Again, thanks!!