- C 98.8%
- Roff 0.7%
- Nix 0.4%
- Makefile 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .gitignore | ||
| butterpal.1 | ||
| butterpal.c | ||
| flake.nix | ||
| LICENSE | ||
| Makefile | ||
| package.nix | ||
| README.md | ||
| stb_image.h | ||
butterpal
The palette a wallpaper gives the butter setups (butterbox, butterdwm, mangobutter): one small C program they all call, the way tabbed serves both bspwm and dwm.
butterpal ~/Pictures/wallpaper.png
prints 24 colors, one per line: background, second background, text,
border, primary, secondary, alert, disabled, then the 16 terminal colors.
That is the argument order of the setups' wallpaper-theme:
wallpaper-theme "$img" $(butterpal "$img")
How it picks
- The image is shrunk to 192x108 by averaging (every pixel counts) and binned into a 4-bit-per-channel histogram.
- Designed art, with most of its pixels in a few flat colors, keeps its own values; photographs get clear, even colors.
- A small bright patch of another hue (a lamp, a sunset sliver) becomes the primary color; without one, the most vivid color that covers real ground. A pale patch (bokeh, haze) gives way to a vivid color that fills a third of the image, and becomes the secondary.
- Accents are lifted until they read against the background (4.5:1).
- The terminal colors keep their meaning: red is the alert color, and
every other slot takes the image's nearest hue, or a stock one, so diffs,
lsand test output still read right.
The same image gives the same colors on any machine. A 3440x1440 PNG takes about 65 ms.
Build
make
sudo make install # /usr/local/bin and the man page
Needs only a C compiler and libm. PNG, JPEG, BMP and GIF (the first
frame) are read by stb_image (public
domain), included as stb_image.h from commit
003501f6d7a8668ce8b6d875e34dd97ad0d5d5b5.
butterpal --pixels <image> prints the shrunk image, for checking.
With wallust
butterpal --json <image> prints a pywal colorscheme: background, text
and the 16 terminal colors, with the primary as the cursor (the format
has no other accent). wallust fills its templates from it and leaves its
own color picking out:
butterpal --json "$img" > ~/.cache/butterpal.json
wallust cs -s ~/.cache/butterpal.json
The terminal slots keep their meaning here too, so color12 is always a
blue; templates that want the wallpaper's accent should use cursor.
Packages
Debian packages are built in deb-builders and published in butterrepo.
NixOS
The repo includes a flake (flake.nix, building package.nix):
nix run git+https://justaguy.dev/drew/butterpal -- <image>
To keep it, add butterpal.url = "git+https://justaguy.dev/drew/butterpal";
to your flake's inputs and butterpal.packages.${system}.default to your
packages. butterview's
NixOS guide
walks through the same steps for a configuration.
Support
Connect
- YouTube — tutorials and guides
- Butterforge — source code and projects
- Butter desktops — ready-to-use window manager desktops for Debian
- The Butter Lab — Discourse forum
- The Churn — community chat (Fluxer)
- Wiki — documentation and guides
- Mastodon — @justaguylinux@fosstodon.org
- Butterbian — a maintained Debian derivative built on Debian stable
License
GPL-2.0, as the setups it came from. stb_image.h is public domain (or
MIT, at your choice).
Made with 🧈 by JustAGuyLinux
