Share Pastebin
Guest
Public paste!

King_Critter

By: a guest | Aug 4th, 2009 | Syntax: Python | Size: 0.58 KB | Hits: 173 | Expires: Never
Copy text to clipboard
  1. #!/usr/bin/env python
  2. from easygconf import GConfDict
  3. from daemon import Daemon
  4. import time
  5. import random
  6. import os
  7.  
  8. gc = GConfDict('/desktop/gnome/background')
  9.  
  10. dirname = os.path.join(os.path.expanduser("~"), "pics/wallpaper/safe/")
  11.  
  12. wallpapers = [f for f in os.listdir(dirname)
  13.         if os.path.isfile(os.path.join(dirname, f))]
  14.  
  15. class MyDaemon(Daemon):
  16.         def run(self):
  17.                 while True:
  18.                         dice = random.randint(0,(len(wallpapers)-1))
  19.                         gc["picture_filename"] = dirname + wallpapers[dice]
  20.                         time.sleep(60*5)
  21.  
  22. daemon = MyDaemon('/tmp/critters-wallpaper-switcher.pid')
  23. daemon.start()