Skip to content

foxify colors#158

Merged
eylles merged 3 commits intomasterfrom
foxify
Feb 17, 2026
Merged

foxify colors#158
eylles merged 3 commits intomasterfrom
foxify

Conversation

@eylles
Copy link
Owner

@eylles eylles commented May 15, 2025

This adds the ability to change colors with the pywalfox algorithm.

blocking:

unfortunately this is a time when once again i'm hitting face first into the wall that is #13

which means that it would only be possible to add colors modified like this as part of the special colors in the main color dict, not allow users to call the foxify property from a template as the way template export function is defined at:

pywal16/pywal/export.py

Lines 24 to 83 in ec2ad5a

def template(colors, input_file, output_file=None):
"""Read template file, substitute markers and
save the file elsewhere."""
# pylint: disable-msg=too-many-locals
template_data = util.read_file_raw(input_file)
for i, l in enumerate(template_data):
for match in re.finditer(r"(?<=(?<!\{))(\{([^{}]+)\})(?=(?!\}))", l):
# Get the color, and the functions associated with it
cname, _, funcs = match.group(2).partition(".")
# Check that functions are needed for this 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, re.split(r"\)|\.", funcs)):
# 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) + ")"
else:
# if it is an attribute i.e. rgb
replace_str += "." + fname
new_color = function
if isinstance(new_color, util.Color):
new_color = new_color.strip
# If replace the format placeholder with the new color
if new_color is not colors[cname]:
new_color = str(new_color)
template_data[i] = l.replace("{" + replace_str + "}", new_color)
try:
template_data = "".join(template_data).format(**colors)
except (ValueError, KeyError, AttributeError) as exc:
logging.error(
"Syntax error in template file '%s': %r.", input_file, exc
)
return
util.save_file(template_data, output_file)

as a finditer and such careless reggular expression usage should have never been part of the function... but we are already past beyond that point...

anyway will have to leave this open until that problem is eventually fixed.

@eylles eylles mentioned this pull request May 15, 2025
AnthonyMichaelTDM added a commit to AnthonyMichaelTDM/pywal16 that referenced this pull request Oct 1, 2025
AnthonyMichaelTDM added a commit to AnthonyMichaelTDM/pywal16 that referenced this pull request Oct 1, 2025
eylles pushed a commit that referenced this pull request Oct 13, 2025
@AnthonyMichaelTDM
Copy link
Contributor

Since #187 was merged a few months ago, this should be unblocked.

Unless I'm missing something you should be able to just rebase this ontop of the current master and be good to go

@eylles
Copy link
Owner Author

eylles commented Feb 17, 2026

yeh, there are other changes i want to do to this PR, will try to commit them today and merge

The dumb github web editor screwed this up
@eylles
Copy link
Owner Author

eylles commented Feb 17, 2026

nevermind, changed ideas the further changes i wanted to make here will go to a different branch

@eylles eylles merged commit e5b4c09 into master Feb 17, 2026
2 checks passed
@eylles eylles mentioned this pull request Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments