diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-07-09 23:27:15 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-07-09 23:27:15 +1000 |
| commit | 91fa1e0ca5177587dfb8a8689dbec0aab7f440b8 (patch) | |
| tree | 97cf9a99ea4fa45150345326a9d0f7b156e3fc65 /pywal | |
| parent | 07fd6fa6619444c0da248cce96604de972a04720 (diff) | |
export: Add error handling
Diffstat (limited to 'pywal')
| -rw-r--r-- | pywal/__main__.py | 13 | ||||
| -rw-r--r-- | pywal/wallpaper.py | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/pywal/__main__.py b/pywal/__main__.py index ff86b00..0be6cc8 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -89,20 +89,23 @@ def process_args(args): # -i if args.i: image_file = image.get_image(args.i) - - # Create a list of hex colors. colors_plain = magic.get_colors(image_file, args.q) - if not args.n: - wallpaper.set_wallpaper(image_file) - # -f elif args.f: colors_plain = util.read_file_json(args.f) + # If wallpaper is unset, set it to "None" + if "wallpaper" not in colors_plain: + colors_plain["wallpaper"] = "None" + # -i or -f if args.i or args.f: sequences.send_sequences(colors_plain, args.t) + + if not args.n: + wallpaper.set_wallpaper(colors_plain["wallpaper"]) + export.export_all_templates(colors_plain) reload.reload_env() diff --git a/pywal/wallpaper.py b/pywal/wallpaper.py index 59f1aeb..5e524a3 100644 --- a/pywal/wallpaper.py +++ b/pywal/wallpaper.py @@ -82,6 +82,9 @@ def set_desktop_wallpaper(desktop, img): def set_wallpaper(img): """Set the wallpaper.""" + if not os.path.isfile(img): + return + desktop = get_desktop_env() if desktop: |
