diff options
Diffstat (limited to '.config/niri/set-backdrop.sh')
| -rwxr-xr-x | .config/niri/set-backdrop.sh | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/.config/niri/set-backdrop.sh b/.config/niri/set-backdrop.sh index efd02b3..32e4144 100755 --- a/.config/niri/set-backdrop.sh +++ b/.config/niri/set-backdrop.sh @@ -1,29 +1,19 @@ -#!/bin/bash -# Push a blurred copy of a wallpaper to the awww-daemon backdrop namespace. -# Prefers a pre-made <name>-blur.<ext> sibling; otherwise generates one into the cache. -# Used by theme-switcher.sh and apply-colors.sh for the niri Overview backdrop. - -set -euo pipefail - -IMG="${1:-}" -if [ -z "$IMG" ] || [ ! -f "$IMG" ]; then - echo "usage: $0 <image>" >&2 - exit 1 -fi - -EXT="${IMG##*.}" -SIBLING="${IMG%.*}-blur.${EXT}" -if [ -f "$SIBLING" ]; then - BLURRED="$SIBLING" -else - CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/niri-backdrop" - mkdir -p "$CACHE_DIR" - BASE=$(basename "${IMG%.*}") - BLURRED="$CACHE_DIR/${BASE}-blur.jpg" - if [ ! -f "$BLURRED" ] || [ "$IMG" -nt "$BLURRED" ]; then - magick "$IMG" -blur 0x16 -quality 90 "$BLURRED" +#!/bin/sh +# Generate a blurred copy of WALLPAPER and set it as the awww backdrop layer. +set -eu +WP="${1:?usage: set-backdrop.sh <wallpaper>}" +CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/niri-backdrop" +mkdir -p "$CACHE_DIR" +name="$(basename "${WP%.*}")" +blur="$CACHE_DIR/${name}-blur.jpg" +# (re)generate the blur only if it is missing +[ -f "$blur" ] || magick "$WP" -blur 0x40 -quality 85 "$blur" +# wait for the backdrop daemon socket, then set the image +for _ in 1 2 3 4 5 6 7 8; do + if awww img --namespace backdrop "$blur" 2>/dev/null; then + exit 0 fi -fi - -awww img "$BLURRED" -n backdrop -echo "$BLURRED" >/tmp/current_backdrop_state
\ No newline at end of file + sleep 0.5 +done +echo "set-backdrop: awww backdrop daemon not reachable" >&2 +exit 1 |
