X-Git-Url: https://code.delx.au/bg-scripts/blobdiff_plain/e4213ca1d2783c9e10aed97b719d40fb4165d276..37a55b03716139bdc88b0cd444e8b0eabab6669d:/randombg.py diff --git a/randombg.py b/randombg.py index 0bc4b79..fff408f 100755 --- a/randombg.py +++ b/randombg.py @@ -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__":