/ modules / home / programs / sketchybar / sketchybar / plugins / update_workspaces.sh
update_workspaces.sh
 1  #!/bin/bash
 2  
 3  declare -A changes_on changes_off
 4  
 5  for mid in $(aerospace list-monitors); do
 6    for sid in $(aerospace list-workspaces --monitor "$mid" --empty no); do
 7      changes_on["$sid"]=1
 8    done
 9    for sid in $(aerospace list-workspaces --monitor "$mid" --empty); do
10      changes_off["$sid"]=1
11    done
12  done
13  
14  # Ensure focused workspace is always set to drawing=on and icon.highlight=on
15  if [ -n "$FOCUSED_WORKSPACE" ]; then
16    changes_on["$FOCUSED_WORKSPACE"]=1
17    unset changes_off["$FOCUSED_WORKSPACE"] # Remove from changes_off if present
18    sketchybar --set space.$FOCUSED_WORKSPACE icon.highlight=on
19  fi
20  
21  for sid in "${!changes_off[@]}"; do
22    # Avoid turning off if it's already in the "on" list
23    if [ -z "${changes_on[$sid]}" ]; then
24      sketchybar --set space.$sid drawing=off
25    fi
26  done
27  
28  # Apply changes at the end
29  for sid in "${!changes_on[@]}"; do
30    sketchybar --set space.$sid drawing=on
31  done
32