diff options
Diffstat (limited to 'home-manager/scripts')
| -rwxr-xr-x | home-manager/scripts/matugen-sync.sh | 15 |
1 files changed, 10 insertions, 5 deletions
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" |
