#!/bin/sh # Set a new wallpaper everywhere: main layer, blurred backdrop, wallust colors. # # Usage: theme-switcher.sh [--palette P] [--threshold T] # [--saturation S] [--colorspace C] # # The chosen palette/threshold are persisted to ~/.cache/wallust_runtime so # that apply-colors.sh reproduces them after a reboot. The main wallpaper is # cached by awww itself, so it is also restored on the next boot. set -eu CACHE="${XDG_CACHE_HOME:-$HOME/.cache}" STATE="$CACHE/wallust_runtime" WP=""; palette=""; threshold=""; sat=""; cs="" while [ $# -gt 0 ]; do case "$1" in --palette|-p) palette="$2"; shift 2 ;; --threshold|-t) threshold="$2"; shift 2 ;; --saturation) sat="$2"; shift 2 ;; --colorspace|-c) cs="$2"; shift 2 ;; *) WP="${WP:-$1}"; shift ;; esac done [ -n "$WP" ] || { echo "usage: $0 [--palette P] [--threshold T]" >&2; exit 1; } case "$WP" in /*) ;; *) WP="$HOME/Pictures/wallpapers/$WP" ;; esac [ -f "$WP" ] || { echo "no such wallpaper: $WP" >&2; exit 1; } # Remember the last used wallpaper so apply-colors.sh reproduces it on reboot. echo "$WP" > "$CACHE/current_wallpaper" # Persist palette/threshold for the next boot. : > "$STATE" [ -n "$palette" ] && echo "palette=$palette" >> "$STATE" [ -n "$threshold" ] && echo "threshold=$threshold" >> "$STATE" [ -n "$sat" ] && echo "saturation=$sat" >> "$STATE" [ -n "$cs" ] && echo "colorspace=$cs" >> "$STATE" # Main wallpaper (awww caches it -> restored automatically on next boot). awww img "$WP" # Regenerate colors, sync backdrop, reload live apps. "$HOME/.config/niri/apply-colors.sh" # Refresh niri's own theme (focus ring, etc.) live. matugen image "$WP" 2>/dev/null || true niri msg action reload-config 2>/dev/null || true