def main(): print_info() wp = WallpaperPicker() while True: # if you modify the config file, this script doesn't have to be restarted reload(cfg) cfg.self_verify() wp.collect_images() nb_images = wp.get_nb_images() if nb_images == 0: # there are no images in the directory => do nothing pass if nb_images == 1: # there is only one image => easy choice wallpaper = wp.get_first_image() if nb_images > 1: # there are several images => choose a different image than the previous pick wallpaper = wp.get_random_image() gnome.set_wallpaper_image(wallpaper) try: sleep(float(cfg.DURATION)) except KeyboardInterrupt: sys.exit()
def main(): print_info() wp = WallpaperPicker() while True: # if you modify the config file, this script doesn't have to be restarted reload(cfg) cfg.self_verify() # The list of images is re-read in each iteration because Wallpaper Downloader # is supposed to work parallelly. Thus, newly downloaded images will have a # chance to appear on the desktop. wp.collect_images() nb_images = wp.get_nb_images() if nb_images == 0: # there are no images in the directory => do nothing pass if nb_images == 1: # there is only one image => easy choice wallpaper = wp.get_first_image() if nb_images > 1: # there are several images => choose a different image than the previous pick wallpaper = wp.get_random_image() gnome.set_wallpaper_image(wallpaper) wp.free_memory() try: sleep(float(cfg.DURATION)) except KeyboardInterrupt: sys.exit()