简单的gnome自动换壁纸
闲的没事写着玩玩
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import gconf
5 import os
6 import gobject
7 import gtk
8
9 class Auto_wp:
10 def __init__(self, wp_dir):
11 self.wp_dir = wp_dir
12 self.file_list = []
13 self.index = 0
14 self.client = gconf.client_get_default()
15 self.get_file_list(self.wp_dir)
16 gobject.timeout_add(10000, self.change_wp)
17 gtk.main()
18
19 def get_file_list(self, wp_dir):
20 for parent, dirnames, filenames in os.walk(wp_dir):
21 for filename in filenames:
22 self.file_list.append(os.path.join(parent, filename))
23
24 def change_wp(self):
25 print self.file_list[self.index]
26 self.client.set_string('/desktop/gnome/background/picture_filename',self.file_list[self.index])
27 self.index += 1
28 if self.index >= len(self.file_list):
29 self.index = 0
30 gobject.timeout_add(10000, self.change_wp)
31
32 if __name__ == "__main__":
33 Auto_wp('/home/yangguang/图片/background/down')