notify-send from cron

tested with Arch x64 and Gnome 2.3

libnotify-Message: Unable to get session bus: /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.

Solution

echo `set | grep DBUS_SESSION_BUS_ADDRESS | cut -d "=" -f2-4` > /tmp/dbus_session_hostname
sudo grep -z DBUS_SESSION_BUS_ADDRESS /proc/`/bin/pidof gnome-session`/environ | cut  -d "=" -f2-4 > /tmp/dbus_session_id
CONTENT=`cat /tmp/dbus_session_id`
echo $CONTENT > /tmp/dbus_session_id
sudo -u username DISPLAY=:0.0 DBUS_SESSION_BUS_ADDRESS=`cat /tmp/dbus_session_hostname` /usr/bin/notify-send Inventur "daily inventur complete"