mirror of
https://github.com/anufrievroman/waypaper.git
synced 2024-09-11 08:15:30 +03:00
Fixing random selection
This commit is contained in:
parent
858c0127f2
commit
958c8cf61e
@ -49,7 +49,7 @@ def run():
|
||||
for wallpaper, monitor in zip(cf.wallpaper, cf.monitors):
|
||||
|
||||
if args.random:
|
||||
wallpaper = get_random_file(cf.image_folder, cf.include_subfolders)
|
||||
wallpaper = get_random_file(cf.backend, cf.image_folder, cf.include_subfolders)
|
||||
|
||||
if wallpaper is None:
|
||||
continue
|
||||
|
@ -420,7 +420,7 @@ class App(Gtk.Window):
|
||||
def set_random_wallpaper(self):
|
||||
"""Choose a random image and set it as the wallpaper"""
|
||||
self.cf.backend = self.backend_option_combo.get_active_text()
|
||||
self.cf.selected_wallpaper = get_random_file(self.cf.image_folder, self.cf.include_subfolders)
|
||||
self.cf.selected_wallpaper = get_random_file(self.cf.backend, self.cf.image_folder, self.cf.include_subfolders)
|
||||
if self.cf.selected_wallpaper is None:
|
||||
return
|
||||
print(self.txt.msg_path, self.cf.selected_wallpaper)
|
||||
|
@ -29,10 +29,10 @@ def get_image_paths(backend, root_folder, include_subfolders=False, depth=None):
|
||||
return image_paths
|
||||
|
||||
|
||||
def get_random_file(folder, include_subfolders):
|
||||
def get_random_file(backend, folder, include_subfolders):
|
||||
"""Pick a random file from the folder"""
|
||||
try:
|
||||
image_paths = get_image_paths(folder, include_subfolders, depth=1)
|
||||
image_paths = get_image_paths(backend, folder, include_subfolders, depth=1)
|
||||
return random.choice(image_paths)
|
||||
except:
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user