From cb3d53ee0c2dc0f4132ec119b7e96d6c3c5d2266 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 15 Mar 2018 16:26:47 +1100 Subject: [PATCH 01/29] themes: Initial theme support --- pywal/colors.py | 25 ++++++++++++++++++------- pywal/colorschemes/solarized-dark.json | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 pywal/colorschemes/solarized-dark.json diff --git a/pywal/colors.py b/pywal/colors.py index f47ac33..4bd3655 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -7,7 +7,7 @@ import shutil import subprocess import sys -from .settings import CACHE_DIR, COLOR_COUNT, __cache_version__ +from .settings import CACHE_DIR, COLOR_COUNT, MODULE_DIR, __cache_version__ from . import util @@ -129,12 +129,23 @@ def get(img, cache_dir=CACHE_DIR, def file(input_file): """Import colorscheme from json file.""" - data = util.read_file_json(input_file) + theme_file = os.path.join(MODULE_DIR, "colorschemes", + ".".join((input_file, "json"))) - if "wallpaper" not in data: - data["wallpaper"] = "None" + if os.path.isfile(theme_file): + input_file = theme_file - if "alpha" not in data: - data["alpha"] = "100" + if os.path.isfile(input_file): + data = util.read_file_json(input_file) - return data + if "wallpaper" not in data: + data["wallpaper"] = "None" + + if "alpha" not in data: + data["alpha"] = "100" + + return data + + else: + print("No colorscheme file found, exiting...") + sys.exit(1) diff --git a/pywal/colorschemes/solarized-dark.json b/pywal/colorschemes/solarized-dark.json new file mode 100644 index 0000000..a611e31 --- /dev/null +++ b/pywal/colorschemes/solarized-dark.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#073642", + "foreground": "#fdf6e3", + "cursor": "#dc322f" + }, + "colors": { + "color0": "#073642", + "color1": "#dc322f", + "color2": "#859900", + "color3": "#b58900", + "color4": "#268bd2", + "color5": "#d33682", + "color6": "#2aa198", + "color7": "#eee8d5", + "color8": "#6c7c80", + "color9": "#dc322f", + "color10": "#859900", + "color11": "#b58900", + "color12": "#268bd2", + "color13": "#d33682", + "color14": "#2aa198", + "color15": "#eee8d5" + } +} From 59987878886587cf8b9c38bf87cbb78066b92575 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 15 Mar 2018 16:34:38 +1100 Subject: [PATCH 02/29] themes: Added gruvbox. --- pywal/colorschemes/gruvbox.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pywal/colorschemes/gruvbox.json diff --git a/pywal/colorschemes/gruvbox.json b/pywal/colorschemes/gruvbox.json new file mode 100644 index 0000000..5f7f8f7 --- /dev/null +++ b/pywal/colorschemes/gruvbox.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#282828", + "foreground": "#a89984", + "cursor": "#dc322f" + }, + "colors": { + "color0": "#282828", + "color1": "#cc241d", + "color2": "#d79921", + "color3": "#b58900", + "color4": "#458588", + "color5": "#b16286", + "color6": "#689d6a", + "color7": "#a89984", + "color8": "#928374", + "color9": "#cc241d", + "color10": "#d79921", + "color11": "#b58900", + "color12": "#458588", + "color13": "#b16286", + "color14": "#689d6a", + "color15": "#a89984" + } +} From a95d901deab1abd19fb4bacd9b4704eae48c0ffb Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 15 Mar 2018 16:35:11 +1100 Subject: [PATCH 03/29] themes: Added colorschemes to manifest. --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 3e0ef16..9d80177 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ include pywal/templates/* include pywal/scripts/* +include pywal/colorschemes/* include tests/* include tests/test_files/* include .pylintrc From 947922960773ce66ef86a7ede6adf5e796155c30 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 15 Mar 2018 16:39:59 +1100 Subject: [PATCH 04/29] themes: Added zenburn. --- pywal/colorschemes/gruvbox.json | 2 +- pywal/colorschemes/zenburn.json | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 pywal/colorschemes/zenburn.json diff --git a/pywal/colorschemes/gruvbox.json b/pywal/colorschemes/gruvbox.json index 5f7f8f7..6f864d6 100644 --- a/pywal/colorschemes/gruvbox.json +++ b/pywal/colorschemes/gruvbox.json @@ -2,7 +2,7 @@ "special": { "background": "#282828", "foreground": "#a89984", - "cursor": "#dc322f" + "cursor": "#cc241d" }, "colors": { "color0": "#282828", diff --git a/pywal/colorschemes/zenburn.json b/pywal/colorschemes/zenburn.json new file mode 100644 index 0000000..b0b9c53 --- /dev/null +++ b/pywal/colorschemes/zenburn.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#3f3f3f", + "foreground": "#dcdccc", + "cursor": "#cc9393" + }, + "colors": { + "color0": "#3f3f3f", + "color1": "#cc9393", + "color2": "#7f9f7f", + "color3": "#d0bf8f", + "color4": "#6ca0a3", + "color5": "#dc8cc3", + "color6": "#93e0e3", + "color7": "#dcdccc", + "color8": "#828282", + "color9": "#cc9393", + "color10": "#7f9f7f", + "color11": "#d0bf8f", + "color12": "#6ca0a3", + "color13": "#dc8cc3", + "color14": "#93e0e3", + "color15": "#dcdccc" + } +} From 90a73edda5a6484a8ad4dc081e22c0d9e53cc5e1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 15 Mar 2018 17:19:01 +1100 Subject: [PATCH 05/29] themes: Add support for terminal.sexy json --- pywal/colors.py | 22 ++++++++++++++++++++++ pywal/colorschemes/gruvbox.json | 2 +- pywal/colorschemes/zenburn.json | 25 +++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 pywal/colorschemes/zenburn.json diff --git a/pywal/colors.py b/pywal/colors.py index 4bd3655..bff33c4 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -127,6 +127,24 @@ def get(img, cache_dir=CACHE_DIR, return colors +def terminal_sexy_to_wal(data): + """Convert terminal.sexy json schema to wal.""" + data["colors"] = {} + data["special"] = {} + + for i in range(0, 16): + data["colors"]["color%s" % i] = data["color"][i if i < 9 else i - 8] + + data["colors"]["color0"] = data["background"] + data["colors"]["color7"] = data["foreground"] + data["colors"]["color15"] = data["foreground"] + data["special"]["foreground"] = data["foreground"] + data["special"]["background"] = data["background"] + data["special"]["cursor"] = data["colors"]["color1"] + + return data + + def file(input_file): """Import colorscheme from json file.""" theme_file = os.path.join(MODULE_DIR, "colorschemes", @@ -144,6 +162,10 @@ def file(input_file): if "alpha" not in data: data["alpha"] = "100" + # Terminal.sexy format. + if isinstance(data["color"], list): + data = terminal_sexy_to_wal(data) + return data else: diff --git a/pywal/colorschemes/gruvbox.json b/pywal/colorschemes/gruvbox.json index 5f7f8f7..6f864d6 100644 --- a/pywal/colorschemes/gruvbox.json +++ b/pywal/colorschemes/gruvbox.json @@ -2,7 +2,7 @@ "special": { "background": "#282828", "foreground": "#a89984", - "cursor": "#dc322f" + "cursor": "#cc241d" }, "colors": { "color0": "#282828", diff --git a/pywal/colorschemes/zenburn.json b/pywal/colorschemes/zenburn.json new file mode 100644 index 0000000..b0b9c53 --- /dev/null +++ b/pywal/colorschemes/zenburn.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#3f3f3f", + "foreground": "#dcdccc", + "cursor": "#cc9393" + }, + "colors": { + "color0": "#3f3f3f", + "color1": "#cc9393", + "color2": "#7f9f7f", + "color3": "#d0bf8f", + "color4": "#6ca0a3", + "color5": "#dc8cc3", + "color6": "#93e0e3", + "color7": "#dcdccc", + "color8": "#828282", + "color9": "#cc9393", + "color10": "#7f9f7f", + "color11": "#d0bf8f", + "color12": "#6ca0a3", + "color13": "#dc8cc3", + "color14": "#93e0e3", + "color15": "#dcdccc" + } +} From c245d27874b8742400f87247aac61c7979a3dfa6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 15 Mar 2018 17:25:59 +1100 Subject: [PATCH 06/29] themes: Add support for terminal.sexy json --- pywal/colors.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pywal/colors.py b/pywal/colors.py index bff33c4..e7e75bd 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -132,12 +132,9 @@ def terminal_sexy_to_wal(data): data["colors"] = {} data["special"] = {} - for i in range(0, 16): - data["colors"]["color%s" % i] = data["color"][i if i < 9 else i - 8] + for i, color in enumerate(data["color"]): + data["colors"]["color%s" % i] = color - data["colors"]["color0"] = data["background"] - data["colors"]["color7"] = data["foreground"] - data["colors"]["color15"] = data["foreground"] data["special"]["foreground"] = data["foreground"] data["special"]["background"] = data["background"] data["special"]["cursor"] = data["colors"]["color1"] From 14adc09073aa9fc157e0e8633ffaf4e92b54038f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 15 Mar 2018 17:30:03 +1100 Subject: [PATCH 07/29] themes: Added 3024 --- pywal/colorschemes/3024.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pywal/colorschemes/3024.json diff --git a/pywal/colorschemes/3024.json b/pywal/colorschemes/3024.json new file mode 100644 index 0000000..498f96c --- /dev/null +++ b/pywal/colorschemes/3024.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#090300", + "foreground": "#a5a2a2", + "cursor": "#db2d20" + }, + "colors": { + "color0": "#090300", + "color1": "#db2d20", + "color2": "#01a252", + "color3": "#fded02", + "color4": "#01a0e4", + "color5": "#a16a94", + "color6": "#b5e4f4", + "color7": "#a5a2a2", + "color8": "#5c5855", + "color9": "#db2d20", + "color10": "#01a252", + "color11": "#fded02", + "color12": "#01a0e4", + "color13": "#a16a94", + "color14": "#b5e4f4", + "color15": "#f7f7f7" + } +} From 3569d10312ecc7d46de5e4f8e90d217f7d3dfdb3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 15 Mar 2018 17:37:17 +1100 Subject: [PATCH 08/29] themes: Added 3024 --- pywal/colors.py | 2 +- .../{3024.json => 3024-dark.json} | 0 pywal/colorschemes/3024-light.json | 25 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) rename pywal/colorschemes/{3024.json => 3024-dark.json} (100%) create mode 100644 pywal/colorschemes/3024-light.json diff --git a/pywal/colors.py b/pywal/colors.py index e7e75bd..1619e40 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -160,7 +160,7 @@ def file(input_file): data["alpha"] = "100" # Terminal.sexy format. - if isinstance(data["color"], list): + if "color" in data: data = terminal_sexy_to_wal(data) return data diff --git a/pywal/colorschemes/3024.json b/pywal/colorschemes/3024-dark.json similarity index 100% rename from pywal/colorschemes/3024.json rename to pywal/colorschemes/3024-dark.json diff --git a/pywal/colorschemes/3024-light.json b/pywal/colorschemes/3024-light.json new file mode 100644 index 0000000..aedc835 --- /dev/null +++ b/pywal/colorschemes/3024-light.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#f7f7f7", + "foreground": "#090300", + "cursor": "#db2d20" + }, + "colors": { + "color0": "#f7f7f7", + "color1": "#db2d20", + "color2": "#01a252", + "color3": "#fded02", + "color4": "#01a0e4", + "color5": "#a16a94", + "color6": "#b5e4f4", + "color7": "#090300", + "color8": "#5c5855", + "color9": "#db2d20", + "color10": "#01a252", + "color11": "#fded02", + "color12": "#01a0e4", + "color13": "#a16a94", + "color14": "#b5e4f4", + "color15": "#090300" + } +} From 98418fc3d0c79daa0e74a384b15ed60dcf19734b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 15 Mar 2018 17:52:33 +1100 Subject: [PATCH 09/29] themes: -f with no args lists themes. --- pywal/__main__.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index 7c0bf06..f9bd2a2 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -14,7 +14,7 @@ import os import shutil import sys -from .settings import __version__, CACHE_DIR +from .settings import __version__, CACHE_DIR, MODULE_DIR from . import colors from . import export from . import image @@ -42,8 +42,10 @@ def get_args(args): arg.add_argument("-i", metavar="\"/path/to/img.jpg\"", help="Which image or directory to use.") - arg.add_argument("-f", metavar="\"/path/to/colorscheme/file\"", - help="Which colorscheme file to use.") + arg.add_argument("-f", metavar="/path/to/colorscheme/file or theme_name", + help="Which colorscheme file to use. \ + Use 'wal -f' to list available builtin themes.", + const="list_themes", nargs="?") arg.add_argument("-g", action="store_true", help="Generate an oomox theme.") @@ -122,6 +124,14 @@ def process_args(args): image_file = image.get(args.i) colors_plain = colors.get(image_file, light=args.l) + if args.f == "list_themes": + themes = os.listdir(os.path.join(MODULE_DIR, "colorschemes")) + + print("Themes:", + ", ".join([theme.replace(".json", "") for theme in themes])) + + sys.exit(0) + if args.f: colors_plain = colors.file(args.f) From e76887915fa8ca4bab27309da663f438a56fa8cb Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 08:31:10 +1100 Subject: [PATCH 10/29] travis: Fix linting --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 08f340e..8d4e0ae 100644 --- a/.pylintrc +++ b/.pylintrc @@ -7,7 +7,7 @@ good-names=i,j,k,n,x,y,fg,bg,r,g,b,i3,r1,r2,r3,g1,g2,g3,b1,b2,b3,h,s,v # too-many-branches: # Disabled as it's a non-issue and only occurs in the # process_args() function. -disable=inconsistent-return-statements,too-many-branches +disable=inconsistent-return-statements,too-many-branches,too-many-statements [SIMILARITIES] ignore-imports=y From 7db89a390728944637fc4c3517894f3d22543447 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 08:47:53 +1100 Subject: [PATCH 11/29] themes: Allow local themes --- pywal/__main__.py | 5 +++-- pywal/colors.py | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index f9bd2a2..05f96e7 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -14,7 +14,7 @@ import os import shutil import sys -from .settings import __version__, CACHE_DIR, MODULE_DIR +from .settings import __version__, CACHE_DIR, MODULE_DIR, CONF_DIR from . import colors from . import export from . import image @@ -125,7 +125,8 @@ def process_args(args): colors_plain = colors.get(image_file, light=args.l) if args.f == "list_themes": - themes = os.listdir(os.path.join(MODULE_DIR, "colorschemes")) + themes = os.listdir(os.path.join(CONF_DIR, "colorschemes")) + themes += os.listdir(os.path.join(MODULE_DIR, "colorschemes")) print("Themes:", ", ".join([theme.replace(".json", "") for theme in themes])) diff --git a/pywal/colors.py b/pywal/colors.py index 1619e40..664dd4b 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -7,7 +7,8 @@ import shutil import subprocess import sys -from .settings import CACHE_DIR, COLOR_COUNT, MODULE_DIR, __cache_version__ +from .settings import CACHE_DIR, COLOR_COUNT, MODULE_DIR, \ + CONF_DIR, __cache_version__ from . import util @@ -144,10 +145,17 @@ def terminal_sexy_to_wal(data): def file(input_file): """Import colorscheme from json file.""" - theme_file = os.path.join(MODULE_DIR, "colorschemes", - ".".join((input_file, "json"))) + theme_file = ".".join((input_file, "json")) + user_theme_dir = os.path.join(CONF_DIR, "colorschemes") + user_theme_file = os.path.join(user_theme_dir, theme_file) + theme_file = os.path.join(MODULE_DIR, "colorschemes", theme_file) - if os.path.isfile(theme_file): + util.create_dir(user_theme_dir) + + if os.path.isfile(user_theme_file): + input_file = user_theme_file + + elif os.path.isfile(theme_file): input_file = theme_file if os.path.isfile(input_file): From 4492587c17d52ea3b50449a83a1357def2e51738 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 08:54:08 +1100 Subject: [PATCH 12/29] misc: cleanup --- pywal/__main__.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index 05f96e7..43f4465 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -104,6 +104,14 @@ def process_args(args): reload.colors() sys.exit(0) + if args.f == "list_themes": + themes = os.listdir(os.path.join(CONF_DIR, "colorschemes")) + themes += os.listdir(os.path.join(MODULE_DIR, "colorschemes")) + themes = [theme.replace(".json", "") for theme in themes] + + print("Themes:", ", ".join(themes)) + sys.exit(0) + if args.q: sys.stdout = sys.stderr = open(os.devnull, "w") @@ -124,15 +132,6 @@ def process_args(args): image_file = image.get(args.i) colors_plain = colors.get(image_file, light=args.l) - if args.f == "list_themes": - themes = os.listdir(os.path.join(CONF_DIR, "colorschemes")) - themes += os.listdir(os.path.join(MODULE_DIR, "colorschemes")) - - print("Themes:", - ", ".join([theme.replace(".json", "") for theme in themes])) - - sys.exit(0) - if args.f: colors_plain = colors.file(args.f) From aac48cb798e88608131f9cbfd6a6f5ed58c829e5 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 09:10:38 +1100 Subject: [PATCH 13/29] themes: Added more themes. --- pywal/colorschemes/github.json | 25 +++++++++++++++++++++++++ pywal/colorschemes/monokai-dark.json | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 pywal/colorschemes/github.json create mode 100644 pywal/colorschemes/monokai-dark.json diff --git a/pywal/colorschemes/github.json b/pywal/colorschemes/github.json new file mode 100644 index 0000000..62da597 --- /dev/null +++ b/pywal/colorschemes/github.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#ffffff", + "foreground": "#3e3e3e", + "cursor": "#970b16" + }, + "colors": { + "color0": "#3e3e3e", + "color1": "#970b16", + "color2": "#07962a", + "color3": "#f8eec7", + "color4": "#003e8a", + "color5": "#e94691", + "color6": "#89d1ec", + "color7": "#ffffff", + "color8": "#666666", + "color9": "#de0000", + "color10": "#87d5a2", + "color11": "#f1d007", + "color12": "#2e6cba", + "color13": "#ffa29f", + "color14": "#1cfafe", + "color15": "#ffffff" + } +} diff --git a/pywal/colorschemes/monokai-dark.json b/pywal/colorschemes/monokai-dark.json new file mode 100644 index 0000000..40ad451 --- /dev/null +++ b/pywal/colorschemes/monokai-dark.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#272822", + "foreground": "#f8f8f2", + "cursor": "#f92672" + }, + "colors": { + "color0": "#272822", + "color1": "#f92672", + "color2": "#a6e22e", + "color3": "#f4bf75", + "color4": "#66d9ef", + "color5": "#ae81ff", + "color6": "#a1efe4", + "color7": "#f8f8f2", + "color8": "#75715e", + "color9": "#f92672", + "color10": "#a6e22e", + "color11": "#f4bf75", + "color12": "#66d9ef", + "color13": "#ae81ff", + "color14": "#a1efe4", + "color15": "#f9f8f5" + } +} From 9ec4344ec6e429f9f16298f067bc62834eaea92b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 09:11:12 +1100 Subject: [PATCH 14/29] themes: Added more themes. --- pywal/colorschemes/github.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pywal/colorschemes/github.json b/pywal/colorschemes/github.json index 62da597..e154814 100644 --- a/pywal/colorschemes/github.json +++ b/pywal/colorschemes/github.json @@ -1,6 +1,6 @@ { "special": { - "background": "#ffffff", + "background": "#f4f4f4", "foreground": "#3e3e3e", "cursor": "#970b16" }, From 7260145e11d1eb00f26dac1ff464ca0fd270d2d8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 09:32:43 +1100 Subject: [PATCH 15/29] theme: Made wal themes more compatible --- pywal/colorschemes/github.json | 6 +++--- pywal/colorschemes/hybrid-material.json | 25 +++++++++++++++++++++++++ pywal/sequences.py | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 pywal/colorschemes/hybrid-material.json diff --git a/pywal/colorschemes/github.json b/pywal/colorschemes/github.json index e154814..28f555f 100644 --- a/pywal/colorschemes/github.json +++ b/pywal/colorschemes/github.json @@ -5,14 +5,14 @@ "cursor": "#970b16" }, "colors": { - "color0": "#3e3e3e", + "color0": "#ffffff", "color1": "#970b16", "color2": "#07962a", "color3": "#f8eec7", "color4": "#003e8a", "color5": "#e94691", "color6": "#89d1ec", - "color7": "#ffffff", + "color7": "#3e3e3e", "color8": "#666666", "color9": "#de0000", "color10": "#87d5a2", @@ -20,6 +20,6 @@ "color12": "#2e6cba", "color13": "#ffa29f", "color14": "#1cfafe", - "color15": "#ffffff" + "color15": "#3e3e3e" } } diff --git a/pywal/colorschemes/hybrid-material.json b/pywal/colorschemes/hybrid-material.json new file mode 100644 index 0000000..a5dd5a7 --- /dev/null +++ b/pywal/colorschemes/hybrid-material.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#263238", + "foreground": "#ffffff", + "cursor": "#cc6666" + }, + "colors": { + "color0": "#263238", + "color1": "#cc6666", + "color2": "#f0c674", + "color3": "#b5bd68", + "color4": "#8abeb7", + "color5": "#81a2be", + "color6": "#b294bb", + "color7": "#ffffff", + "color8": "#707880", + "color9": "#cc6666", + "color10": "#f0c674", + "color11": "#b5bd68", + "color12": "#8abeb7", + "color13": "#81a2be", + "color14": "#b294bb", + "color15": "#ffffff" + } +} diff --git a/pywal/sequences.py b/pywal/sequences.py index 1b2fce5..ecb79e3 100644 --- a/pywal/sequences.py +++ b/pywal/sequences.py @@ -50,7 +50,7 @@ def create_sequences(colors): # 13 = mouse foreground sequences.extend([set_special(10, colors["special"]["foreground"], "g"), set_special(11, colors["special"]["background"], "h"), - set_special(12, colors["colors"]["color1"], "l"), + set_special(12, colors["colors"]["color9"], "l"), set_special(13, colors["special"]["foreground"], "l"), set_special(17, colors["special"]["foreground"], "l"), set_special(19, colors["special"]["background"], "l")]) From 534768a791af167567ed4f7390950a4dd6902854 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 09:39:54 +1100 Subject: [PATCH 16/29] theme: Added vscode-dark --- pywal/colorschemes/vscode-dark.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pywal/colorschemes/vscode-dark.json diff --git a/pywal/colorschemes/vscode-dark.json b/pywal/colorschemes/vscode-dark.json new file mode 100644 index 0000000..a70b684 --- /dev/null +++ b/pywal/colorschemes/vscode-dark.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#1e1e1e", + "foreground": "#d4d4d4", + "cursor": "#f44747" + }, + "colors": { + "color0": "#1e1e1e", + "color1": "#f44747", + "color2": "#d7ba7d", + "color3": "#608b4e", + "color4": "#569cd6", + "color5": "#4ec9b0", + "color6": "#c586c0", + "color7": "#d4d4d4", + "color8": "#808080", + "color9": "#f44747", + "color10": "#d7ba7d", + "color11": "#608b4e", + "color12": "#569cd6", + "color13": "#4ec9b0", + "color14": "#c586c0", + "color15": "#d4d4d4" + } +} From ae1c31305f3e5642a6a53f116584c26b28dea86e Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 09:43:51 +1100 Subject: [PATCH 17/29] misc: cleanup --- pywal/colors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pywal/colors.py b/pywal/colors.py index 664dd4b..6ce3443 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -131,15 +131,15 @@ def get(img, cache_dir=CACHE_DIR, def terminal_sexy_to_wal(data): """Convert terminal.sexy json schema to wal.""" data["colors"] = {} - data["special"] = {} + data["special"] = { + "foreground": data["foreground"], + "background": data["background"], + "cursor": data["color"][9] + } for i, color in enumerate(data["color"]): data["colors"]["color%s" % i] = color - data["special"]["foreground"] = data["foreground"] - data["special"]["background"] = data["background"] - data["special"]["cursor"] = data["colors"]["color1"] - return data From d0aa7df3b5487f2453c1c118d3acf63fa069c7e6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 09:52:41 +1100 Subject: [PATCH 18/29] theme: Added ashes --- pywal/colorschemes/ashes-dark.json | 25 +++++++++++++++++++++++++ pywal/colorschemes/ashes-light.json | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 pywal/colorschemes/ashes-dark.json create mode 100644 pywal/colorschemes/ashes-light.json diff --git a/pywal/colorschemes/ashes-dark.json b/pywal/colorschemes/ashes-dark.json new file mode 100644 index 0000000..86105d4 --- /dev/null +++ b/pywal/colorschemes/ashes-dark.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#1c2023", + "foreground": "#c7ccd1", + "cursor": "#c7ae95" + }, + "colors": { + "color0": "#1c2023", + "color1": "#c7ae95", + "color2": "#95c7ae", + "color3": "#aec795", + "color4": "#ae95c7", + "color5": "#c795ae", + "color6": "#95aec7", + "color7": "#c7ccd1", + "color8": "#747c84", + "color9": "#c7ae95", + "color10": "#95c7ae", + "color11": "#aec795", + "color12": "#ae95c7", + "color13": "#c795ae", + "color14": "#95aec7", + "color15": "#f3f4f5" + } +} diff --git a/pywal/colorschemes/ashes-light.json b/pywal/colorschemes/ashes-light.json new file mode 100644 index 0000000..7af28e6 --- /dev/null +++ b/pywal/colorschemes/ashes-light.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#f3f4f5", + "foreground": "#565e65", + "cursor": "#c7ae95" + }, + "colors": { + "color0": "#f3f4f5", + "color1": "#c7ae95", + "color2": "#95c7ae", + "color3": "#aec795", + "color4": "#ae95c7", + "color5": "#c795ae", + "color6": "#95aec7", + "color7": "#1c2023", + "color8": "#747c84", + "color9": "#c7ae95", + "color10": "#95c7ae", + "color11": "#aec795", + "color12": "#ae95c7", + "color13": "#c795ae", + "color14": "#95aec7", + "color15": "#1c2023" + } +} From 20ae5f8d7a3367bf0483cc8aae018419fbdb1ef0 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Mar 2018 09:56:14 +1100 Subject: [PATCH 19/29] theme: Added darktooth --- pywal/colorschemes/darktooth.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pywal/colorschemes/darktooth.json diff --git a/pywal/colorschemes/darktooth.json b/pywal/colorschemes/darktooth.json new file mode 100644 index 0000000..7ea165e --- /dev/null +++ b/pywal/colorschemes/darktooth.json @@ -0,0 +1,25 @@ +{ + "special": { + "background": "#1d2021", + "foreground": "#a89984", + "cursor": "#fb543f" + }, + "colors": { + "color0": "#1d2021", + "color1": "#fb543f", + "color2": "#95c085", + "color3": "#fac03b", + "color4": "#0d6678", + "color5": "#8f4673", + "color6": "#8ba59b", + "color7": "#a89984", + "color8": "#665c54", + "color9": "#fb543f", + "color10": "#95c085", + "color11": "#fac03b", + "color12": "#0d6678", + "color13": "#8f4673", + "color14": "#8ba59b", + "color15": "#fdf4c1" + } +} From 1cff79bcc6f64c8b52c255c9dd161cd5564bf748 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 18 Mar 2018 10:03:48 +1100 Subject: [PATCH 20/29] theme: Move theme handling to own file. --- pywal/__init__.py | 2 ++ pywal/__main__.py | 14 +++++----- pywal/colors.py | 56 +++++---------------------------------- pywal/export.py | 1 - pywal/theme.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 58 deletions(-) create mode 100644 pywal/theme.py diff --git a/pywal/__init__.py b/pywal/__init__.py index 98d9a08..8a00b5a 100644 --- a/pywal/__init__.py +++ b/pywal/__init__.py @@ -15,6 +15,7 @@ from . import export from . import image from . import reload from . import sequences +from . import theme from . import wallpaper __all__ = [ @@ -25,5 +26,6 @@ __all__ = [ "image", "reload", "sequences", + "theme", "wallpaper", ] diff --git a/pywal/__main__.py b/pywal/__main__.py index 43f4465..8086e39 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -14,12 +14,13 @@ import os import shutil import sys -from .settings import __version__, CACHE_DIR, MODULE_DIR, CONF_DIR +from .settings import __version__, CACHE_DIR, CONF_DIR from . import colors from . import export from . import image from . import reload from . import sequences +from . import theme from . import util from . import wallpaper @@ -105,11 +106,7 @@ def process_args(args): sys.exit(0) if args.f == "list_themes": - themes = os.listdir(os.path.join(CONF_DIR, "colorschemes")) - themes += os.listdir(os.path.join(MODULE_DIR, "colorschemes")) - themes = [theme.replace(".json", "") for theme in themes] - - print("Themes:", ", ".join(themes)) + print("Themes:", ", ".join(theme.index())) sys.exit(0) if args.q: @@ -133,7 +130,7 @@ def process_args(args): colors_plain = colors.get(image_file, light=args.l) if args.f: - colors_plain = colors.file(args.f) + colors_plain = theme.file(args.f) if args.a: util.Color.alpha_num = args.a @@ -165,6 +162,9 @@ def process_args(args): def main(): """Main script function.""" + util.create_dir(os.path.join(CONF_DIR, "colorschemes")) + util.create_dir(os.path.join(CONF_DIR, "templates")) + args = get_args(sys.argv[1:]) process_args(args) diff --git a/pywal/colors.py b/pywal/colors.py index 6ce3443..90f7ba2 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -7,8 +7,9 @@ import shutil import subprocess import sys -from .settings import CACHE_DIR, COLOR_COUNT, MODULE_DIR, \ - CONF_DIR, __cache_version__ +from . import theme + +from .settings import CACHE_DIR, COLOR_COUNT, __cache_version__ from . import util @@ -112,7 +113,7 @@ def get(img, cache_dir=CACHE_DIR, % (cache_file, color_type, __cache_version__)) if os.path.isfile(cache_file): - colors = file(cache_file) + colors = theme.file(cache_file) util.Color.alpha_num = colors["alpha"] print("colors: Found cached colorscheme.") @@ -128,51 +129,6 @@ def get(img, cache_dir=CACHE_DIR, return colors -def terminal_sexy_to_wal(data): - """Convert terminal.sexy json schema to wal.""" - data["colors"] = {} - data["special"] = { - "foreground": data["foreground"], - "background": data["background"], - "cursor": data["color"][9] - } - - for i, color in enumerate(data["color"]): - data["colors"]["color%s" % i] = color - - return data - - def file(input_file): - """Import colorscheme from json file.""" - theme_file = ".".join((input_file, "json")) - user_theme_dir = os.path.join(CONF_DIR, "colorschemes") - user_theme_file = os.path.join(user_theme_dir, theme_file) - theme_file = os.path.join(MODULE_DIR, "colorschemes", theme_file) - - util.create_dir(user_theme_dir) - - if os.path.isfile(user_theme_file): - input_file = user_theme_file - - elif os.path.isfile(theme_file): - input_file = theme_file - - if os.path.isfile(input_file): - data = util.read_file_json(input_file) - - if "wallpaper" not in data: - data["wallpaper"] = "None" - - if "alpha" not in data: - data["alpha"] = "100" - - # Terminal.sexy format. - if "color" in data: - data = terminal_sexy_to_wal(data) - - return data - - else: - print("No colorscheme file found, exiting...") - sys.exit(1) + """Deprecated: symbolic link to --> theme.file""" + return theme.file(input_file) diff --git a/pywal/export.py b/pywal/export.py index 120150d..87185f6 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -53,7 +53,6 @@ def every(colors, output_dir=CACHE_DIR): colors = flatten_colors(colors) template_dir = os.path.join(MODULE_DIR, "templates") template_dir_user = os.path.join(CONF_DIR, "templates") - util.create_dir(template_dir_user) join = os.path.join # Minor optimization. diff --git a/pywal/theme.py b/pywal/theme.py new file mode 100644 index 0000000..8023d73 --- /dev/null +++ b/pywal/theme.py @@ -0,0 +1,67 @@ +""" +Theme file handling. +""" +import os +import sys + +from .settings import CONF_DIR, MODULE_DIR +from . import util + + +def index(): + """List all installed theme files.""" + themes = os.listdir(os.path.join(CONF_DIR, "colorschemes")) + themes += os.listdir(os.path.join(MODULE_DIR, "colorschemes")) + return [theme.replace(".json", "") for theme in themes] + + +def terminal_sexy_to_wal(data): + """Convert terminal.sexy json schema to wal.""" + data["colors"] = {} + data["special"] = { + "foreground": data["foreground"], + "background": data["background"], + "cursor": data["color"][9] + } + + for i, color in enumerate(data["color"]): + data["colors"]["color%s" % i] = color + + return data + + +def file(input_file): + """Import colorscheme from json file.""" + theme_name = ".".join((input_file, "json")) + user_theme_file = os.path.join(CONF_DIR, "colorschemes", theme_name) + theme_file = os.path.join(MODULE_DIR, "colorschemes", theme_name) + + # Find the theme file. + if os.path.isfile(input_file): + theme_file = input_file + + elif os.path.isfile(user_theme_file): + theme_file = user_theme_file + + elif os.path.isfile(theme_file): + theme_file = theme_file + + # Parse the theme file. + if os.path.isfile(theme_file): + data = util.read_file_json(theme_file) + + if "wallpaper" not in data: + data["wallpaper"] = "None" + + if "alpha" not in data: + data["alpha"] = "100" + + # Terminal.sexy format. + if "color" in data: + data = terminal_sexy_to_wal(data) + + return data + + else: + print("No colorscheme file found, exiting...") + sys.exit(1) From 7c3e1ad4e86a2f2747a63b81127f377a2a38e87c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 18 Mar 2018 15:23:30 +1100 Subject: [PATCH 21/29] theme: Added random option. -f random --- pywal/__main__.py | 4 +++- pywal/theme.py | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index 8086e39..d7ba602 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -106,7 +106,9 @@ def process_args(args): sys.exit(0) if args.f == "list_themes": - print("Themes:", ", ".join(theme.index())) + themes = theme.index() + themes = [theme.name.replace(".json", "") for theme in themes] + print("Themes:", ", ".join(themes)) sys.exit(0) if args.q: diff --git a/pywal/theme.py b/pywal/theme.py index 8023d73..66beac6 100644 --- a/pywal/theme.py +++ b/pywal/theme.py @@ -2,6 +2,7 @@ Theme file handling. """ import os +import random import sys from .settings import CONF_DIR, MODULE_DIR @@ -10,9 +11,11 @@ from . import util def index(): """List all installed theme files.""" - themes = os.listdir(os.path.join(CONF_DIR, "colorschemes")) - themes += os.listdir(os.path.join(MODULE_DIR, "colorschemes")) - return [theme.replace(".json", "") for theme in themes] + themes = [theme for theme in + os.scandir(os.path.join(CONF_DIR, "colorschemes"))] + themes += [theme for theme in + os.scandir(os.path.join(MODULE_DIR, "colorschemes"))] + return themes def terminal_sexy_to_wal(data): @@ -46,6 +49,11 @@ def file(input_file): elif os.path.isfile(theme_file): theme_file = theme_file + elif input_file == "random": + themes = [theme.path for theme in index()] + random.shuffle(themes) + theme_file = themes[0] + # Parse the theme file. if os.path.isfile(theme_file): data = util.read_file_json(theme_file) From d364829fa5231788b98ad0e2aae86f3ac6dbd6bf Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 18 Mar 2018 15:27:02 +1100 Subject: [PATCH 22/29] misc: cleanup --- pywal/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index d7ba602..97eb999 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -106,9 +106,9 @@ def process_args(args): sys.exit(0) if args.f == "list_themes": - themes = theme.index() - themes = [theme.name.replace(".json", "") for theme in themes] + themes = [theme.name.replace(".json", "") for theme in theme.index()] print("Themes:", ", ".join(themes)) + print("Extra: 'random (select a random theme)'") sys.exit(0) if args.q: From 3d3f9ce2c5d7992f4ed123201f16065939b786d6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 18 Mar 2018 15:37:51 +1100 Subject: [PATCH 23/29] misc: cleanup --- pywal/theme.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pywal/theme.py b/pywal/theme.py index 66beac6..010e90f 100644 --- a/pywal/theme.py +++ b/pywal/theme.py @@ -11,11 +11,8 @@ from . import util def index(): """List all installed theme files.""" - themes = [theme for theme in - os.scandir(os.path.join(CONF_DIR, "colorschemes"))] - themes += [theme for theme in - os.scandir(os.path.join(MODULE_DIR, "colorschemes"))] - return themes + return [*os.scandir(os.path.join(CONF_DIR, "colorschemes")), + *os.scandir(os.path.join(MODULE_DIR, "colorschemes"))] def terminal_sexy_to_wal(data): From a58a9037c8e9e74742c589d41816fa414f3b7290 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 18 Mar 2018 15:46:45 +1100 Subject: [PATCH 24/29] misc: cleanup --- pywal/theme.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pywal/theme.py b/pywal/theme.py index 010e90f..efa3129 100644 --- a/pywal/theme.py +++ b/pywal/theme.py @@ -43,9 +43,6 @@ def file(input_file): elif os.path.isfile(user_theme_file): theme_file = user_theme_file - elif os.path.isfile(theme_file): - theme_file = theme_file - elif input_file == "random": themes = [theme.path for theme in index()] random.shuffle(themes) From 3093cce32718306025e887d7c9f93d5ad75739f5 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 18 Mar 2018 15:50:38 +1100 Subject: [PATCH 25/29] misc: cleanup --- pywal/__main__.py | 3 --- pywal/export.py | 2 ++ pywal/theme.py | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index 97eb999..00a2004 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -164,9 +164,6 @@ def process_args(args): def main(): """Main script function.""" - util.create_dir(os.path.join(CONF_DIR, "colorschemes")) - util.create_dir(os.path.join(CONF_DIR, "templates")) - args = get_args(sys.argv[1:]) process_args(args) diff --git a/pywal/export.py b/pywal/export.py index 87185f6..ca5f7a7 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -54,6 +54,8 @@ def every(colors, output_dir=CACHE_DIR): template_dir = os.path.join(MODULE_DIR, "templates") template_dir_user = os.path.join(CONF_DIR, "templates") + util.create_dir(template_dir_user) + join = os.path.join # Minor optimization. for file in os.scandir(template_dir): diff --git a/pywal/theme.py b/pywal/theme.py index efa3129..6d0acdc 100644 --- a/pywal/theme.py +++ b/pywal/theme.py @@ -36,6 +36,8 @@ def file(input_file): user_theme_file = os.path.join(CONF_DIR, "colorschemes", theme_name) theme_file = os.path.join(MODULE_DIR, "colorschemes", theme_name) + util.create_dir(os.path.dirname(user_theme_file)) + # Find the theme file. if os.path.isfile(input_file): theme_file = input_file From e1df4a685d14ab34d599730ac4c246c7ab239f98 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 18 Mar 2018 16:06:57 +1100 Subject: [PATCH 26/29] misc: cleanup --- pywal/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index 00a2004..2447b6b 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -14,7 +14,7 @@ import os import shutil import sys -from .settings import __version__, CACHE_DIR, CONF_DIR +from .settings import __version__, CACHE_DIR from . import colors from . import export from . import image From 40454ff0c642b13b9cfcd114dfeb1c71829227db Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 18 Mar 2018 16:18:36 +1100 Subject: [PATCH 27/29] misc: cleanup --- pywal/export.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pywal/export.py b/pywal/export.py index ca5f7a7..120150d 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -53,7 +53,6 @@ def every(colors, output_dir=CACHE_DIR): colors = flatten_colors(colors) template_dir = os.path.join(MODULE_DIR, "templates") template_dir_user = os.path.join(CONF_DIR, "templates") - util.create_dir(template_dir_user) join = os.path.join # Minor optimization. From 2bd4c7b75b9d4629c27bb16bd042f6019cb09197 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 1 Apr 2018 09:50:53 +1000 Subject: [PATCH 28/29] theme: Update flag --- pywal/__main__.py | 29 +++++++++++++++-------------- pywal/theme.py | 4 ++-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pywal/__main__.py b/pywal/__main__.py index 2857ae3..09d0769 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -41,17 +41,17 @@ def get_args(args): help="Which color backend to use.", const="list_backends", type=str, nargs="?", default="wal") + arg.add_argument("--theme", metavar="/path/to/file or theme_name", + help="Which colorscheme file to use. \ + Use 'wal -f' to list available builtin themes.", + const="list_themes", nargs="?") + arg.add_argument("-c", action="store_true", help="Delete all cached colorschemes.") arg.add_argument("-i", metavar="\"/path/to/img.jpg\"", help="Which image or directory to use.") - arg.add_argument("-f", metavar="/path/to/colorscheme/file or theme_name", - help="Which colorscheme file to use. \ - Use 'wal -f' to list available builtin themes.", - const="list_themes", nargs="?") - arg.add_argument("-g", action="store_true", help="Generate an oomox theme.") @@ -96,7 +96,7 @@ def process_args(args): " Refer to \"wal -h\" for more info.") sys.exit(1) - if args.i and args.f: + if args.i and args.theme: print("error: Conflicting arguments -i and -f.\n" " Refer to \"wal -h\" for more info.") sys.exit(1) @@ -109,14 +109,15 @@ def process_args(args): reload.colors() sys.exit(0) - if args.f == "list_themes": - themes = [theme.name.replace(".json", "") for theme in theme.index()] - print("Themes:", ", ".join(themes)) - print("Extra: 'random (select a random theme)'") + if args.theme == "list_themes": + themes = [theme.name.replace(".json", "") + for theme in theme.list_themes()] + print("Themes:", themes) + print("Extra: 'random' (select a random theme)") sys.exit(0) if args.backend == "list_backends": - print("Available backends:", colors.list_backends()) + print("Backends:", colors.list_backends()) sys.exit(0) if args.q: @@ -139,8 +140,8 @@ def process_args(args): image_file = image.get(args.i) colors_plain = colors.get(image_file, args.l, args.backend) - if args.f: - colors_plain = theme.file(args.f) + if args.theme: + colors_plain = theme.file(args.theme) if args.a: util.Color.alpha_num = args.a @@ -150,7 +151,7 @@ def process_args(args): colors_plain["special"]["background"] = args.b colors_plain["colors"]["color0"] = args.b - if args.i or args.f: + if args.i or args.theme: if not args.n: wallpaper.change(colors_plain["wallpaper"]) diff --git a/pywal/theme.py b/pywal/theme.py index 6d0acdc..a049ad2 100644 --- a/pywal/theme.py +++ b/pywal/theme.py @@ -9,7 +9,7 @@ from .settings import CONF_DIR, MODULE_DIR from . import util -def index(): +def list_themes(): """List all installed theme files.""" return [*os.scandir(os.path.join(CONF_DIR, "colorschemes")), *os.scandir(os.path.join(MODULE_DIR, "colorschemes"))] @@ -46,7 +46,7 @@ def file(input_file): theme_file = user_theme_file elif input_file == "random": - themes = [theme.path for theme in index()] + themes = [theme.path for theme in list_themes()] random.shuffle(themes) theme_file = themes[0] From ae13cae6f838212461ad12ae2b73e447b66cc05b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 1 Apr 2018 09:55:11 +1000 Subject: [PATCH 29/29] theme: cleanup --- pywal/theme.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/pywal/theme.py b/pywal/theme.py index a049ad2..6439d40 100644 --- a/pywal/theme.py +++ b/pywal/theme.py @@ -30,6 +30,23 @@ def terminal_sexy_to_wal(data): return data +def parse_theme(theme_file): + """Parse the theme file.""" + data = util.read_file_json(theme_file) + + if "wallpaper" not in data: + data["wallpaper"] = "None" + + if "alpha" not in data: + data["alpha"] = "100" + + # Terminal.sexy format. + if "color" in data: + data = terminal_sexy_to_wal(data) + + return data + + def file(input_file): """Import colorscheme from json file.""" theme_name = ".".join((input_file, "json")) @@ -52,19 +69,7 @@ def file(input_file): # Parse the theme file. if os.path.isfile(theme_file): - data = util.read_file_json(theme_file) - - if "wallpaper" not in data: - data["wallpaper"] = "None" - - if "alpha" not in data: - data["alpha"] = "100" - - # Terminal.sexy format. - if "color" in data: - data = terminal_sexy_to_wal(data) - - return data + return parse_theme(theme_file) else: print("No colorscheme file found, exiting...")