summaryrefslogtreecommitdiff
path: root/mac/.config/sketchybar/plugins/monitor_watcher.sh
blob: 50868d300c7f609758c1cdce186dbc97f947a12f (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
#!/usr/bin/env bash

# Source colors for consistent theming
source "$CONFIG_DIR/colors.sh"

# Store current monitor state to detect changes
MONITOR_STATE_FILE="/tmp/aerospace_monitor_state"

# Get current monitor state
CURRENT_MONITORS=$(aerospace list-monitors | awk '{print $1}' | sort | tr '\n' ' ')

# Check if state has changed
if [ -f "$MONITOR_STATE_FILE" ]; then
    PREVIOUS_MONITORS=$(cat "$MONITOR_STATE_FILE")
    if [ "$CURRENT_MONITORS" != "$PREVIOUS_MONITORS" ]; then
        # Monitor configuration changed, update display
        "$CONFIG_DIR/plugins/aerospace_display.sh"
    fi
else
    # First run, create state file
    "$CONFIG_DIR/plugins/aerospace_display.sh"
fi

# Save current state
echo "$CURRENT_MONITORS" > "$MONITOR_STATE_FILE"