In my Kubuntu 22.04, a script run by my crontab uses notify-send
. However, it doesn't work: there is no pop-up appearing. If I redirect the output (stderr
in particular) of the script to a file, this error is printed:
Error calling StartServiceByName for org.freedesktop.Notifications: Timeout was reached
If instead I run notify-send
directly from a cronjob,
0 * * * * env DISPLAY=:0.0 notify-send --expire-time=0 --app-name="Test" 'Test text' 1>/tmp/out1 2>/tmp/out2
out1
and out2
are empty; however, this doesn't work as before. The pop-up does not appear.
Is there a way to make notify-send
work as expected?
I guess for
notify-send
to work in a cron job you have to copy the environment variableDBUS_SESSION_BUS_ADDRESS
from your current desktop session and set it in the cron job. Also,notify-send
must run as the same user who is currently logged in to the desktop session.At least that works for me.