I use a window manager WM
, like dwm
, so I need to manage my themes, colorschemes manually.
This script will take care of that. It's designed to handle system and application themes, including light
dark
mode switching, wallpaper settings, and command execution.
~ $ pythemes
Usage: {__appname__} [-h] [-m MODE] [-l] [-a APP] [-L] [-d] [-v] [-c COLOR] [--diff] [--verbose] [theme]
Simple CLI tool for update themes files, with find/replace and execute commands.
Options:
theme Theme name
-m, --mode Select a mode [light|dark]
-l, --list List themes found
-a, --app Apply mode to app
-D, --diff Show app diff
-L, --list-apps List available apps in theme
-d, --dry-run Do not make any changes
-c, --color Enable color [always|never] (default: always)
-V, --version Print version and exit
-v, --verbose Increase output verbosity
-h, --help Print this help message
locations:
/home/$USER/.config/pythemes
~ $ pythemes gruvbox -m dark
> gruvbox theme with (10 apps)
[app] bat applied
[app] rofi applied
[app] xresources applied
[app] fzf applied
[app] gtk2-mine no changes needed
[app] gtk3 applied
[app] newsboat applied
[app] nvim applied
[app] git applied
[app] zathura applied
[cmd] dunst executed
[cmd] xresources executed
[wal] my-dark-wallpaperjpg set
[sys] dwm restarted
[sys] st restarted
~ $ pythemes gruvbox -m dark -a fzf
[app] fzf applied
~ $ pythemes gruvbox -m light --app fzf --diff
[app] fzf has changes
- source "$DOTFILES/fzf/themes/gruvbox-dark.fzf"
? ^^^^
+ source "$DOTFILES/fzf/themes/gruvbox-light.fzf"
? ^^^^^
- Simple copy:
Copy the main
script to your $PATH
, and rename it as you want.
- Cloning repository:
# Clone repository
$ git clone "https://github.com/haaag/pythemes"
$ cd pythemes
# Create virtual environment & source
$ python -m venv .venv & source .venv/bin/activate
# Install
(.venv) $ pip install .
- Using
uv
to install tool:
~ $ cd /path/to/cloned/pythemes
~ $ uv tool install .
- Using
pipx
to install tool:
~ $ pipx install /path/to/cloned/pythemes
The theme file, is an INI
file that has 3 sections for now.
- program: section for programs settings
- wallpaper: section for wallpapers settings
- restart: section for restart settings
[program_name]:
file: path to the file to update
query: the query to find in the file
light: the theme to use for the light theme
dark: the theme to use for the dark theme
cmd: the command to execute (optional)
[cmd]:
...
[wallpaper]
light: path to the wallpaper for the light theme
dark: path to the wallpaper for the dark theme
random: path to the directory with the wallpapers
cmd: the command to execute
Will search for PIDs
process ids that match the cmd
and send the signal SIGUSR1
[restart]
cmd: commands that will receive the signal SIGUSR1
This is a example INI file for pythemes
.
You can find the complete example here
; the script will read this file and find the `query` line and replace it with
; the `{theme}` value and then execute the `cmd` command if it is set
[wallpaper]
light=~/wallpapers/my-light-wallpaper.png
dark=~/wallpapers/my-dark-wallpaper.png
random=~/dls/wallpapers/
cmd=nitrogen --save --set-zoom-fill
[bat]
file=~/.config/shell/some-envs.sh
query=export BAT_THEME="{theme}"
light=gruvbox-light
dark=gruvbox-dark
[rofi]
file=~/.config/rofi/config.rasi
query=@theme "{theme}"
light=gruvbox-light-hard
dark=gruvbox-dark
[restart]
cmd=dwm st