aerospace.sh
1 #!/usr/bin/env bash 2 set -euo pipefail 3 4 # make sure it's executable with: 5 # chmod +x ~/.config/sketchybar/plugins/aerospace.sh 6 7 # Script is called by sketchybar for each item that subscribed, with: 8 # NAME=space.<id> (sketchybar sets this) 9 # FOCUSED_WORKSPACE=<id> (you pass this from Aerospace via --trigger) 10 11 ITEM="${NAME:-}" 12 FOCUSED="${FOCUSED_WORKSPACE:-}" 13 14 # If NAME isn't set (e.g. running by hand), bail quietly 15 [ -z "${ITEM}" ] && exit 0 16 17 # Extract this item's workspace id: "space.3" -> "3" 18 SID="${ITEM#space.}" 19 20 if [ "${SID}" = "${FOCUSED}" ] && [ -n "${FOCUSED}" ]; then 21 # Make sure the item actually shows; highlight the focused one 22 sketchybar --set "${ITEM}" drawing=on icon.highlight=on background.drawing=on 23 else 24 # Still show the item, just not highlighted 25 sketchybar --set "${ITEM}" drawing=on icon.highlight=off background.drawing=on 26 fi