From 8f0d296c321854308d7e349ec0c76b95cfbbc797 Mon Sep 17 00:00:00 2001 From: name Date: Sat, 31 Oct 2026 16:08:39 +0100 Subject: wallpaper scrript is device agnostic now --- home-manager/scripts/matugen-sync.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'home-manager/scripts/matugen-sync.sh') diff --git a/home-manager/scripts/matugen-sync.sh b/home-manager/scripts/matugen-sync.sh index 5ae80e3..4a469d9 100755 --- a/home-manager/scripts/matugen-sync.sh +++ b/home-manager/scripts/matugen-sync.sh @@ -1,18 +1,23 @@ #!/usr/bin/env bash -# We watch the state file that contains the actual text path of the wallpaper +# We watch the wallpaper state directory; Serpantinum writes monitor-specific +# files like current_DP-2 or current_eDP-1. STATE_DIR="$HOME/.cache/serpantinum/wallpaper/" -STATE_FILE="current_DP-2" inotifywait -m -e close_write "$STATE_DIR" | while read -r directory events filename; do - if [ "$filename" = "$STATE_FILE" ]; then + # Only react to monitor pointer files like current_DP-2, current_eDP-1, + # current_HDMI-A-1. Ignore binary/image/json side files. + if [[ "$filename" =~ ^current_[[:alnum:]]+-[[:alnum:]-]+$ ]]; then # Give Serpantinum a split second to finish its operations sleep 0.5 - # Read the real path of the image from the text file - WP_PATH=$(cat "$STATE_DIR$STATE_FILE") + # Read one line from the monitor pointer file. + IFS= read -r WP_PATH < "$STATE_DIR$filename" + + # Skip empty, non-absolute, or missing paths. + [[ -n "$WP_PATH" && "$WP_PATH" = /* && -f "$WP_PATH" ]] || continue # 1. Run Matugen against the ORIGINAL valid image file matugen image "$WP_PATH" -- cgit v1.2.3