-class GnomeChanger(BaseChanger):
- name = "Gnome"
- def set_image(self, file):
- cmd = ['gconftool-2', '--type', 'string', '--set', '/desktop/gnome/background/picture_filename', file]
- logging.debug(cmd)
- return not subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=None).wait()
-
-class KDEChanger(BaseChanger):
- name = "KDE"
- def set_image(self, file):
- cmds = []
- for group in ('Desktop0', 'Desktop0Screen0'):
- base = ['kwriteconfig', '--file', 'kdesktoprc', '--group', group, '--key']
- cmds.append(base + ['Wallpaper', file])
- cmds.append(base + ['UseSHM', '--type', 'bool', 'true'])
- cmds.append(base + ['WallpaperMode', 'ScaleAndCrop'])
- cmds.append(base + ['MultiWallpaperMode', 'NoMulti'])
-
- cmds.append(['dcop', 'kdesktop', 'KBackgroundIface', 'configure'])
- for cmd in cmds:
- logging.debug(cmd)
- if subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=None).wait() != 0:
+class WIN32Changer(BaseChanger):
+ name = "Windows"
+ _ConvertedWallpaperLocation = os.path.join(os.environ.get('APPDATA', os.path.expanduser('~')), 'wallchanger')
+
+ def __init__(self, *args, **kwargs):
+ BaseChanger.__init__(self, *args, **kwargs)
+ if not self.convert:
+ logging.warn('Running on windows, but convert is not set')
+
+ def remove_old_image_cache(self):
+ """Cleans up any old temp images"""
+ if not os.path.isdir(self._ConvertedWallpaperLocation):
+ os.mkdir(self._ConvertedWallpaperLocation)
+ for fullpath, filenames, dirnames in os.walk(self._ConvertedWallpaperLocation, topdown=False):
+ for filename in filenames:
+ os.unlink(os.path.join(fullpath, filename))
+ for dirname in dirnames:
+ os.unlink(os.path.join(fullpath, dirname))
+
+ def set_image(self, filename):
+ import ctypes
+ user32 = ctypes.windll.user32
+
+ # Taken from the Platform SDK
+ SPI_SETDESKWALLPAPER = 20
+ SPIF_SENDWININICHANGE = 2
+
+ if self.convert:
+ filename, ret = self.convert_image_format(filename)
+ if not ret:
+ logging.debug("Convert failed")