diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-07-20 23:19:13 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-07-20 23:19:13 +1000 |
| commit | 52cd5e5f1a7c972a593fe55a853afd43111531e9 (patch) | |
| tree | 86a972bee26b93db9f8f8bd3fd5c8d05553ec4c0 /pywal/image.py | |
| parent | a3d4b3d9f348fd308ad8a55f5ef71263e11b6875 (diff) | |
General: Unhardcode all CACHE_DIR and COLOR_COUNT usage.
Diffstat (limited to 'pywal/image.py')
| -rw-r--r-- | pywal/image.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/pywal/image.py b/pywal/image.py index 394967d..43bc7b5 100644 --- a/pywal/image.py +++ b/pywal/image.py @@ -5,13 +5,12 @@ import os import pathlib import random -from pywal.settings import CACHE_DIR from pywal import util -def get_random_image(img_dir): +def get_random_image(img_dir, cache_dir): """Pick a random image file from a directory.""" - current_wall = CACHE_DIR / "wal" + current_wall = cache_dir / "wal" if current_wall.is_file(): current_wall = util.read_file(current_wall) @@ -30,7 +29,7 @@ def get_random_image(img_dir): return img_dir / random.choice(images).name -def get_image(img): +def get_image(img, cache_dir): """Validate image input.""" image = pathlib.Path(img) @@ -38,7 +37,7 @@ def get_image(img): wal_img = image elif image.is_dir(): - wal_img = get_random_image(image) + wal_img = get_random_image(image, cache_dir) else: print("error: No valid image file found.") |
