aerospace + sketchybar
change
commit 87344b7cd2a01206514ed01292ada43f7161b7d8
author Alpha Chen <alpha@kejadlen.dev>
date
parent 00966df0
diff --git a/.config/sketchybar/plugins/aerospace.sh b/.config/sketchybar/plugins/aerospace.sh
index 3c7104fa..b64c33d4 100755
--- a/.config/sketchybar/plugins/aerospace.sh
+++ b/.config/sketchybar/plugins/aerospace.sh
@@ -1,5 +1,12 @@
-#!/usr/bin/env bash
+#!/usr/bin/env zsh
 
-if [ -n "$FOCUSED_WORKSPACE" ]; then
-    sketchybar --set "$NAME" label="$FOCUSED_WORKSPACE"
+# Original source:
+#   https://nikitabobko.github.io/AeroSpace/goodness#show-aerospace-workspaces-in-sketchybar
+
+workspaces=("${(@f)$(aerospace list-workspaces --monitor $1)}")
+
+if (($workspaces[(Ie)$FOCUSED_WORKSPACE])); then
+    sketchybar --set "$NAME" label="$FOCUSED_WORKSPACE" background.drawing=on
+else
+    sketchybar --set "$NAME" label="$FOCUSED_WORKSPACE" background.drawing=off
 fi
diff --git a/.config/sketchybar/sketchybarrc b/.config/sketchybar/sketchybarrc
index 6d836ac5..9feba6e2 100755
--- a/.config/sketchybar/sketchybarrc
+++ b/.config/sketchybar/sketchybarrc
@@ -38,12 +38,15 @@ sketchybar --default "${default[@]}"
 ### Aerospace
 
 sketchybar --add event aerospace_workspace_change
-sketchybar --add item aerospace left \
-           --subscribe aerospace aerospace_workspace_change \
-           --set aerospace \
-                 icon.drawing=off \
-                 label="$(aerospace list-workspaces --focused)" \
-                 script="$CONFIG_DIR/plugins/aerospace.sh"
+for monitor in $(aerospace list-monitors | awk '{print $1}'); do
+  sketchybar --add item aerospace.$monitor left \
+             --subscribe aerospace.$monitor aerospace_workspace_change \
+             --set aerospace.$monitor \
+                   display=$monitor \
+                   icon.drawing=off \
+                   label="$(aerospace list-workspaces --focused)" \
+                   script="$CONFIG_DIR/plugins/aerospace.sh $monitor"
+done
 
 ##### Adding Left Items #####
 # We add some regular items to the left side of the bar, where