I need to run a script as root called root.py. I need to create notifications within the script. I made a separate script specifically for the notifications called notify.py.
Here is notify.py:
import pynotify
import sys
def notify(title, message):
n = pynotify.Notification (title,
message,
"notification-message-im")
n.show()
if __name__ == '__main__':
notify(sys.argv[1], sys.argv[2])
notify.py script works well with a user not as root:
python notify.py Title Message
But I need to call this script inside root.py, which is ran as root. It fails if I run it as root. So, I tried to for lack of better words, sign out as root by launching it as another user (I also replaced sudo with gksudo in the following):
xhost local:user
gksudo -u user notify.py Title Message
Won't work.
Any ideas?
btw: I had a similar problem with running gtk from root ran upstart scripts. Also, gvfs won't change attributes as root when as other user as sudo.