summaryrefslogtreecommitdiff
path: root/mac/.config/sketchybar.mon/plugins/dnd.sh
blob: 42c7ba6f57afefdec6a1d81b5fef5bc3ea0a5dac (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
33
#!/bin/sh

# Load global styles, colors and icons
source "$CONFIG_DIR/globalstyles.sh"

update() {
    dnd_enabled=$(cat ~/Library/DoNotDisturb/DB/Assertions.json | jq .data[0].storeAssertionRecords)
    # alternate method: defaults read com.apple.controlcenter "NSStatusItem Visible FocusModes"
    ICON=􀆺

    if [ "$dnd_enabled" = "null" ]; then
        COLOR=$WHITE_25
        # echo $NAME: "Disabled"
    else
        COLOR=$WHITE
        # echo $NAME: "Enabled"
    fi

    sketchybar --set $NAME icon=$ICON icon.color=$COLOR
}

toggle() {
    osascript -e 'tell application "System Events" to keystroke "\\" using {control down, shift down, command down, option down}'
}

case "$SENDER" in
"routine" | "forced" | "focus_on" | "focus_off")
    update
    ;;
"mouse.clicked")
    toggle
    ;;
esac