L'uso di questo sito
autorizza anche l'uso dei cookie
necessari al suo funzionamento.
(Altre informazioni)

Friday, August 8, 2014

A simple command line remainder, for the linux GUI

One of the first exercises of the Unix (then: Linux) books of yore was using the "at" command to create reminders (or, alarms). If memory serves, it went like this:

$ echo "echo \"Go home!\" > /dev/tty " | at 17:00

Because this is way too much typing, you were then taught how to plop it in a /usr/local/bin script:


       echo "echo \"$1\" > /dev/tty" |  at $2

Those were the tty days. Enter the GUI (or, even, multiple terminals) and your nifty alarm utility does not cut it any more, essentially because you're not usually looking at the right window when the alarm is echoed. Using xdialog or knotify in place of echo does not cut it either, as both rely on being able to connect to the X display (which they cannot do, because they are activated by atd outside the current desktop session).

Of course there must be thousands of fancy reminder/alarm apps from the desktop to the web-based, but none (that I could find) that'd allow me to set a simple reminder by typing it in the terminal I happen to have my focus on.

Enter libnotify and its command line minion notify-send:



[[ x$TITLE == x ]] && TITLE="Sveglia!!!!"
echo /usr/bin/notify-send  -u critical  \"$TITLE\" \"$2\"\
 |at -m "$1"

And then:

$ alarm.sh 13:00 "Aren't you hungry?" "Lunch time" 

The -m switch tells at to send you mail when it fires  - Fedora pre 20 users may want to take notice of this bug report and compensate accordingly. Of course, the atd service must be running for this to work.

No comments: