A wallpaper's palette for the butter setups
  • C 98.8%
  • Roff 0.7%
  • Nix 0.4%
  • Makefile 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-06 12:58:00 -05:00
.gitignore butterpal 0.1.0: the wallpaper palette as one C program 2026-10-26 15:26:06 -04:00
butterpal.1 butterpal 0.3.2: pale highlights give way to a vivid color that fills a third of the image 2026-11-02 15:59:03 -05:00
butterpal.c butterpal 0.3.2: pale highlights give way to a vivid color that fills a third of the image 2026-11-02 15:59:03 -05:00
flake.nix flake: build butterpal with nix 2026-10-29 21:39:57 -04:00
LICENSE butterpal 0.1.0: the wallpaper palette as one C program 2026-10-26 15:26:06 -04:00
Makefile butterpal 0.3.2: pale highlights give way to a vivid color that fills a third of the image 2026-11-02 15:59:03 -05:00
package.nix butterpal 0.3.2: pale highlights give way to a vivid color that fills a third of the image 2026-11-02 15:59:03 -05:00
README.md consistent readme footer 2026-11-06 12:58:00 -05:00
stb_image.h butterpal 0.1.0: the wallpaper palette as one C program 2026-10-26 15:26:06 -04:00

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, ls and 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

Buy me a coffee

Connect

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