1

Forgive my stupidity but I'm trying to make a script that has to been ran as root to print a notification but it won't work for some reason??

It works just fine when ran without Sudo. If I try to run it with sudo it gives me this error?? ** (zenity:14645): WARNING **: 16:25:09.209: Error showing notification: The connection is closed

Could someone give me some insight to this issue and possible a solution?

Here is the command. echo 'message:Finished!' | timeout 0.1 zenity --notification --listen --display=:0.0

Kevin Char
  • 65
  • 6

1 Answers1

0

Testing here, mine only works if I pass XDG_RUNTIME_DIR, otherwise it hangs and eventually shows:

Error showing notification: Error calling StartServiceByName for org.freedesktop.Notifications: Timeout was reached

And it needs to run as the target user, not root (not even if xhost + is allowed), or the same happens.

This works here:

sudo -u $USER --preserve-env=DISPLAY,XDG_RUNTIME_DIR \
  zenity --timeout 1 --notification --text test &

Gnome 3.30.2, zenity 3.30.0.

melissa_boiko
  • 153
  • 10