summaryrefslogtreecommitdiff
path: root/mac/.config/sketchybar.mon/plugins/dnd.sh
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-08-23 12:42:37 +0900
commit07d294425a98ee5d1e22d03e2b24ae2c76e487c0 (patch)
treea6818f0d64438c5fdb88b00a35d944f80c056213 /mac/.config/sketchybar.mon/plugins/dnd.sh
parent6fc28cdb3529ca8ee864cb5c41674cb0a4af72a1 (diff)
updates
Diffstat (limited to 'mac/.config/sketchybar.mon/plugins/dnd.sh')
-rwxr-xr-xmac/.config/sketchybar.mon/plugins/dnd.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/mac/.config/sketchybar.mon/plugins/dnd.sh b/mac/.config/sketchybar.mon/plugins/dnd.sh
new file mode 100755
index 0000000..42c7ba6
--- /dev/null
+++ b/mac/.config/sketchybar.mon/plugins/dnd.sh
@@ -0,0 +1,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