blob: af9035f0b17e0cdfa6b36de9f2be475df3574138 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/sh
# Set a new wallpaper everywhere: main layer, blurred backdrop, wallust colors.
#
# Usage: theme-switcher.sh <wallpaper|path> [--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 <wallpaper> [--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
|