From f13f7a05d5edbe0b064cb52720c22b81cd44c9dd Mon Sep 17 00:00:00 2001 From: vxid Date: Mon, 2 Jul 2018 20:13:09 +0200 Subject: Add kitty support --- pywal/export.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 993e528..357656e 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -37,6 +37,7 @@ def get_export_type(export_type): "gtk2": "colors-gtk2.rc", "json": "colors.json", "konsole": "colors-konsole.colorscheme", + "kitty": "colors-kitty.conf", "plain": "colors", "putty": "colors-putty.reg", "rofi": "colors-rofi.Xresources", -- cgit v1.2.3 From 04a10fdcc60f11224680bad831a8822d755df738 Mon Sep 17 00:00:00 2001 From: surrealpie Date: Thu, 8 Nov 2018 05:17:52 -0500 Subject: template for waybar --- pywal/export.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 357656e..6a28249 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -47,6 +47,7 @@ def get_export_type(export_type): "tty": "colors-tty.sh", "xresources": "colors.Xresources", "yaml": "colors.yml", + "waybar": "colors-waybar.css", }.get(export_type, export_type) -- cgit v1.2.3 From 24735845f6251d3e78024fe6d554a8b265ddf0e8 Mon Sep 17 00:00:00 2001 From: lasers Date: Mon, 26 Nov 2018 01:03:42 -0600 Subject: export: add speedcrunch template --- pywal/export.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 357656e..e737d1b 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -43,6 +43,7 @@ def get_export_type(export_type): "rofi": "colors-rofi.Xresources", "scss": "colors.scss", "shell": "colors.sh", + "speedcrunch": "colors-speedcrunch.json", "sway": "colors-sway", "tty": "colors-tty.sh", "xresources": "colors.Xresources", -- cgit v1.2.3 From 37e96eca3b6aeccb0052e30cf6ec80eac0510df1 Mon Sep 17 00:00:00 2001 From: sraysmith Date: Thu, 20 Dec 2018 15:55:11 -0500 Subject: I added the xmonad export_type. --- pywal/export.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 357656e..7873557 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -47,6 +47,7 @@ def get_export_type(export_type): "tty": "colors-tty.sh", "xresources": "colors.Xresources", "yaml": "colors.yml", + "xmonad": "colors.hs", }.get(export_type, export_type) -- cgit v1.2.3 From 041fe0643f9a31079cdf641a7f8227e97dba9696 Mon Sep 17 00:00:00 2001 From: Younes Khoudli Date: Sun, 30 Dec 2018 03:40:11 +0100 Subject: template: add dmenu template --- pywal/export.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 357656e..833912d 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -31,6 +31,7 @@ def get_export_type(export_type): """Convert template type to the right filename.""" return { "css": "colors.css", + "dmenu": "colors-wal-dmenu.h", "dwm": "colors-wal-dwm.h", "st": "colors-wal-st.h", "tabbed": "colors-wal-tabbed.h", -- cgit v1.2.3 From 1d4127925dfe9c43281b99a43a9ef4dcf7351dc8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 10 Feb 2019 08:07:06 +0200 Subject: export: Print error message if template can't be parsed. --- pywal/export.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 83dd15c..fb284bd 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -12,7 +12,13 @@ def template(colors, input_file, output_file=None): """Read template file, substitute markers and save the file elsewhere.""" template_data = util.read_file_raw(input_file) - template_data = "".join(template_data).format(**colors) + + try: + template_data = "".join(template_data).format(**colors) + except ValueError: + logging.error("Syntax error in template file '%s'. " + "Are non-marker braces escaped? '{{}}'?" % input_file) + return util.save_file(template_data, output_file) -- cgit v1.2.3 From 0f7c6aeaf9eda9a5062b78950a60ca72771388a7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 3 Mar 2019 11:41:10 +0200 Subject: export: Skip swp files --- pywal/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index fb284bd..4139cb7 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -70,7 +70,7 @@ def every(colors, output_dir=CACHE_DIR): join = os.path.join # Minor optimization. for file in [*os.scandir(template_dir), *os.scandir(template_dir_user)]: - if file.name != ".DS_Store": + if file.name != ".DS_Store" and not file.name.endswith(".swp"): template(colors, file.path, join(output_dir, file.name)) logging.info("Exported all files.") -- cgit v1.2.3 From 95c1cc18bcb68fc3b4dfa73bfe75d1bd207ca956 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 5 Mar 2019 11:27:54 +0200 Subject: docs: update --- pywal/export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 4139cb7..0a2b8f3 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -16,8 +16,8 @@ def template(colors, input_file, output_file=None): try: template_data = "".join(template_data).format(**colors) except ValueError: - logging.error("Syntax error in template file '%s'. " - "Are non-marker braces escaped? '{{}}'?" % input_file) + logging.error("Syntax error in template file '%s'. ", input_file, + "Are non-marker braces escaped? '{{}}'?") return util.save_file(template_data, output_file) -- cgit v1.2.3 From 3292a5513d79f3ead1a8f27178b0fab76078f0fd Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 5 Mar 2019 11:32:49 +0200 Subject: docs: update --- pywal/export.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 0a2b8f3..88c98a6 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -16,8 +16,7 @@ def template(colors, input_file, output_file=None): try: template_data = "".join(template_data).format(**colors) except ValueError: - logging.error("Syntax error in template file '%s'. ", input_file, - "Are non-marker braces escaped? '{{}}'?") + logging.error("Syntax error in template file '%s'.", input_file) return util.save_file(template_data, output_file) -- cgit v1.2.3 From b9fd064d3069024b7d9084d3303e28fede3ad4b0 Mon Sep 17 00:00:00 2001 From: Amit Prasad <17amitprasad@gmail.com> Date: Mon, 16 Dec 2019 11:45:22 -0500 Subject: Started working on matching functions --- pywal/export.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 88c98a6..b175c11 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -3,6 +3,7 @@ Export colors in various formats. """ import logging import os +import re from .settings import CACHE_DIR, MODULE_DIR, CONF_DIR from . import util @@ -12,7 +13,32 @@ def template(colors, input_file, output_file=None): """Read template file, substitute markers and save the file elsewhere.""" template_data = util.read_file_raw(input_file) - + matches = re.finditer(r"(?<=(? Date: Tue, 17 Dec 2019 20:29:04 -0500 Subject: Added ability to modify colors using methods ( .lighten(%), .darken(%), .saturate(%) for now) --- pywal/export.py | 59 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index b175c11..ae619cd 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -13,38 +13,43 @@ def template(colors, input_file, output_file=None): """Read template file, substitute markers and save the file elsewhere.""" template_data = util.read_file_raw(input_file) - matches = re.finditer(r"(?<=(? 1: + args = func_split[1].split(",") + else: + args = [] + name = func_split[0] + if name[0] == '.': + name = name[1:] + x = getattr(colors[color], name) + if callable(x): + new_color = x(*args) + if func[0] != '.': + to_replace += "." + to_replace += func + ")" + else: + pass + if not new_color is None: + cname = "color" + new_color.strip + template_data[i] = line.replace(to_replace, cname) + colors[cname] = new_color try: template_data = "".join(template_data).format(**colors) except ValueError: logging.error("Syntax error in template file '%s'.", input_file) return - util.save_file(template_data, output_file) -- cgit v1.2.3 From f0692c31eb91f0c6e5f2f5c8fdf4737808784362 Mon Sep 17 00:00:00 2001 From: Amit Prasad <17amitprasad@gmail.com> Date: Wed, 18 Dec 2019 13:28:13 -0500 Subject: Commented and minimize. --- pywal/export.py | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index ae619cd..f7b9de8 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -17,33 +17,34 @@ def template(colors, input_file, output_file=None): line = template_data[i] matches = re.finditer(r"(?<=(? 1: - args = func_split[1].split(",") - else: - args = [] - name = func_split[0] - if name[0] == '.': - name = name[1:] - x = getattr(colors[color], name) - if callable(x): - new_color = x(*args) - if func[0] != '.': - to_replace += "." - to_replace += func + ")" - else: - pass - if not new_color is None: + args = [] + if len(func_split) > 1: args = func_split[1].split(",") + fname = func_split[0] + if fname[0] == '.': fname = fname[1:] + f = getattr(new_color, fname) + + # If the function is callable, call it + if callable(f): + new_color = f(*args) + #add to the string that will replace the function calls with the generated function. + if func[0] != '.': replace_str += "." + replace_str += func + ")" + #If the color was changed, replace the template with a unique identifier for the new color. + if not new_color is colors[color]: cname = "color" + new_color.strip - template_data[i] = line.replace(to_replace, cname) + template_data[i] = line.replace(replace_str, cname) colors[cname] = new_color try: template_data = "".join(template_data).format(**colors) -- cgit v1.2.3 From c29151de464ee9267872c48115fc79bc7a0075b6 Mon Sep 17 00:00:00 2001 From: Amit Prasad <17amitprasad@gmail.com> Date: Fri, 20 Dec 2019 09:44:19 -0500 Subject: Beautify --- pywal/export.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index f7b9de8..4c0649f 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -19,29 +19,35 @@ def template(colors, input_file, output_file=None): for match in matches: # Get the color, and the functions associated with it color, _, funcs = match.group(2).partition(".") - #Check that functions are needed for this color + # Check that functions are needed for this color if len(funcs) != 0: - #Build up a string which will be replaced when the color is done processing + # Build up a string which will be replaced when the color is done processing replace_str = color - #The modified color + # The modified color new_color = colors[color] - #Execute each function to be done - for func in filter(None,funcs.split(")")): - ### Get function name and arguments + # Execute each function to be done + for func in filter(None, funcs.split(")")): + # Get function name and arguments func_split = func.split("(") args = [] - if len(func_split) > 1: args = func_split[1].split(",") + if len(func_split) > 1: + args = func_split[1].split(",") fname = func_split[0] - if fname[0] == '.': fname = fname[1:] + if fname[0] == '.': + fname = fname[1:] + if not hasattr(new_color, fname): + logging.error( + "Syntax error in template file '%s' on line '%s'", input_file, i) f = getattr(new_color, fname) # If the function is callable, call it if callable(f): new_color = f(*args) - #add to the string that will replace the function calls with the generated function. - if func[0] != '.': replace_str += "." + # add to the string that will replace the function calls with the generated function. + if func[0] != '.': + replace_str += "." replace_str += func + ")" - #If the color was changed, replace the template with a unique identifier for the new color. + # If the color was changed, replace the template with a unique identifier for the new color. if not new_color is colors[color]: cname = "color" + new_color.strip template_data[i] = line.replace(replace_str, cname) -- cgit v1.2.3 From d4bd389b438df7bc4d3f302d44e23c9bbdaba8ec Mon Sep 17 00:00:00 2001 From: Amit Prasad <17amitprasad@gmail.com> Date: Fri, 20 Dec 2019 11:34:57 -0500 Subject: Cleaned up code for pylint --- pywal/export.py | 76 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'pywal/export.py') diff --git a/pywal/export.py b/pywal/export.py index 4c0649f..d9ff16d 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -5,53 +5,53 @@ import logging import os import re -from .settings import CACHE_DIR, MODULE_DIR, CONF_DIR from . import util +from .settings import CACHE_DIR, CONF_DIR, MODULE_DIR def template(colors, input_file, output_file=None): """Read template file, substitute markers and save the file elsewhere.""" template_data = util.read_file_raw(input_file) - for i in range(len(template_data)): - line = template_data[i] - matches = re.finditer(r"(?<=(? 1: - args = func_split[1].split(",") - fname = func_split[0] - if fname[0] == '.': - fname = fname[1:] - if not hasattr(new_color, fname): - logging.error( - "Syntax error in template file '%s' on line '%s'", input_file, i) - f = getattr(new_color, fname) - - # If the function is callable, call it - if callable(f): - new_color = f(*args) - # add to the string that will replace the function calls with the generated function. - if func[0] != '.': - replace_str += "." - replace_str += func + ")" - # If the color was changed, replace the template with a unique identifier for the new color. - if not new_color is colors[color]: - cname = "color" + new_color.strip - template_data[i] = line.replace(replace_str, cname) - colors[cname] = new_color + if len(funcs) == 0: + continue + # Build up a string which will be replaced with the new color + replace_str = cname + # Color to be modified copied into new one + new_color = util.Color(colors[cname].hex_color) + # Execute each function to be done + for func in filter(None, funcs.split(")")): + # Get function name and arguments + func = func.split("(") + fname = func[0] + if fname[0] == '.': + fname = fname[1:] + if not hasattr(new_color, fname): + logging.error( + "Syntax error in template file '%s' on line '%s'", + input_file, i) + function = getattr(new_color, fname) + + # If the function is callable, call it + if callable(function): + if len(func) > 1: + new_color = function(*func[1].split(",")) + else: + new_color = function() + # string to replace generated colors + if func[0] != '.': + replace_str += "." + replace_str += "(".join(func) + ")" + # If the color was changed, replace with a unique identifier. + if new_color is not colors[cname]: + template_data[i] = l.replace( + replace_str, "color" + new_color.strip) + colors["color" + new_color.strip] = new_color try: template_data = "".join(template_data).format(**colors) except ValueError: -- cgit v1.2.3