Fix SketchyBar workspace indicators not reappearing
The aerospace workspace plugin had two issues preventing workspace indicators from properly showing/hiding: 1. The script expected workspace number as $1 but update_freq routine calls only provide $NAME environment variable. Now extracts from either source. 2. Using drawing=off to hide workspaces was unreliable - items wouldn't consistently reappear. Now uses width=0 with cleared icon/label content to collapse items instead. Workspaces now properly appear within 2 seconds when windows are created or moved, without requiring manual sketchybar --update.
This commit is contained in:
@@ -539,8 +539,15 @@ in
|
|||||||
# Get list of empty workspaces
|
# Get list of empty workspaces
|
||||||
EMPTY_WORKSPACES=$(${pkgs.aerospace}/bin/aerospace list-workspaces --monitor all --empty)
|
EMPTY_WORKSPACES=$(${pkgs.aerospace}/bin/aerospace list-workspaces --monitor all --empty)
|
||||||
|
|
||||||
# Clean up the workspace number parameter
|
# Get workspace number - from $1 if provided (event-triggered), otherwise extract from $NAME (routine update)
|
||||||
WORKSPACE_NUM=$(echo "$1" | tr -d ' \n\r')
|
# $NAME is always available (e.g., "space.1", "space.2", etc.)
|
||||||
|
# $1 is only available when called via event trigger with positional argument
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
WORKSPACE_NUM=$(echo "$1" | tr -d ' \n\r')
|
||||||
|
else
|
||||||
|
# Extract number from item name: "space.1" -> "1", "space.10" -> "10"
|
||||||
|
WORKSPACE_NUM=$(echo "$NAME" | sed 's/space\.//')
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if workspace has windows (is NOT empty)
|
# Check if workspace has windows (is NOT empty)
|
||||||
IS_EMPTY=false
|
IS_EMPTY=false
|
||||||
@@ -554,6 +561,13 @@ in
|
|||||||
IS_FOCUSED=true
|
IS_FOCUSED=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Determine display value (workspace 10 displays as "0")
|
||||||
|
if [ "$WORKSPACE_NUM" = "10" ]; then
|
||||||
|
DISPLAY="0"
|
||||||
|
else
|
||||||
|
DISPLAY="$WORKSPACE_NUM"
|
||||||
|
fi
|
||||||
|
|
||||||
# Determine visibility and styling
|
# Determine visibility and styling
|
||||||
# Always show focused workspace (even if empty) with fixed width
|
# Always show focused workspace (even if empty) with fixed width
|
||||||
# Hide non-focused empty workspaces by setting width to 0 (collapsed)
|
# Hide non-focused empty workspaces by setting width to 0 (collapsed)
|
||||||
@@ -562,7 +576,7 @@ in
|
|||||||
if [ "$IS_FOCUSED" = "true" ]; then
|
if [ "$IS_FOCUSED" = "true" ]; then
|
||||||
# Focused workspace - always show with focused styling
|
# Focused workspace - always show with focused styling
|
||||||
${pkgs.sketchybar}/bin/sketchybar --set space.$WORKSPACE_NUM \
|
${pkgs.sketchybar}/bin/sketchybar --set space.$WORKSPACE_NUM \
|
||||||
drawing=on \
|
icon="$DISPLAY" \
|
||||||
width=32 \
|
width=32 \
|
||||||
icon.padding_left=13 \
|
icon.padding_left=13 \
|
||||||
icon.padding_right=11 \
|
icon.padding_right=11 \
|
||||||
@@ -571,13 +585,19 @@ in
|
|||||||
background.drawing=on \
|
background.drawing=on \
|
||||||
icon.color=$TEXT
|
icon.color=$TEXT
|
||||||
elif [ "$IS_EMPTY" = "true" ]; then
|
elif [ "$IS_EMPTY" = "true" ]; then
|
||||||
# Empty workspace (not focused) - hide by turning off drawing
|
# Empty workspace (not focused) - hide by collapsing width and clearing content
|
||||||
|
# Using width=0 + empty icon/label instead of drawing=off because drawing=off doesn't reliably re-show items
|
||||||
${pkgs.sketchybar}/bin/sketchybar --set space.$WORKSPACE_NUM \
|
${pkgs.sketchybar}/bin/sketchybar --set space.$WORKSPACE_NUM \
|
||||||
drawing=off
|
icon="" \
|
||||||
|
label="" \
|
||||||
|
width=0 \
|
||||||
|
icon.padding_left=0 \
|
||||||
|
icon.padding_right=0 \
|
||||||
|
background.drawing=off
|
||||||
else
|
else
|
||||||
# Non-empty workspace (not focused) - show with inactive styling
|
# Non-empty workspace (not focused) - show with inactive styling
|
||||||
${pkgs.sketchybar}/bin/sketchybar --set space.$WORKSPACE_NUM \
|
${pkgs.sketchybar}/bin/sketchybar --set space.$WORKSPACE_NUM \
|
||||||
drawing=on \
|
icon="$DISPLAY" \
|
||||||
width=32 \
|
width=32 \
|
||||||
icon.padding_left=13 \
|
icon.padding_left=13 \
|
||||||
icon.padding_right=11 \
|
icon.padding_right=11 \
|
||||||
|
|||||||
Reference in New Issue
Block a user