Skip to content

haaag/pythemes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’… PyThemes

Simple CLI tool for update themes, with find/replace and execute commands

Python Hatch project linting - Ruff types - Mypy License - MIT

πŸ“– Description

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.

πŸ› οΈ Usage

~ $ 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

🎨 Apply theme/mode

~ $ 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

🎨 Apply theme/mode to single app

~ $ pythemes gruvbox -m dark -a fzf
[app] fzf applied

πŸ” Show diff for single app

~ $ 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"
?                                      ^^^^^

πŸ“¦ Installation

  • 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

πŸ“ Theme file

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 section

[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)

βš™οΈ Command section (WIP)

[cmd]:
...

πŸŒ„ Wallpaper section

[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

πŸ” Restart section

Will search for PIDs process ids that match the cmd and send the signal SIGUSR1

[restart]
cmd:      commands that will receive the signal SIGUSR1

πŸ“ Example

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

About

πŸ’… Simple cli tool for update themes, find/replace and execute commands

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages