A CLI tool to handle base16-powered Linux ricing.
Managing colors across multiple config files can quickly become messy.
gohan simplifies this by letting you define colors inline.
gohan is a simple command line tool to help you apply base16 color palettes across your Linux setup.
The goal is to simplify templating by reducing the number of files required.
Themes are applied via inline template processing: you just wrap your colors between two markers and gohan takes care of the rest.
For example:
@gohan:start
background: #1d2021
foreground: #d5c4a1
@gohan:end
bla bla bla
@gohan:start
red: #fb4934
green: #b8bb26
blue: #83a598
@gohan:end
gohan identifies blocks marked by @gohan:start and @gohan:end, maps the existing colors to their base16 equvalents, and replaces them using the selected palette.
Make sure you have Git and Go installed.
Assuming ~/.local/bin is in your PATH:
git clone https://github.com/lauroro/gohan
cd gohan
go build -o gohan ./src/main
mv ./gohan ~/.local/bin/
Then open a new terminal and check:
gohan --help
or
gohan --version
gohan reads its configuration and palettes from:
$XDG_CONFIG_HOME/gohan
(default: ~/.config/gohan)
Example structure:
~/.config/gohan/
├── config.yaml
└── palettes/
├── nord.yaml
├── gruvbox-dark-hard.yaml
└── dracula.yaml
config.yaml must contain a list of targets (files to process). It may also include a list of commands to run after processing and an optional features section.
Example:
targets:
- ~/.config/alacritty/alacritty.yml
- ~/.themes/colors.css
commands:
- pkill -USR1 alacritty
- notify-send "Theme applied"
features:
gtk_auto_colorscheme: true
The features section is optional. All feature options default to false when omitted.
Currently supported features:
gtk_auto_colorscheme: When enabled, gohan automatically sets gtk settingcolor-schemetoprefer-darkorprefer-light, based on the newly applied palette.
The palettes/ directory contains your palette files.
gohan supports palettes formatted according to the base16 standard, but is more permissive.
It only requires:
- 16 base keys (
base00tobase0F) - valid hex colors (with or without
#, with or without quotes)
Example:
base00: "000000"
base01: "111111"
base02: "222222"
base03: "333333"
base04: "444444"
base05: "555555"
base06: "666666"
base07: "777777"
base08: "888888"
base09: "999999"
base0A: "aaaaaa"
base0B: "bbbbbb"
base0C: "cccccc"
base0D: "dddddd"
base0E: "eeeeee"
base0F: "ffffff"
or:
base00: "#000000"
base01: "#111111"
base02: "#222222"
base03: "#333333"
base04: "#444444"
base05: "#555555"
base06: "#666666"
base07: "#777777"
base08: "#888888"
base09: "#999999"
base0A: "#aaaaaa"
base0B: "#bbbbbb"
base0C: "#cccccc"
base0D: "#dddddd"
base0E: "#eeeeee"
base0F: "#ffffff"
The filename becomes the palette name.
gohan processes blocks between markers. A block looks like:
@gohan:start
Ferrari's red is #FF2800
@gohan:end
(P.S.: Don't process this block! Ferrari's red is already perfect!)
Markers can appear anywhere on a line, so you can easily embed them in comments:
// @gohan:start
focus-ring {
width 1
active-color "#a9b7c2"
inactive-color "#262b33"
}
// @gohan:end
gohan stores the current palette at:
$XDG_STATE_HOME/gohan/current.yaml
(default: ~/.local/state/gohan/current.yaml)
This file is used to map colors to base keys when applying a new palette.
This is the most tedious step:
- Add the palette you originally used to your
palettes/directory - Ensure it is valid
- Add markers to all target files
- Create your config file
Then initialize gohan:
gohan init <palette_name>
gohan --help
gohan --version
This command prints the file names of the palettes defined in the palettes folder. gohan assumes these are the palette names.
gohan list
This creates gohan's current palette file. Necessary when using gohan for the first time.
gohan init <palette_name>
e.g.:
gohan init nord
This will apply a palette to every target written in the config file, update the current palette file and execute the commands written in the config file.
gohan apply <palette_name>
e.g.:
gohan apply nord
gohan uses gopkg.in/yaml.v3 (Apache-2.0, MIT) for YAML parsing.
If you like this project or find it useful, please consider donating to these organizations and join me in supporting them:
If you'd prefer to support me directly, you can do so here:
- ☕ Ko-fi
Thank you!
Licensed under the GNU GPL-3.0-or-later.
Made with ❤️ and neovim.
