#!/usr/bin/env bash # 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/" inotifywait -m -e close_write "$STATE_DIR" | while read -r directory events filename; do # 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 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" # 2. Reload Hyprland hyprctl reload # 3. Reload running Foot terminals pkill -HUP foot fi done