users/ryan/modules/simple-bar/simple-bar-source/lib/scripts/yabai-set-mode.sh

0fcaad38a78d872e8e7fee332986d7b1efc05bb7 · 1.0 KB · 40 lines raw

1 #! /usr/bin/env sh
2
3 # make sure to fix permissions!
4 # Privacy & Security > Automation > skhd > Ubersicht
5
6 # Write information regarding skhd mode to a cache file for widgets to read from.
7 # Usage:
8 # $0 --query print location of cache file
9 # $0 mode_name [color] write mode_name (and optionally, a color) to a cache file
10 # default color is white.
11 # by default, a mode named "default" will not be shown.
12
13 CACHE_FILE="$HOME/Library/Caches/uebersicht-simple-bar-index/yabai-mode"
14
15 mkdir -p "$(dirname "$CACHE_FILE")"
16 touch "$CACHE_FILE"
17
18 main() {
19 # optional second argument color
20 color="$2"
21 if [ -z "$color" ]; then
22 color="white"
23 fi
24
25 # update cache file
26 echo \
27 "{\"mode\": \"$1\", \"color\": \"$color\"}" \
28 > "$CACHE_FILE"
29
30 osascript -e 'tell application id "tracesOf.Uebersicht" to refresh widget id "simple-bar-index-jsx"'
31 }
32
33 case "$1" in
34 --query)
35 echo "$CACHE_FILE"
36 ;;
37 *)
38 main "$@"
39 ;;
40 esac