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.

9 Responses to “A simple timer”

  1. Myke said

    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?

  2. urukrama said

    Your window manager should take care of that.

  3. chombee said

    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!

  4. evidex said

    Nice, quite useful. Thanks for sharing.🙂

  5. logs_con said

    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

  6. verdolagero said

    Just had to say thanks for this. It’s very simple and very handy.

  7. […] 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 […]

  8. Subito Piano said

    Wow. Thanks!! 🙂

  9. Subito Piano said

    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!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s