users/ryan/modules/simple-bar/simple-bar-source/lib/scripts/yabai-set-mode-server.sh
9cb45d050939b499e8e01ec9e4fe9be998d98dc4
· 947 B · 38 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 | |
| 31 | case "$1" in |
| 32 | --query) |
| 33 | echo "$CACHE_FILE" |
| 34 | ;; |
| 35 | *) |
| 36 | main "$@" |
| 37 | ;; |
| 38 | esac |