summaryrefslogtreecommitdiff
path: root/mac/.config/sketchybar/items/spaces.sh
blob: 5dc28d0ba60000808a7d921c78b47bdf1bc70869 (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
#!/bin/bash

source "$CONFIG_DIR/globalstyles.sh"

SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12")

# Destroy space on right click, focus space on left click.
# New space by left clicking separator (>)

sid=0
spaces=()
for i in "${!SPACE_ICONS[@]}"; do
	sid=$(($i + 1))

	space=(
		space=$sid
		icon="${SPACE_ICONS[i]}"
		icon.padding_left=2
		icon.padding_right=-5
		label.padding_right=10
		label.font="sketchybar-app-font:Regular:16.0"
		label.y_offset=-1
		background.height=2
		script="$PLUGIN_DIR/space.sh"
	)

	sketchybar --add space space.$sid left \
		--set space.$sid "${space[@]}" \
		--subscribe space.$sid mouse.clicked
done

spaces=(
	background.color=$BACKGROUND_1
	background.border_color=$BACKGROUND_2
	background.border_width=2
	background.drawing=on
)

space_creator=(
	icon=󰅂
	icon.font="$FONT:Heavy:25.0"
	padding_left=2
	padding_right=5
	label.drawing=off
	display=active
	script="$PLUGIN_DIR/space_windows.sh"
	associated_display=active
	click_script='yabai -m space --create && sketchybar --trigger space_change'
	icon.color=$WHITE
)

sketchybar --add bracket spaces '/space\..*/' \
	--set spaces "${spaces[@]}" \
	--add item space_creator left \
	--set space_creator "${space_creator[@]}" \
	--subscribe space_creator space_windows_change