summaryrefslogtreecommitdiff
path: root/pywal/image.py
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2017-12-31 07:55:22 +1100
committerDylan Araps <dylan.araps@gmail.com>2017-12-31 07:55:22 +1100
commitb79a0d65146f539e212639acb774e8a1a4adea7e (patch)
tree2523b58790a1d4f05614021dc186d3b2ec591f92 /pywal/image.py
parent31eb532843c9268a0cff057fe59d048fc756b4d0 (diff)
shuffle: Better error handling, don't exit if one image found. Closes #149
Diffstat (limited to 'pywal/image.py')
-rw-r--r--pywal/image.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/pywal/image.py b/pywal/image.py
index e4bccfa..5e9413d 100644
--- a/pywal/image.py
+++ b/pywal/image.py
@@ -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)