I just want to show notification in KDE environment.So i tried pynotifytest.py
from pynotify import *
init("test")
Notification("test", "test").show()
then i run sudo python pynotifytest.py
,the error i got was:
No protocol specified
/usr/lib/python2.7/site-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display warnings.warn(str(e), _gtk.Warning)
----> 3 Notification("test", "test").show()
Error: Command line `dbus-launch --autolaunch=cb94cb23372d0aff09ce7d8a000024b4 --binary-syntax --close-stderr' exited with non-zero exit status 1: No protocol specified\nAutolaunch error: X11 initialization failed.
then i tried to drop privilege pynotifytest.py
import os
os.setuid(1000)
from pynotify import *
init("test")
Notification("test", "test").show()
still i got the same error only in KDE.In gnome-shell and awesome the notification show up as expected.I have a python program must running with root privilege so i can't leave sudo behind. 1000 is my user's uid logging in X.
My linux distribution is Arch. Thanks
To allow sudo to start graphical application in X, you need to add:
to visudo.