From 1bd5542beb1d43d49549675c1040167f8874722e Mon Sep 17 00:00:00 2001 From: Lorenz Leitner Date: Tue, 10 Sep 2019 18:09:43 +0200 Subject: [PATCH 1/4] Make wal -R understand the -l flag, add -d flag https://github.com/dylanaraps/pywal/issues/441 --- pywal/__main__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pywal/__main__.py b/pywal/__main__.py index de992b7..af0770c 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -76,6 +76,9 @@ def get_args(): arg.add_argument("-l", action="store_true", help="Generate a light colorscheme.") + arg.add_argument("-d", action="store_true", + help="Generate a dark colorscheme. Default.") + arg.add_argument("-n", action="store_true", help="Skip setting the wallpaper.") @@ -175,6 +178,17 @@ def parse_args(parser): if args.R: colors_plain = theme.file(os.path.join(CACHE_DIR, "colors.json")) + if args.l: + f = open(os.path.join(CACHE_DIR, "wal")) + cached_wallpaper = f.read() + colors_plain = colors.get(cached_wallpaper, True, args.backend, + sat=args.saturate) + elif args.d: + f = open(os.path.join(CACHE_DIR, "wal")) + cached_wallpaper = f.read() + colors_plain = colors.get(cached_wallpaper, False, args.backend, + sat=args.saturate) + if args.b: args.b = "#%s" % (args.b.strip("#")) colors_plain["special"]["background"] = args.b From f44ca5da87408549a560867811955270615bedd0 Mon Sep 17 00:00:00 2001 From: Lorenz Leitner Date: Tue, 10 Sep 2019 20:31:42 +0200 Subject: [PATCH 2/4] Fix filename --- pywal/__main__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index af0770c..cfcafe4 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -179,13 +179,13 @@ def parse_args(parser): colors_plain = theme.file(os.path.join(CACHE_DIR, "colors.json")) if args.l: - f = open(os.path.join(CACHE_DIR, "wal")) - cached_wallpaper = f.read() + wallpaper_cache = open(os.path.join(CACHE_DIR, "wal")) + cached_wallpaper = wallpaper_cache.read() colors_plain = colors.get(cached_wallpaper, True, args.backend, sat=args.saturate) elif args.d: - f = open(os.path.join(CACHE_DIR, "wal")) - cached_wallpaper = f.read() + wallpaper_cache = open(os.path.join(CACHE_DIR, "wal")) + cached_wallpaper = wallpaper_cache.read() colors_plain = colors.get(cached_wallpaper, False, args.backend, sat=args.saturate) From fefcd53fcf1476afce442e207197eef99c5e97aa Mon Sep 17 00:00:00 2001 From: Lorenz Leitner Date: Wed, 11 Sep 2019 09:35:31 +0200 Subject: [PATCH 3/4] Use util.read_file instead of inline file reading --- pywal/__main__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index cfcafe4..cb0523c 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -179,14 +179,12 @@ def parse_args(parser): colors_plain = theme.file(os.path.join(CACHE_DIR, "colors.json")) if args.l: - wallpaper_cache = open(os.path.join(CACHE_DIR, "wal")) - cached_wallpaper = wallpaper_cache.read() - colors_plain = colors.get(cached_wallpaper, True, args.backend, + cached_wallpaper = util.read_file(os.path.join(CACHE_DIR, "wal")) + colors_plain = colors.get(cached_wallpaper[0], True, args.backend, sat=args.saturate) elif args.d: - wallpaper_cache = open(os.path.join(CACHE_DIR, "wal")) - cached_wallpaper = wallpaper_cache.read() - colors_plain = colors.get(cached_wallpaper, False, args.backend, + cached_wallpaper = util.read_file(os.path.join(CACHE_DIR, "wal")) + colors_plain = colors.get(cached_wallpaper[0], False, args.backend, sat=args.saturate) if args.b: From bab56a88a899ac4a96aadbbb0975289046e617df Mon Sep 17 00:00:00 2001 From: Lorenz Leitner Date: Wed, 11 Sep 2019 19:40:34 +0200 Subject: [PATCH 4/4] Use separate flag for last used wallpaper --- pywal/__main__.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index cb0523c..0f0f077 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -76,9 +76,6 @@ def get_args(): arg.add_argument("-l", action="store_true", help="Generate a light colorscheme.") - arg.add_argument("-d", action="store_true", - help="Generate a dark colorscheme. Default.") - arg.add_argument("-n", action="store_true", help="Skip setting the wallpaper.") @@ -104,6 +101,9 @@ def get_args(): arg.add_argument("-v", action="store_true", help="Print \"wal\" version.") + arg.add_argument("-w", action="store_true", + help="Use last used wallpaper for color generation.") + arg.add_argument("-e", action="store_true", help="Skip reloading gtk/xrdb/i3/sway/polybar") @@ -141,6 +141,7 @@ def parse_args_exit(parser): if not args.i and \ not args.theme and \ not args.R and \ + not args.w and \ not args.backend: parser.error("No input specified.\n" "--backend, --theme, -i or -R are required.") @@ -178,14 +179,10 @@ def parse_args(parser): if args.R: colors_plain = theme.file(os.path.join(CACHE_DIR, "colors.json")) - if args.l: - cached_wallpaper = util.read_file(os.path.join(CACHE_DIR, "wal")) - colors_plain = colors.get(cached_wallpaper[0], True, args.backend, - sat=args.saturate) - elif args.d: - cached_wallpaper = util.read_file(os.path.join(CACHE_DIR, "wal")) - colors_plain = colors.get(cached_wallpaper[0], False, args.backend, - sat=args.saturate) + if args.w: + cached_wallpaper = util.read_file(os.path.join(CACHE_DIR, "wal")) + colors_plain = colors.get(cached_wallpaper[0], args.l, args.backend, + sat=args.saturate) if args.b: args.b = "#%s" % (args.b.strip("#"))