diff options
Diffstat (limited to 'mac/.config/sketchybar.mon/plugins/space.sh')
| -rwxr-xr-x | mac/.config/sketchybar.mon/plugins/space.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/mac/.config/sketchybar.mon/plugins/space.sh b/mac/.config/sketchybar.mon/plugins/space.sh new file mode 100755 index 0000000..70f3ac4 --- /dev/null +++ b/mac/.config/sketchybar.mon/plugins/space.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +source "$CONFIG_DIR/globalstyles.sh" + +if [ "$SELECTED" = "true" ]; then + COLOR=$HIGHLIGHT + OFFSET=-12 # under line + WIDTH="dynamic" +else + COLOR=$TRANSPARENT +fi + +sketchybar --animate tanh 10 \ + --set $NAME icon.highlight=$SELECTED \ + label.highlight=$SELECTED \ + background.color=$COLOR \ + background.y_offset=$OFFSET + +update() { + source "$CONFIG_DIR/colors.sh" + COLOR=$BACKGROUND_2 + WIDTH="dynamic" + + sketchybar --set $NAME icon.highlight=$SELECTED \ + label.highlight=$SELECTED \ + background.border_color=$COLOR \ + sketchybar --animate tanh 8 \ + label.width=$WIDTH \ +} + +set_space_label() { + sketchybar --set $NAME icon="$@" +} + +mouse_clicked() { + if [ "$BUTTON" = "right" ]; then + yabai -m space --destroy $SID + sketchybar --trigger space_change --trigger windows_on_spaces + else + if [ "$MODIFIER" = "shift" ]; then + SPACE_LABEL="$(osascript -e "return (text returned of (display dialog \"Give a name to space $NAME:\" default answer \"\" with icon note buttons {\"Cancel\", \"Continue\"} default button \"Continue\"))")" + if [ $? -eq 0 ]; then + if [ "$SPACE_LABEL" = "" ]; then + set_space_label "${NAME:6}" + else + set_space_label "${NAME:6} ($SPACE_LABEL)" + fi + fi + else + yabai -m space --focus $SID 2>/dev/null + fi + fi +} + +case "$SENDER" in +"mouse.clicked") + mouse_clicked + ;; +*) + update + ;; +esac |
