]> code.delx.au - bg-scripts/blobdiff - randombg.py
Merged in the wallpaper setting code for Windows (Tested on Windows XP, without PIL).
[bg-scripts] / randombg.py
index 0bc4b7973610495f8ac665bc82c11a4d21b72406..fff408f3b6d6cacf6fe77487986d5dc1551294b7 100755 (executable)
@@ -245,7 +245,7 @@ class FolderRandomFileList(BaseFileList):
 
 
 class Cycler(object):
-       def init(self, options, paths):
+       def init(self, options, paths, oneshot=False):
                self.cycle_time = options.cycle_time
                self.history_filename = options.history_filename
 
@@ -274,7 +274,10 @@ class Cycler(object):
                        sys.exit(1)
        
                self.task = None
-               self.cmd_reload()
+               if oneshot:
+                       self.cmd_next()
+               else:
+                       self.cmd_reload()
        
        def finish(self):
                self.filelist.store_cache(self.history_filename)
@@ -293,6 +296,7 @@ class Cycler(object):
                        self.task.cancel()
                self.task = asyncsched.schedule(self.cycle_time, next)
                logging.debug("Reset timer for %s seconds" % self.cycle_time)
+               self.filelist.store_cache(self.history_filename)
        
        def cmd_reload(self):
                image = self.filelist.get_current_image()
@@ -396,7 +400,7 @@ def do_client(options, args):
 
 def do_oneshot(options, paths):
        cycler = Cycler()
-       cycler.init(options, paths)
+       cycler.init(options, paths, oneshot=True)
 
 def build_parser():
        parser = OptionParser(version="%prog " + VERSION, 
@@ -449,11 +453,11 @@ def main():
        
        if options.oneshot:
                do_oneshot(options, args)
-
-       if os.path.exists(options.socket_filename):
-               do_client(options, args)
        else:
-               do_server(options, args)
+               if os.path.exists(options.socket_filename):
+                       do_client(options, args)
+               else:
+                       do_server(options, args)
 
 
 if __name__ == "__main__":