xiii-wall (1977B)
1 #!/bin/sh 2 set -eu 3 CACHE=$HOME/.cache/wallust 4 DEFAULT_WALL=$HOME/Pictures/wallpapers/saya.png 5 mkdir -p "$CACHE" 6 7 write_baseline() { 8 cp -f "$HOME/.config/wob/wob.ini" "$CACHE/wob.ini" 9 cp -f "$HOME/.config/mako/config" "$CACHE/mako.conf" 10 cp -f "$HOME/.config/niri/baseline.kdl" "$CACHE/niri.kdl" 11 cp -f "$HOME/.config/foot/baseline.ini" "$CACHE/foot.ini" 12 cp -f "$HOME/.config/xiii/baseline.env" "$CACHE/env.sh" 13 } 14 15 reload_desktop() { 16 if command -v niri >/dev/null 2>&1 && [ -n "${WAYLAND_DISPLAY:-}" ]; then 17 niri msg action load-config-file >/dev/null 2>&1 || true 18 fi 19 if [ -n "${WAYLAND_DISPLAY:-}" ]; then 20 pkill -x mako 2>/dev/null || true 21 if [ -r "$CACHE/mako.conf" ]; then 22 nohup mako -c "$CACHE/mako.conf" >/dev/null 2>&1 & 23 else 24 nohup mako >/dev/null 2>&1 & 25 fi 26 "$HOME/.local/bin/xiii-osd" restart >/dev/null 2>&1 || true 27 fi 28 } 29 30 case ${1:-} in 31 --reset) 32 write_baseline 33 reload_desktop 34 printf 'Reverted theme to baseline defaults\n' 35 exit 0 36 ;; 37 --restore) 38 [ -r "$CACHE/niri.kdl" ] && [ -r "$CACHE/foot.ini" ] || write_baseline 39 wall=$(cat "$CACHE/wallpaper" 2>/dev/null || true) 40 [ -r "$wall" ] || wall=$DEFAULT_WALL 41 pkill -x wbg 2>/dev/null || true 42 [ -r "$wall" ] && nohup wbg "$wall" >/dev/null 2>&1 & 43 pkill -x mako 2>/dev/null || true 44 if [ -r "$CACHE/mako.conf" ]; then 45 exec mako -c "$CACHE/mako.conf" 46 fi 47 exec mako 48 ;; 49 ""|-h|--help) 50 printf 'usage: xiii-wall <image> | --reset | --restore\n' >&2 51 exit 2 52 ;; 53 esac 54 55 img=$(readlink -f "$1") 56 [ -r "$img" ] || { printf 'xiii-wall: not readable: %s\n' "$1" >&2; exit 1; } 57 printf '%s\n' "$img" > "$CACHE/wallpaper" 58 if [ -n "${WAYLAND_DISPLAY:-}" ]; then 59 pkill -x wbg 2>/dev/null || true 60 nohup wbg "$img" >/dev/null 2>&1 & 61 fi 62 wallust run -q "$img" 63 reload_desktop