I am using Kubuntu 20.04 Focal (KDE Plasma v5.18.5, KDE Frameworks v5.68.0, Qt v5.12.8) and I have a bunch of Bash scripts that are expected to post some notifications, to the user and this is the step I am currently having unresolved issues with. To post notifications I am using
libnotify-bin package) and
kdialog package). The minimal, complete and verifiable example for my case can look like this (say, it's
/tmp/test.sh, executable file):
#!/bin/bash notify-send "notify-send test" kdialog --passivepopup 'kdialog test' 5
When you run this script manually, it works just fine and produces what you expect - shows the notification that appears on your destkop. In my case it's expected to show up in bottom-left corner of the screen as I do have vertical panel on the left edge:
However when I try to run my scripts from a cron job, with crontab entry like this:
* * * * * DISPLAY=:0 /tmp/test.sh
notify-send fails completely (shows nothing) and
kdialog shows something oddly themed and misplaced (in top-left part of the screen):
The cron job is running on behalf of my user and I am logged during the tests. When checking syslog I see:
Sep 10 20:05:01 HOST CRON: (USER) CMD (DISPLAY=:0 /tmp/test.sh) Sep 10 20:05:15 HOST org.freedesktop.Notifications: org.kde.knotifications: WaitForName: Service was not registered within timeout Sep 10 20:05:15 HOST dbus-daemon: [session uid=1000 pid=76744] Activated service 'org.freedesktop.Notifications' failed: Process org.freedesktop.Notifications exited with status 1 Sep 10 20:05:15 HOST dbus-daemon: [session uid=1000 pid=76744] Activating service name='org.freedesktop.Notifications' requested by ':1.497' (uid=1000 pid=159930 comm="notify-send notify-send test " label="unconfined")
I was searching for
org.kde.knotifications: WaitForName: Service was not registered within timeout but failed to find any explanation what this is really caused by. I suspect that cron job environment is missing something (i.e. say env var?) that is otherwise present when launched from interactive shell, but I somehow stuck and not sure what to check next. So, ancient, posts suggested turning off panel auto-hide (I am no using auto-hide feature) or ensuring I did not mute notifications in tray (not my case either). I definitely lacks some knowledge here, so my question is - what is really preventing notification from showing up as expected? I understand that running cron job is not an equivalent of user's manual launch, yet I failed to figure out what is really the vital difference here that I should artificially provide. What shall I peek next in my finding culprit quest? I am simply out of ideas at the moment, and nothing I found during my search crusade pushed mu any step forward right now.
I'd really apreciate any hints or thoughts about that or what to peek/read/investigate next as I am currently out of ideas.