Zenity Reminder Script

Zenity is a fun little tool that "allows you to display Gtk+ dialog boxes from the command line and through shell scripts." It's an easy way to get stuff to and from the user. Mix it with the at command and you get this tiny reminder script.

#!/usr/bin/bash

export DISPLAY=:0

QUESTION='/usr/bin/zenity --entry --title=Remind'
MESSAGE='/usr/bin/zenity --info --title=Remind'

now=`/usr/bin/date +%H:%M`
text=$($QUESTION --text="What would you like to be reminded of?\n")
time=$($QUESTION --text="At what time would you like to see this reminder? (HH:MM)\n" --entry-text="$now")

if [ "$text" ] && [ "$time" ]
then
   display='export DISPLAY=:0'
   message="$MESSAGE --text=\"It is now $time. You asked to be reminded of the following:\n\n$text\""

   echo "$display;$message" | /usr/bin/at $time
fi

The script could be refined in dozens of ways but it does the trick for me just the way it is. Here's what it looks like in action:

Screenshot of the Zenity reminder script

Step 1: message input

Another screenshot of the Zenity reminder script

Step 2: time input

Last screenshot of the Zenity reminder script

And at 11:25pm that day…


Sébastien Biot — Sun, 24 Oct 2004 21:32:30 +0000