[Workaround] Can't Display Notifications as root

Forum rules
Before you post please read how to get help
Post Reply
ajgringo619
Level 6
Level 6
Posts: 1386
Joined: Thu Mar 01, 2018 8:36 pm
Location: San Diego, California

[Workaround] Can't Display Notifications as root

Post by ajgringo619 » Sat Jul 06, 2019 6:48 pm

I have just completed the transition from XFCE to Cinnamon. I'm working on converting some of my scripts and have ran into a problem I can't seem to solve. I have a backup script that displays notifications when it starts and stops, as well as when it needs me to plug in my portable USB drive. When using XFCE, the following worked:

Root crontab

Code: Select all

SHELL=/bin/bash

DISPLAY=":0.0"
XAUTHORITY="/home/me/.Xauthority"
XDG_RUNTIME_DIR="/run/user/1000"

00 10 * * * /usr/local/sbin/rsync_backup >> /var/log/rsync_backup.log
00 21 * * * /usr/local/sbin/clonezilla_backup > /dev/null
Notification (from rsync_backup)

Code: Select all

zenity --notification --window-icon="info" --text="Daily backup started - `date +%Y-%m-%d` @ `date +%H:%M`"
Now, using Cinnamon, none of my zenity notifications work. I even tried going back to notify-send, but that doesn't work either. The strange thing is that it's only notifications; when I use something like zenity --warning --text="This is a test" from root's crontab (or the terminal, for that matter), the message window works as expected. When I try to run the notification command from the terminal, I get this error:

Code: Select all

zenity --notification --text="Testing"

** (zenity:24500): WARNING **: 15:44:58.055: Error showing notification: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
Last edited by ajgringo619 on Sat Jul 06, 2019 7:24 pm, edited 1 time in total.
Mint 19.2 XFCE
kernel 4.15.0-64-generic
AMD FX-8350 Eight-Core w/16 GB RAM
Nvidia GeForce 960 w/2GB RAM (435.21)
Image

ajgringo619
Level 6
Level 6
Posts: 1386
Joined: Thu Mar 01, 2018 8:36 pm
Location: San Diego, California

Re: Can't Display Notifications as root

Post by ajgringo619 » Sat Jul 06, 2019 7:23 pm

OK - adding export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus to my root crontab makes notify-send work, but zenity (notifications only) still does not. I have to run them like this:

Code: Select all

su me -c '/usr/bin/notify-send "Daily backup ended - `date +%Y-%m-%d` @ `date +%H:%M:%S`"'
Mint 19.2 XFCE
kernel 4.15.0-64-generic
AMD FX-8350 Eight-Core w/16 GB RAM
Nvidia GeForce 960 w/2GB RAM (435.21)
Image

User avatar
MrEen
Level 13
Level 13
Posts: 4561
Joined: Mon Jun 12, 2017 8:39 pm

Re: [Workaround] Can't Display Notifications as root

Post by MrEen » Sat Jul 06, 2019 9:46 pm

ajgringo619 wrote:
Sat Jul 06, 2019 6:48 pm

Code: Select all

zenity --notification --text="Testing"

** (zenity:24500): WARNING **: 15:44:58.055: Error showing notification: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
I'm still on 18.3 Xfce. The above worked perfectly for me. And by perfectly I mean I didn't even get the usual "Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged." warning.

Sorry I can't help any more than that. (Like that was of any help whatsoever.)

EDIT: I just went into Menu > Settings > Notifications > Applications tab and unchecked Zenity notification then ran the above again. Still no warning, but also no notification. Maybe Cinnamon has a similar setting?

ajgringo619
Level 6
Level 6
Posts: 1386
Joined: Thu Mar 01, 2018 8:36 pm
Location: San Diego, California

Re: [Workaround] Can't Display Notifications as root

Post by ajgringo619 » Sat Jul 06, 2019 9:51 pm

Cinnamon doesn't have a way, at least through the System Settings, to turn off individual application notifications; I'm going to really miss the XFCE Notification plug-in! :cry: I'm going to have to do some research on how exactly Cinnamon handles notifications.
Mint 19.2 XFCE
kernel 4.15.0-64-generic
AMD FX-8350 Eight-Core w/16 GB RAM
Nvidia GeForce 960 w/2GB RAM (435.21)
Image

Post Reply

Return to “Scripts & Bash”