blob: 4a469d9ee04cb4be6debabb42a830d2b50b9ab4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/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
|