Comments (3)
This is dead simple and doesn't require anything external: https://stackoverflow.com/a/6385940
(That method also works well with #16 since the colors are now stored in dicts.)
from pywal.
Actually, a better method is probably something like this:
def template(colors, input_file, export_file):
"""Read template file, substitute markers and
save the file elsewhere."""
# Import the template.
with open(input_file) as file:
template_data = file.readlines()
# Format the markers.
template_data = "".join(template_data).format(*colors)
# Export the template.
with open(export_file, "w") as file:
file.write(template_data)
Since the function is rather generic we can loop it over the template directory removing the need for the export_colors.py
and format_colors.py
files. Adding a new export file will be as easy as adding a new file to the templates directory, wal
will see it on next run and update the cache dir.
The markers are rather verbose now {index}
but the change to json
and dicts
will most likely fix this. https://stackoverflow.com/questions/5952344/how-do-i-format-a-string-using-a-dictionary-in-python-3-x
Example template file:
/* '{}' need to be escaped if they're not markers.
You can escape them by doubling them '{{', '}}' */
:root {{
--color0: {0};
--color1: {1};
--color2: {2};
--color3: {3};
--color4: {4};
--color5: {5};
--color6: {6};
--color7: {7};
--color8: {8};
--color9: {9};
--color10: {10};
--color11: {11};
--color12: {12};
--color13: {13};
--color14: {14};
--color15: {15};
}}
from pywal.
See #18
from pywal.
Related Issues (20)
- AttributeError: 'Color' object has no attribute 'alpha_dec'. Did you mean: 'alpha_num'? HOT 1
- Can't use oomox with pywal
- Pywal not applying color to new terminals
- Pywal conflicts with polybar and picom?: HOT 2
- Using custom theme file not working in NixOS
- Wallpaper setting stop working in MacOS Sonoma HOT 5
- superpaper
- [Feature] Gives the luminence of the theme as an argument to the -o script HOT 2
- Changing GTK3 colour scheme in Wayland with pywal? HOT 2
- Kitty displays a strange error when running pywal
- Pywal toml colors file for Alacritty
- running `wal` command turns laptop screen on while lid is closed
- Pywal on Mac OS not setting scheme and wall paper correctly HOT 1
- Installation instruction for Gentoo? HOT 3
- deprecated for dwm HOT 1
- wal -R -l doesn't work
- Tutorial for xrdb patch DWM HOT 1
- How do i remove things from user template files? HOT 3
- ImageMagick-7 Policy change causes error (w/ solution)
- pywal wont generate color schemes for all templates.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pywal.