diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-08-23 12:42:37 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-08-23 12:42:37 +0900 |
| commit | 07d294425a98ee5d1e22d03e2b24ae2c76e487c0 (patch) | |
| tree | a6818f0d64438c5fdb88b00a35d944f80c056213 /mac/.config/sketchybar.allapp/plugins/volume.sh | |
| parent | 6fc28cdb3529ca8ee864cb5c41674cb0a4af72a1 (diff) | |
updates
Diffstat (limited to 'mac/.config/sketchybar.allapp/plugins/volume.sh')
| -rwxr-xr-x | mac/.config/sketchybar.allapp/plugins/volume.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/mac/.config/sketchybar.allapp/plugins/volume.sh b/mac/.config/sketchybar.allapp/plugins/volume.sh new file mode 100755 index 0000000..1ee75a0 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/volume.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +WIDTH=100 + +volume_change() { + source "$CONFIG_DIR/icons.sh" + case $INFO in + [6-9][0-9]|100) ICON=$VOLUME_100 + ;; + [3-5][0-9]) ICON=$VOLUME_66 + ;; + [1-2][0-9]) ICON=$VOLUME_33 + ;; + [1-9]) ICON=$VOLUME_10 + ;; + 0) ICON=$VOLUME_0 + ;; + *) ICON=$VOLUME_100 + esac + + sketchybar --set volume_icon label=$ICON \ + --set $NAME slider.percentage=$INFO + + INITIAL_WIDTH="$(sketchybar --query $NAME | jq -r ".slider.width")" + if [ "$INITIAL_WIDTH" -eq "0" ]; then + sketchybar --animate tanh 30 --set $NAME slider.width=$WIDTH + fi + + sleep 2 + + # Check wether the volume was changed another time while sleeping + FINAL_PERCENTAGE="$(sketchybar --query $NAME | jq -r ".slider.percentage")" + if [ "$FINAL_PERCENTAGE" -eq "$INFO" ]; then + sketchybar --animate tanh 30 --set $NAME slider.width=0 + fi +} + +mouse_clicked() { + osascript -e "set volume output volume $PERCENTAGE" +} + +case "$SENDER" in + "volume_change") volume_change + ;; + "mouse.clicked") mouse_clicked + ;; +esac |
