diff options
Diffstat (limited to 'users/ryan/modules/simple-bar/simple-bar-source/lib/scripts/yabai-set-mode-server.sh')
| -rwxr-xr-x | users/ryan/modules/simple-bar/simple-bar-source/lib/scripts/yabai-set-mode-server.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/users/ryan/modules/simple-bar/simple-bar-source/lib/scripts/yabai-set-mode-server.sh b/users/ryan/modules/simple-bar/simple-bar-source/lib/scripts/yabai-set-mode-server.sh new file mode 100755 index 0000000..f5fc782 --- /dev/null +++ b/users/ryan/modules/simple-bar/simple-bar-source/lib/scripts/yabai-set-mode-server.sh | |||
| @@ -0,0 +1,38 @@ | |||
| 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 | |||
| 31 | case "$1" in | ||
| 32 | --query) | ||
| 33 | echo "$CACHE_FILE" | ||
| 34 | ;; | ||
| 35 | *) | ||
| 36 | main "$@" | ||
| 37 | ;; | ||
| 38 | esac | ||
