I'd like to send a notification bubble to the gnome desktop from a shell script that is executed by cron.
To make it able to communicate with the desktop environment DBUS_SESSION_BUS_ADDRESS
env variable needs to be set within the script. I'm trying to achieve this by the following code which isn't working.
#!/usr/bin/env sh
export DISPLAY=:0
dbus=$(env | grep DBUS_SESSION_BUS_ADDRESS | sed 's/DBUS_SESSION_BUS_ADDRESS=//')
export DBUS_SESSION_BUS_ADDRESS=$dbus
[...]
notify-send -u critical "Blah" "Blubb"
When hardcoded it works fine
export DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-HjnsLUTTrn,guid=17c8962443279ebbe24dcd66536278dd'
Problem is, the dbus session address changes so hardcoding isn't an option.
What am I doing wrong?