#cli #template #colorscheme #theme

bin+lib wallust

Generate a 16 color scheme based on an image

17 stable releases

2.7.1 Sep 24, 2023
2.6.2 Sep 8, 2023
2.6.1 Aug 12, 2023
2.5.1 Jul 21, 2023
1.0.0 Mar 30, 2023

#271 in Command line utilities

Download history 3/week @ 2023-08-18 17/week @ 2023-08-25 3/week @ 2023-09-01 52/week @ 2023-09-08 21/week @ 2023-09-15 54/week @ 2023-09-22 11/week @ 2023-09-29 4/week @ 2023-10-06 7/week @ 2023-10-13 17/week @ 2023-10-20 63/week @ 2023-10-27 27/week @ 2023-11-03 27/week @ 2023-11-10 10/week @ 2023-11-17 76/week @ 2023-11-24 30/week @ 2023-12-01

147 downloads per month

MIT license

240KB
2.5K SLoC

wallust - Generate colors from an image

crates io downloads license dependency status CodeBerg MatrixChat

gif

sources: adwaita - scenic view of mountains - rms by marco novo - pixels - linus talking

Usage

wallust my_wallpaper.png

use wallust -h for an overview and wallust --help for a more detailed explanation

Features

  • Sets terminal colors on all active terminals
  • Cache scheme palettes
    • Linux: $XDG_CACHE_HOME or $HOME/.cache
    • MacOs: $HOME/Library/Caches
    • Windows: {FOLDERID_LocalAppData}
  • Read pywal/terminal-sexy colorschemes with cs subcommand
  • Built-in pywal themes with the theme subcommand (can be disabled with compile-time features) wallust theme --help to list possible themes
  • Configuration file, documented at wallust.toml of this repo:
    • When no config file, the default config file will be generated
    • Optional templating integrated in a config file
    • backends, colorspaces and filters
    • configurable threshold
    • Linux: $XDG_CONFIG_HOME or $HOME/.config
    • MacOs: $HOME/Library/Application Support
    • Windows: {FOLDERID_RoamingAppData}
Methods Description
Backends How to extract the colors from the image. (e.g pywal uses convert)
ColorSpace Get the most prominent color, and sort them according to the Filter, configurable with a threshold
Filter Makes a scheme palette with the gathered colors, (e.g makes the colors constrast nicely with the background)

To see what's avaliable under each method, check the config file

Threshold

Default is 20 with a more colorful approach, 19 is also suggested.

Number Description
1 Not perceptible by human eyes.
1 - 2 Perceptible through close observation.
2 - 10 Perceptible at a glance.
11 - 49 Colors are more similar than opposite
100 Colors are exact opposite

Terminal colors

By default, wallust will send these sequences to all open terminals:

  • /dev/pts/ on Linux
  • /dev/ttys00 on MacOS
  • ps to search active terminals on OpenBSD
  • Updates settings.json on Windows Terminal, to enable this scheme for the first time you will have to selected it manually

You can skip this with the -s or --skip-sequences flag.

When opening new terminals you will notice that the color sequences are not applied. To solve this you can send the sequences yourself when your shell opens. wallust will store the sequences in the cache directory as a file called sequences, the usual way is to cat ~/.cache/wallust/sequences in your .zshrc, .bashrc, etc.

Templating

OPTIONAL

You can use wallust generated colors in a program by templating the colors in it's config file, like the following example:


#keybindings
...

set default-bg     "{color2}"
set default-fg     "{foreground}"
set statusbar-bg   "{color4}"
set statusbar-fg   "{color6}"
set inputbar-bg    "{color1}"

Then add this file to ~/.config/wallust/ e.g. ~/.config/wallust/zathurarc (config directory defined by the platform) and add a new entry to wallust.toml

[[entry]]
template = "zathurarc"
target = "~/.config/zathura/zathurarc"

You can find examples at pywal templates or wpgtk templates

NOTE: The template name doesn't have to match the target name: e.g. the file could be named sample.conf, and thus the entry would have template = "sample.conf", but the target can remain the same, e.g. target = "~/.config/zathurarc".

Variables and Methods

  • {wallpaper}: The full path to the current wallpaper.
  • {alpha}: displays 100, this is here to be compatible with pywal templates.
  • {var}: Output the color in hex.
  • {var.rgb}: Output the color in rgb.
  • {var.rgba}: Output the color in rgba.
  • {var.xrgba}: Output the color in xrgb.
  • {var.strip}: Output the color in hex (without a #).
  • {var.red}: Output the red value.
  • {var.green}: Output the green value.
  • {var.blue}: Output the blue value.

Where var can be color0 - color15, background, foreground and cursor.

Installation

Distros Packages

NetBSD

If you are using NetBSD, a native package is available from the official repositories. To install it, simply run:

pkgin install wallust

Nix

If you are using Nix, a native package is available for the unstable channel.

Install it for your profile:

nix-env -iA nixos.wallust # change `nixos` for `nixpkgs`, if on a non-NixOS system

Try it with nix-shell

nix-shell -p wallust

Binary

Go to the releases and download the tar.gz file, which contains a binary for musl, so it should work for most *nix platforms.

tar -xf wallust-TARGET.tar.gz

Build from source

The master branch is stable

From this repo

Go to the releases page and download the .zip or .tar.gz repository. After extracting the contents, go to the directory (cd MAYOR.MINOR.PATCH).

Then you can do the following, which moves the binary into your $CARGO_HOME/bin

cargo install --path .

or build it and copy the binary to one folder present in your $PATH like /usr/local/bin

cargo build --release
cp -f ./target/release/wallust /usr/local/bin

From crates.io

cargo install wallust

This will use the lastest version

Contribute!

Use the dev branch

Show some of your taste by adding a backends, colorspaces, filters, and/or colorscheme.

Having thoughts or suggestios is also very welcome.

TODOs

for more, grep the src for TODO rg TODO

  • automate binary releases with a CI, figure out woodkeeper codeberg CI
  • Think about using k means algo similar to pigmnts (just without seg faulting :p)
  • use thiserror for errors in the modules (there aren't that many)

Dependencies

~12–22MB
~268K SLoC