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 tospace
components. SketchyBar sets its value totrue
if the space is the active one on its display, andfalse
otherwise.sketchybar --set "$NAME" background.drawing="$SELECTED"
: The script uses the value of$SELECTED
to directly set thebackground.drawing
property. This elegantly toggles the background visibility, highlighting the active space. For this to work, thespace
item must have a background color configured in thesketchybarrc
file.