diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-24 20:35:27 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-24 20:35:27 +0900 |
| commit | c80a54e42b52ce297f0f2f71af23c562832025c7 (patch) | |
| tree | dcce8bb977a770f473325d48f6f70b21d9818a40 /mac/.config/sketchybar/plugins/space.sh | |
init
Diffstat (limited to 'mac/.config/sketchybar/plugins/space.sh')
| -rw-r--r-- | mac/.config/sketchybar/plugins/space.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/mac/.config/sketchybar/plugins/space.sh b/mac/.config/sketchybar/plugins/space.sh new file mode 100644 index 0000000..70f3ac4 --- /dev/null +++ b/mac/.config/sketchybar/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 |
