Plugin: space.sh
This is a special-purpose plugin designed to work with space components. Its job is to change the appearance of a space item to indicate whether it is currently active.
Usage
This script is assigned to each space item you create. SketchyBar automatically runs this script for all space items whenever the active space changes.
# From the default sketchybarrc
sketchybar --add space space.1 left \
--set space.1 \
space=1 \
script="$PLUGIN_DIR/space.sh"
Source Code
#!/bin/sh
# The $SELECTED variable is available for space components and indicates if
# the space invoking this script (with name: $NAME) is currently selected:
# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item
sketchybar --set "$NAME" background.drawing="$SELECTED"
Explanation
$SELECTED: This is a special environment variable provided only for scripts attached tospacecomponents. SketchyBar sets its value totrueif the space is the active one on its display, andfalseotherwise.sketchybar --set "$NAME" background.drawing="$SELECTED": The script uses the value of$SELECTEDto directly set thebackground.drawingproperty. This elegantly toggles the background visibility, highlighting the active space. For this to work, thespaceitem must have a background color configured in thesketchybarrcfile.