You are not logged in.
Pages: 1
Hi guys,
I created a little script to check for Arch updates using pynotify. Now if I execute the script manually it runs fine and shows the notification. If I run it trough cron it runs as well just it won't show the notification. Any idea why?
#!/usr/bin/env python
import gtk
import os
import pynotify
def _gtk_destroy(dummyarg):
gtk.main_quit()
def main():
count = 0
updates = "\n";
output = os.popen("sudo pacman -Syup --noprogressbar").read()
output = output.split('\n')
for line in output:
line = line.rstrip('\n')
if line.endswith(".pkg.tar.gz"):
linet = line.rsplit('/', 1)
updates = updates + linet[-1]
updates = updates + "\n"
count = count + 1
if count is not 0:
if pynotify.init("ArchUpdateNotifyer"):
if count == 1: msg = "There is 1 update available:\n"
else: msg = ("There are %i updates available:\n" % count)
msg = msg + updates
note = pynotify.Notification("Arch Update Notification", msg, "dialog-information")
note.set_urgency(pynotify.URGENCY_NORMAL)
note.set_hint("x", 1600)
note.set_hint("y", 20)
note.set_timeout(10000)
note.connect('closed', _gtk_destroy)
note.show()
gtk.main()
if __name__ == "__main__":
main()
//edit:
Btw, if I use "Run Task" in gnome-scheduler it also runs as supposed to.
Last edited by panzer (2008-08-29 15:21:06)
Offline
I narrowed it down.
if pynotify.init("ArchUpdateNotifyer"):
This will fail when run through cron. I don't understand why, though.
Offline
Apparently nothing pythongtk based is succesfully executed through cron. I can execute python gtk scripts fine in gnome. But if cron is supposed to run a script it just won't load anything gtk related in the script, not even a messagebox. Why is that?
Offline
Just a guess here...but cron isn't run as you. It may be that root doesn't have access to your X-server, or notification-daemon...or something along those lines.
Cthulhu For President!
Offline
Pages: 1