summaryrefslogtreecommitdiff
path: root/mac/.config/sketchybar/plugins/aerospace.sh
blob: b8825d50aaff6509050be190a1db386eaec763a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash

# Source colors for consistent theming
source "$CONFIG_DIR/colors.sh"

WORKSPACE_ID="$1"

# Get currently focused workspace
FOCUSED_WORKSPACE=$(aerospace list-workspaces --focused)

# Get workspaces for each monitor
MONITOR_1_WORKSPACES=$(aerospace list-workspaces --monitor 1)
MONITOR_2_WORKSPACES=$(aerospace list-workspaces --monitor 2)

# Check if this workspace is on monitor 1 or 2
ON_MONITOR_1=""
ON_MONITOR_2=""

for ws in $MONITOR_1_WORKSPACES; do
    if [ "$ws" = "$WORKSPACE_ID" ]; then
        ON_MONITOR_1="true"
        break
    fi
done

for ws in $MONITOR_2_WORKSPACES; do
    if [ "$ws" = "$WORKSPACE_ID" ]; then
        ON_MONITOR_2="true"
        break
    fi
done

# Show workspace if:
# 1. It's the currently focused workspace (global focus)
# 2. OR it's one of the "representative" workspaces from each monitor
SHOULD_SHOW="false"

if [ "$WORKSPACE_ID" = "$FOCUSED_WORKSPACE" ]; then
    # Always show the currently focused workspace
    SHOULD_SHOW="true"
elif [ "$ON_MONITOR_1" = "true" ] && [ "$WORKSPACE_ID" = "1" ]; then
    # Show workspace 1 as representative of monitor 1
    SHOULD_SHOW="true"
elif [ "$ON_MONITOR_2" = "true" ] && [ "$WORKSPACE_ID" = "4" ]; then
    # Show workspace 4 as representative of monitor 2 (adjust this number as needed)
    SHOULD_SHOW="true"
fi

if [ "$SHOULD_SHOW" = "true" ]; then
    # Show the workspace item
    sketchybar --set "$NAME" drawing=on
    
    if [ "$WORKSPACE_ID" = "$FOCUSED_WORKSPACE" ]; then
        # Active workspace styling - more noticeable text
        sketchybar --set "$NAME" \
                   background.drawing=on \
                   background.color=$BACKGROUND_2 \
                   background.corner_radius=6 \
                   background.height=26 \
                   background.border_width=0 \
                   icon.color=$WHITE \
                   icon.font="SF Pro:Semibold:14.0" \
                   label.color=$WHITE
    else
        # Workspace visible on other display but not focused - subtle styling
        sketchybar --set "$NAME" \
                   background.drawing=on \
                   background.color=$BACKGROUND_1 \
                   background.corner_radius=6 \
                   background.height=26 \
                   background.border_width=0 \
                   icon.color=$GREY \
                   icon.font="SF Pro:Medium:14.0" \
                   label.color=$GREY
    fi
else
    # Hide workspace that's not active on any display
    sketchybar --set "$NAME" drawing=off
fi



# MAIN_COLOR=0xffa17fa7
# ACCENT_COLOR=0xffe19286
#
# echo $NAME > ~/debug_skekychybar
#
# if [ "$1" = "change-focused-window" ]; then
#     echo "change-focused-window"
#     focused_window_info=$(aerospace list-windows --focused)
#     focused_window_id=$(echo $focused_window_info | awk -F ' \\| ' '{print $1}')
#     if [ "$2" = "$focused_window_id" ]; then
#         sketchybar --set $NAME icon.color=$ACCENT_COLOR
#     else
#         sketchybar --set $NAME icon.color=$MAIN_COLOR
#     fi
# fi
#
# if [ "$1" = "change-focused-workspace" ]; then
#     echo "change-focused-workspace"
#     focused_workspace=$(aerospace list-workspaces --focused)
#     if [ "$2" = "$focused_workspace" ]; then
#         sketchybar --set $NAME label.color=$ACCENT_COLOR
#     else
#         sketchybar --set $NAME label.color=$MAIN_COLOR
#     fi
# fi
#
# if [ "$1" = "move-window-within-workspace" ]; then
#     echo "move-window-within-workspace"
#     focused_workspace=$(aerospace list-workspaces --focused)
#     if [ "$2" = "$focused_workspace" ]; then
#         sketchybar --set $NAME label.color=$ACCENT_COLOR
#     else
#         sketchybar --set $NAME label.color=$MAIN_COLOR
#     fi
# fi