cwal
One theme file, many applications. cwal renders a theme into the
configuration format of a program through a template, and apply-theme
installs the result for every supported program found on the system.
cwalis a small C99 program: theme + template in, one configuration fragment on standard output. It never searches for files and never modifies anything.apply-themeis a shell orchestrator that runs one component script per application: detect it, render, validate, install atomically, reload.wallpaper-palettederives a color palette from a wallpaper image.
Supported: Rofi, Mango, Labwc, Foot, Waybar, River, Hyprland, Hyprlock, GTK 3, GTK 4, btop, Qt/KDE, Yazi, nnn, Sway, Vim, vis, dwm and st.
Quick start
make # build cwal
mkdir -p ~/.config/foot # components are only applied if the program is
# installed and its config directory exists
./apply-theme # apply themes/default.conf
./apply-theme themes/nord.conf
Only programs that are installed and have a configuration directory are touched; everything else is skipped. Errors and diagnostics go to standard error.
Build
make
Requires a C99 compiler. wallpaper-palette additionally requires
ImageMagick 7 (magick).
Themes
A theme is a key=value file (# and ; start comments). See
themes/default.conf for a complete example; themes/ holds a few ready-made
ones (Catppuccin, Dracula, Everforest, Gruvbox, Kanagawa, Monokai Pro, Nord,
One Dark, Rosé Pine, Solarized, Tokyo Night, and a cyberpunk one).
| Key | Meaning |
|---|---|
name |
Display name |
terminal_font, terminal_font_fallback, terminal_font_size |
Terminal typography (size 6-72) |
terminal_opacity |
Terminal opacity, 0.0-1.0 |
ui_font, ui_font_size |
Graphical-interface typography (size 6-72) |
opacity |
Graphical-interface opacity, 0.0-1.0 |
icon_theme |
Optional GTK/Qt icon theme; if not installed, the system default is kept |
waybar_font, waybar_background, waybar_text, waybar_radius |
Waybar's own typography, colors and radius |
border_width |
Window border width (0-20) |
border_radius |
Window corner radius (0-100) |
gap_inner, gap_outer |
Tiling gaps (0-100), used by Mango |
crust, base, surface0, surface1, surface2 |
Backgrounds, darkest to lightest |
overlay0, subtext0, subtext1, text |
Foregrounds, dimmest to brightest |
accent |
Highlight color |
red, green, yellow, blue, pink, teal, peach |
Palette colors |
Colors accept RRGGBB or #RRGGBB. Every key except icon_theme is
required. Font names cannot contain ", \ or ,.
Using cwal directly
cwal <theme-file> <template-file>
cwal --base <base-theme-file> <color-overrides-file> <template-file>
--base keeps the typography and layout of a complete theme and replaces only
its colors. The overrides file accepts only color keys and takes precedence;
use - to read it from standard input.
./cwal themes/nord.conf templates/foot.ini > foot-theme.ini
./wallpaper-palette wall.png | ./cwal --base themes/default.conf - templates/waybar.css
Template variables
Templates live in templates/ and use ${variable} placeholders. Write $$
for a literal $. An unknown variable is an error.
| Variable | Value |
|---|---|
name, terminal_font, terminal_font_fallback, ui_font, icon_theme, waybar_font |
Text from the theme |
terminal_font_size, ui_font_size, border_width, border_radius, waybar_radius, gap_inner, gap_outer |
Integers from the theme |
inner_radius |
border_radius - border_width (or border_radius if it is not larger) |
opacity, terminal_opacity |
Decimal, three digits |
alpha_hex |
opacity as two hex digits |
waybar_background, waybar_text |
RRGGBB |
<color> |
RRGGBB, lowercase, no # |
<color>_rgb |
R,G,B in decimal |
<color>_256 |
Closest xterm-256 color index, two hex digits |
<color> is any of the palette colors: crust, base, surface0,
surface1, surface2, overlay0, subtext0, subtext1, text, accent,
red, green, yellow, blue, pink, teal, peach.
Wallpaper palette
wallpaper-palette turns one image into the color-only override format of
cwal --base. It writes to standard output and modifies nothing; it receives
the image path explicitly and never looks for the active wallpaper.
./wallpaper-palette wall.png > wallpaper-colors.conf
./apply-theme --base themes/default.conf wallpaper-colors.conf
./wallpaper-palette wall.png | ./apply-theme --base themes/default.conf -
apply-theme
./apply-theme # themes/default.conf
./apply-theme path/to/theme.conf
./apply-theme --base theme.conf colors.conf # colors.conf may be -
Each application has one script under components/ implementing the phases
detect prepare generate validate install reload summary. The phases run
across all detected components in order, so every file is generated and
validated before any destination is replaced. Each destination is replaced
atomically.
What it writes
| Program | File | Takes effect |
|---|---|---|
| Rofi | ~/.config/rofi/generated-theme.rasi |
Next launch |
| Mango | ~/.config/mango/generated-theme.conf |
Reloaded |
| Labwc | ~/.config/labwc/themerc-override |
Reloaded |
| Foot | ~/.config/foot/generated-theme.ini |
New instances |
| Waybar | ~/.config/waybar/generated-theme.css |
Reloaded |
| River | ~/.config/river/generated-theme.sh |
Next start |
| Hyprland | ~/.config/hypr/generated-theme.lua |
Reloaded |
| Hyprlock | ~/.config/hypr/generated-hyprlock.conf |
Next lock |
| GTK 3 | ~/.config/gtk-3.0/generated-cwal.css |
New windows |
| GTK 4 | ~/.config/gtk-4.0/generated-cwal.css |
New windows |
| btop | ~/.config/btop/themes/cwal.theme |
Next launch |
| Qt/KDE | ~/.local/share/color-schemes/Cwal.colors ($XDG_DATA_HOME if set), ~/.config/environment.d/cwal-qt.conf |
New Qt apps |
| Yazi | ~/.config/yazi/theme.toml |
Next launch |
| nnn | ~/.config/nnn/cwal-colors.sh |
Source it before nnn |
| Sway | ~/.config/sway/generated-theme.conf |
Reloaded |
| Vim | ~/.vim/colors/cwal.vim |
Next launch |
| vis | ~/.config/vis/themes/cwal.lua |
Next launch |
| dwm | ~/.config/dwm/config.h |
Rebuild dwm |
| st | ~/.config/st/config.h |
Rebuild st |
Programs are reloaded when they are running and support it (Mango, Labwc, Waybar, Hyprland and Sway). Foot cannot safely reload its whole configuration, so open terminals keep their theme. Hyprlock is never reloaded while locked.
What your own configuration must include
apply-theme never replaces a file you own; it writes a generated file that
your configuration loads.
- Waybar:
style.cssimportsgenerated-theme.css. The generated CSS styles module IDs for Mango, Hyprland, Sway and Labwc together, so one theme works when you switch compositor; unused selectors are harmless. - Labwc: reads
themerc-overridefrom its config directory, no edits needed. Window, menu, OSD and snapping colors are generated; the titlebar font stays inrc.xml. - River: the init script sources
generated-theme.sh. - Hyprland:
lookandfeel.lualoadsgenerated-theme.lua. - Hyprlock:
hyprlock.confsourcesgenerated-hyprlock.conf. The generated file only defines cwal variables; wallpaper, layout and widgets stay yours. - Sway: the config includes
generated-theme.conf. - GTK 3 (e.g. Thunar):
~/.config/gtk-3.0/gtk.cssimportsgenerated-cwal.css. The icon theme is set only if installed. The generated colors are Breeze's named colors, so the GTK theme must be Breeze (packagebreeze-gtk,gtk-theme-name=Breezeinsettings.ini); with any other theme they have no effect.apply-themewarns when Breeze is missing or another theme is selected. - GTK 4:
~/.config/gtk-4.0/gtk.cssimportsgenerated-cwal.css(optionals/.config/gtk-4.0/gtk.cssin unixconfig). The file has Breeze's named colors, as for GTK 3, plus libadwaita's, which libadwaita applications read instead of the GTK theme. Detected throughgtk4-launch. Only colors are handled: the icon theme is set for GTK 3 only. libadwaita chooses its light or dark variant fromgtk-application-prefer-dark-themeinsettings.ini, which cwal does not change, so match it to the theme. - btop:
btop.confhascolor_theme = "cwal". - Qt/KDE:
kdeglobalsuses theCwalcolor scheme and the selected icon theme.cwal-qt.confalso disables client-side decorations for new Qt Wayland applications. - nnn: source
cwal-colors.shfrom your shell startup (for example.bashrc.local). - Vim:
~/.vimrcloads thecwalcolor scheme. - vis:
visrc.luaruns:set theme cwal. - Yazi: nothing; it reads
theme.toml.
dwm and st
Neither has a configuration file: config.h is compiled in. templates/dwm.h
and templates/st.h are complete config.h files (key bindings, rules,
shell, cursor and so on) in which only the fonts, border width and colors come
from the theme. Link the generated file into the source tree you build and
rebuild after applying a theme:
mkdir -p ~/.config/dwm ~/.config/st
ln -sf ~/.config/dwm/config.h /path/to/dwm/config.h
ln -sf ~/.config/st/config.h /path/to/st/config.h
./apply-theme
make -C /path/to/dwm clean install
To move to a new version, link the same file into the new tree. The templates
target the config.def.h interface of dwm 6.8 and st 0.9.3; if a later
version adds a setting, add it to the template.
Adding a program
- Add
templates/<name>using the variables above. - Add
components/<name>.shimplementing the seven phases; copyfoot.shas a starting point and use the helpers incomponents/common.sh. - Register
<name>in thecomponentslist ofapply-theme.
