summaryrefslogtreecommitdiff
path: root/home-manager/scripts/matugen-sync.sh
blob: 5ae80e3934e8a5909db29d01898555502e665c46 (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
#!/usr/bin/env bash

# We watch the state file that contains the actual text path of the wallpaper
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
        
        # 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")
        
        # 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