Perceptually accurate wallpaper-to-rice color scheme generator
Project description
Colorice
Colorice is a modern alternative to pywal that uses Oklab color space for perceptually accurate color extraction, generates multiple mood variants (vibrant, muted, warm, cool) to preview and select from, enforces WCAG contrast ratios, and applies schemes across your full desktop rice via a pywal-compatible template engine(yes existing pywal templates work) with color manipulation filters.
Install
Requires Python 3.11+.
pipx install colorice
Or with pip:
pip install colorice
Quick start
# Install default templates for common tools
colorice --init
# Generate a scheme and apply to your configured tools
colorice ~/wallpapers/sunset.jpg --apply
This will:
- Extract dominant colors using over-cluster + farthest-first diversity selection
- Generate 4 palette variants (vibrant, muted, warm, cool)
- Preview them in your terminal — pick one
- Write the scheme to
~/.local/share/colorice/colors.json - Render configured templates and reload your apps
Options
colorice <image> [options]
Extraction:
-c, --colors N Dominant colors to extract (3-16, default: 8)
--segment Region-aware extraction via Felzenszwalb segmentation
Palette:
-m, --moods MOOD[,...] Mood names (default: vibrant,muted,warm,cool)
--min-contrast RATIO Min fg/bg contrast ratio (default: 7.0)
--semantic Enforce ANSI color name conventions (red=red, etc.)
--light Light theme
Output:
-o, --output PATH Output JSON path (default: ~/.local/share/colorice/colors.json)
Use -o - for stdout
--no-preview Skip preview, output first palette
-q, --quiet Suppress all output except errors
Templates:
-a, --apply Apply scheme to configured templates
--config PATH Path to config.toml
--dry-run Preview template output without writing files
--no-hooks Skip post-apply hooks
--init Install default templates and exit
Info:
--list-moods List available mood names and exit
-v, --version Show version and exit
Examples
# Generate and interactively select a scheme
colorice ~/wallpapers/sunset.jpg
# Generate, select, and apply to all configured tools
colorice ~/wallpapers/sunset.jpg --apply
# Quiet mode, pipe JSON to stdout
colorice ~/wallpapers/ocean.png -q -o -
# Light theme with specific moods
colorice wallpaper.jpg --light -m vibrant,cool
# Region-aware extraction (better for complex images)
colorice wallpaper.jpg --segment --apply
# Re-apply existing scheme to templates (no image needed)
colorice --apply
# Preview template output without writing
colorice wallpaper.jpg --dry-run --apply
Template system
Colorice includes a pywal-compatible template engine. Templates use {color0} through {color15}, {background}, {foreground}, {cursor}, and {wallpaper} placeholders.
Setup
# Install bundled templates for common tools
colorice --init
This copies templates to ~/.config/colorice/templates/ for: kitty, alacritty, foot, ghostty, wezterm, hyprland, i3, sway, rofi, dunst, mako, waybar, polybar, swaylock, zellij, neovim, vim, xresources, and shell variables.
Configuration
Edit ~/.config/colorice/config.toml to map templates to output paths:
[[templates]]
name = "kitty"
input = "kitty.conf"
output = "~/.config/kitty/current-theme.conf"
hook = "killall -USR1 kitty"
[[templates]]
name = "hyprland"
input = "hyprland-colors.conf"
output = "~/.config/hypr/colorice-colors.conf"
Then add the include directive in your app config (one-time setup):
- Kitty:
include ~/.config/kitty/current-theme.conf - Alacritty:
import = ["~/.config/alacritty/colorice-theme.toml"] - Hyprland:
source = ~/.config/hypr/colorice-colors.conf - i3/Sway:
include ~/.config/i3/colorice-colors.conf - See each template file for tool-specific instructions.
Color manipulation
Templates support Oklab color manipulation filters for deriving colors beyond the base 16:
{color4.lighten_20} Increase lightness by 0.20
{color0.darken_10} Decrease lightness by 0.10
{color1.saturate_15} Increase chroma by 0.15
{color5.desaturate_10} Decrease chroma by 0.10
{color4.lighten_20.strip} Manipulation + format modifier
Manipulations can be chained — they apply left to right:
{color4.lighten_20.saturate_10.strip}
{color0.darken_10.desaturate_5}
Format modifiers (always last in the chain):
.strip— hex without#(1a2b3c).red,.green,.blue— integer channel value (0-255).rgb—rgb(26,43,60).rgba—rgba(26,43,60,1.0)
How it works
- Extract — loads the image, resizes for performance, runs KMeans clustering in Oklab color space. Over-clusters to 4x the requested count, then uses farthest-first selection for maximum perceptual diversity. Optionally uses Felzenszwalb segmentation for region-aware extraction.
- Cache — extraction results are cached by image content hash + params in
~/.cache/colorice/. Same wallpaper with same settings skips re-extraction. - Mood transform — adjusts chroma, lightness, and hue for the selected mood variant.
- Assign roles — maps colors to 16 ANSI slots. In default (aesthetic) mode, sorts by chroma for wallpaper-matching palettes. In
--semanticmode, enforces hue-zone mapping (red=slot 1, green=slot 2, etc.). - Enforce contrast — binary search on Oklab lightness to meet WCAG contrast ratios against the background.
- Validate — warns about any ANSI color pairs that are too similar (pairwise Oklab distance check).
- Apply — renders templates with the scheme and runs post-apply hooks.
File locations (XDG-compliant)
~/.config/colorice/
config.toml Template configuration
templates/ Template files
~/.local/share/colorice/
colors.json Generated scheme
~/.cache/colorice/
<hash>.json Extraction cache
Respects $XDG_CONFIG_HOME, $XDG_DATA_HOME, and $XDG_CACHE_HOME.
Development
git clone https://github.com/rattle99/colorice.git
cd colorice
pip install -e ".[dev]"
pytest
License
GPL-3.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file colorice-0.1.0.tar.gz.
File metadata
- Download URL: colorice-0.1.0.tar.gz
- Upload date:
- Size: 50.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00e467df350d9a4b50baef9aa229e6a9b9d94d6c74977db1ada9696f4eed2bf5
|
|
| MD5 |
3a371ba0e7bf30eacf6930d03de41c29
|
|
| BLAKE2b-256 |
ae912fda273fb2cd51f16ab69fe6fc0115152985e01392a1c287127c1485a5e8
|
Provenance
The following attestation bundles were made for colorice-0.1.0.tar.gz:
Publisher:
publish.yml on rattle99/colorice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colorice-0.1.0.tar.gz -
Subject digest:
00e467df350d9a4b50baef9aa229e6a9b9d94d6c74977db1ada9696f4eed2bf5 - Sigstore transparency entry: 1383877373
- Sigstore integration time:
-
Permalink:
rattle99/colorice@a202e8fabea6dbfaced0150ded96cb2e1864ae6a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rattle99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a202e8fabea6dbfaced0150ded96cb2e1864ae6a -
Trigger Event:
release
-
Statement type:
File details
Details for the file colorice-0.1.0-py3-none-any.whl.
File metadata
- Download URL: colorice-0.1.0-py3-none-any.whl
- Upload date:
- Size: 50.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67f14511c5b443573ddd2a6b4fb40af9d9a80cb6962898f39b1669a4afe0b0ac
|
|
| MD5 |
61139a4820220f6a7cafcd0d0b1804f8
|
|
| BLAKE2b-256 |
ce92e79488e7d442fcbfb4cb0eabb34b003e6e0b38056cd93fc17989ec44ce50
|
Provenance
The following attestation bundles were made for colorice-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on rattle99/colorice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colorice-0.1.0-py3-none-any.whl -
Subject digest:
67f14511c5b443573ddd2a6b4fb40af9d9a80cb6962898f39b1669a4afe0b0ac - Sigstore transparency entry: 1383877399
- Sigstore integration time:
-
Permalink:
rattle99/colorice@a202e8fabea6dbfaced0150ded96cb2e1864ae6a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rattle99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a202e8fabea6dbfaced0150ded96cb2e1864ae6a -
Trigger Event:
release
-
Statement type: