I would really recommend using a wrapper script. To emulate cron calling notify-send, I sshed into my own system with "ssh localhost". Calling '/usr/bin/notify-send "foo"' Didn't work, and I had no luck when adding DISPLAY=:0.0 to the line. Here is what did work:
DBUS_SESSION_BUS_ADDRESS="$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/`pgrep -u username cinnamon|head -1`/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//')" /usr/bin/notify-send "foo"
That is VERY messy, to say the least. This is cleaner.
#! /bin/bash
DBUS=$(pgrep -ou $1 cinnamon)
DBUS="$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$DBUS/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//')"
DBUS_SESSION_BUS_ADDRESS="$DBUS" /usr/bin/notify-send $2
And in cron:
*/1 * * * * /path/to/notify.sh user "help"
Please note that the "cinnamon" bit is there because that the window manager I use. You will likely have to replace it with nautilus, or whatever else you have as a window manager. I also have a user specified as the first argument, because it makes it more modular later, if you want this to work regardless of who is logged in.
DISPLAY
? – Michael Mrozek Sep 08 '11 at 20:53/var/mail/yotam
or/var/spool/mail/yotam
)? You may need to setXAUTHORITY
in addition toDISPLAY
, see this answer. – Gilles 'SO- stop being evil' Sep 08 '11 at 22:13/var/log/cron
? If it appears, see if you have an/etc/pam.d/crond
file on Ubuntu. If you have, steal it, otherwise see the cron job not running because of pam? thread in the openSUSE forum. – manatwork Sep 09 '11 at 07:11