import commands, sys, os, os.path, subprocess, time
from GregDebug import debug, setDebugLevel, DEBUG_LEVEL_DEBUG, DEBUG_LEVEL_LOW, DEBUG_LEVEL_MEDIUM, DEBUG_LEVEL_HIGH, DEBUG_INCREMENT
-import FileLists
import python24_adapter # NB: Must be imported before collections
import collections
return ret
class __BaseChanger(object):
- def __init__(self, filelist, backgroundColour='black', permanent=False):
+ def __init__(self, backgroundColour='black', permanent=False):
debug('Determined the window manager is "%s"' % self.__class__.__name__, DEBUG_LEVEL_MEDIUM)
self.backgroundColour = backgroundColour
self.permanent = permanent
- self.filelist = filelist
# Used to 'chain' background changers
self.nextChanger = None
-
- def callChained(self, filename):
- if self.nextChanger is None:
- return True
- else:
- return self.nextChanger.changeTo(filename)
-
- def cycleNext(self):
- file = self.filelist.getNextRandomImage()
- return self.changeTo(file) and self.callChained(file)
-
- def cyclePrev(self):
- file = self.filelist.getPrevRandomImage()
- return self.changeTo(file) and self.callChained(file)
- def cycleReload(self):
- try:
- file = self.filelist.getCurrentImage()
- return self.changeTo(file) and self.callChained(file)
- except FileLists.FileListNotImplemented:
- return self.cycleNext()
-
+ def setImage(self, filename):
+ self._setImage(filename)
+ if self.nextChanger is not None:
+ self.nextChange.changeTo(filename)
class __WMakerChanger(__BaseChanger):
_ConvertedWallpaperLocation = '/tmp/wallpapers_wmaker/'
cmd = ["convert", '-resize', '1280', '-gravity', 'Center', '-crop', '1280x800+0+0', file, output_name]
debug("""Convert command: '"%s"'""" % '" "'.join(cmd), DEBUG_LEVEL_DEBUG)
return output_name, subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=None).wait()
- def changeTo(self, file):
+
+ def _setImage(self, file):
file, convert_status = self._convertImageFormat(file)
if convert_status:
debug('Convert failed')
except ImportError:
debug('Could not import the Foundation module, you may have problems with dual screens', DEBUG_LEVEL_MEDIUM)
- def changeTo(self, file):
+ def _setImage(self, file):
output_name, ret = self._convertImageFormat(file)
if not ret:
debug("Convert failed")
return not commands.getstatusoutput(cmd)[0]
class __GnomeChanger(__BaseChanger):
- def changeTo(self, file):
+ def _setImage(self, file):
cmd = ['gconftool-2', '--type', 'string', '--set', '/desktop/gnome/background/picture_filename', file]
debug(cmd, DEBUG_LEVEL_DEBUG)
return subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=None).wait()
class __KDEChanger(__BaseChanger):
- def changeTo(self, file):
+ def _setImage(self, file):
cmds = []
for group in ('Desktop0', 'Desktop0Screen0'):
base = ['kwriteconfig', '--file', 'kdesktoprc', '--group', group, '--key']