mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-02-18 03:01:03 +01:00
shuffle: Better error handling, don't exit if one image found. Closes #149
This commit is contained in:
parent
31eb532843
commit
b79a0d6514
@ -19,10 +19,13 @@ def get_random_image(img_dir):
|
||||
".PNG", ".JPG", ".JPEG", ".JPE", ".GIF")
|
||||
|
||||
images = [img for img in os.scandir(img_dir)
|
||||
if img.name.endswith(file_types) and img.name != current_wall]
|
||||
if img.name.endswith(file_types)]
|
||||
|
||||
if not images:
|
||||
print("image: No new images found (nothing to do), exiting...")
|
||||
if len(images) > 2 and current_wall in images:
|
||||
images.remove(current_wall)
|
||||
|
||||
elif not images:
|
||||
print("error: No images found in directory.")
|
||||
sys.exit(1)
|
||||
|
||||
random.shuffle(images)
|
||||
|
Loading…
Reference in New Issue
Block a user