Wednesday 28 September 2011

Ubuntu 10.04 Lucid - notify-send in crontab not working

Alternative title: How to harness Ubuntu's black notification bubbles to set yourself repeating reminders

I recently found the wonderful command notify-send, which you can use to create those black Ubuntu notifications in the top right of the screen e.g. notify-send "Message Title" "This is my message." (you may need to install libnotify-bin). I then tried to shove this in my crontab to remind me to do stuff (e.g. take a short break every hour) but it didn't work.

Turns out that from the crontab, you have to tell it which DISPLAY to use, and luckily this turned out to be quite simply. All you need to do is add this prefix: DISPLAY=:0.0. So my crontab now looks like this:
# m h dom mon dow command
0 * * * * DISPLAY=:0.0 notify-send "Have a break" "Have a Kit Kat"

No comments:

Post a Comment