tenseleyflow/ndotfiles / c7b3a21

Browse files

wkspc skbar script up

Authored by espadonne
SHA
c7b3a21601d8b3dcfcec9617c3ad26356f660c00
Parents
2434e4f
Tree
484f4b9

1 changed file

StatusFile+-
A sketchybar/plugins/wkspc.sh 51 0
sketchybar/plugins/wkspc.shadded
@@ -0,0 +1,51 @@
1
+#!/bin/zsh
2
+# simple aerospace workspace status 'bar' for sketchy...'bar'
3
+# show count of non-empty wkspcs, active workspace and up to
4
+# 4 other non-empty workspaces in the format:
5
+#                       "<ico> N :: F : 1 2 3 4"
6
+#
7
+# where N is the number of non-empty spaces
8
+# and F is the focused space and up to 1-4 are nonempty wkspcs
9
+active=$(aerospace list-workspaces --focused)
10
+
11
+case "$1" in
12
+  count)
13
+    # count of non-empty workspaces
14
+    num_active=$(aerospace list-workspaces --empty no --count --monitor all)
15
+    sketchybar --set "wkspc_count" label="${num_active}" 
16
+    sketchybar --set "wkspc_count" label.color=0xff98E6EB
17
+    ;;
18
+  focus)
19
+    # grab the currently focused wkspc
20
+    sketchybar --set "wkspc_act" label="${active}"
21
+    ;;
22
+  others)
23
+    # my brain was hurting and this seemed
24
+    # the best approach to pull newlines out
25
+    # {
26
+    #   mapfile -t workspaces < <( \
27
+    #     aerospace list-workspaces --monitor all --empty no \
28
+    #   )
29
+    #   others=()
30
+    #   for ws in "${workspaces[@]}"; do
31
+    #     [[ "$ws" == "$active" ]] && continue
32
+    #     others+=("$ws")
33
+    #     (( ${#others[@]} == 4 )) && break
34
+    #   done
35
+
36
+    #   others_string="${others[*]}"
37
+    # }
38
+
39
+    # then gippity gave me this one...
40
+    # either that brain pain above was an
41
+    # anyeurism or I've gravely forgotten how to bash-a-mole
42
+    others_string=$(aerospace list-workspaces --monitor all --empty no --format '%{workspace}' \
43
+      | grep -v "^${active}$" \
44
+      | head -n4 \
45
+      | paste -sd ' ' -)
46
+
47
+    sketchybar --set "wkspc_other" label=": ${others_string}"
48
+    ;;
49
+esac
50
+
51
+