parser.add_option("--folder-random",
action="store_true", dest="folder_random", default=False,
help="Give each folder an equal chance of having an image selected from it")
+ parser.add_option("--convert",
+ action="store_true", dest="convert", default=False,
+ help="Do conversions using ImageMagick or PIL, don't rely on the window manager")
parser.add_option("--cycle-time",
action="store", type="int", default=1800, dest="cycle_time",
help="Cause the image to cycle every X seconds")
class BaseChanger(object):
name = "undefined"
- def __init__(self, background_color='black', permanent=False):
+ def __init__(self, background_color='black', permanent=False, convert=False):
info('Determined the window manager is "%s"' % self.name)
self.background_color = background_color
self.permanent = permanent
+ self.convert = convert
def set_image(self, filename):
raise NotImplementedError()
return output_name, subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=None).wait()
def set_image(self, file):
- file, convert_status = self.convert_image_format(file)
- if convert_status:
- debug('Convert failed')
+ if self.convert:
+ file, convert_status = self.convert_image_format(file)
+ if convert_status:
+ debug('Convert failed')
cmd = ["wmsetbg",
"-b", self.background_color, # Sets the background colour to be what the user specified
"-S", # 'Smooth' (WTF?)
_ConvertedWallpaperLocation = '/tmp/wallpapers/'
_DesktopPlistLocation = os.path.expanduser('~/Library/Preferences/com.apple.desktop.plist')
+ def __init__(self, *args, **kwargs):
+ BaseChanger.__init__(self, *args, **kwargs)
+ self.fix_desktop_plist()
+
def remove_old_image_cache(self):
"""Cleans up any old temp images"""
if not os.path.isdir(self._ConvertedWallpaperLocation):
except ImportError:
debug('Could not import the Foundation module, you may have problems with dual screens')
- def set_image(self, file):
- output_name, ret = self.convert_image_format(file)
- if not ret:
- debug("Convert failed")
- return False
- self.fix_desktop_plist()
- cmd = """osascript -e 'tell application "finder" to set desktop picture to posix file "%s"'""" % output_name
+ def set_image(self, filename):
+ if self.convert:
+ filename, ret = self.convert_image_format(filename)
+ if not ret:
+ debug("Convert failed")
+ return False
+ cmd = """osascript -e 'tell application "finder" to set desktop picture to posix file "%s"'""" % filename
debug(cmd)
return not commands.getstatusoutput(cmd)[0]