diff options
Diffstat (limited to 'mac/.config/sketchybar.mon/plugins/volume.sh')
| -rwxr-xr-x | mac/.config/sketchybar.mon/plugins/volume.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/mac/.config/sketchybar.mon/plugins/volume.sh b/mac/.config/sketchybar.mon/plugins/volume.sh new file mode 100755 index 0000000..a03a790 --- /dev/null +++ b/mac/.config/sketchybar.mon/plugins/volume.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +WIDTH=100 + +volume_change() { + source "$CONFIG_DIR/icons.sh" + source "$CONFIG_DIR/colors.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 icon=$ICON + sketchybar --set $NAME slider.percentage=$INFO --animate tanh 30 --set $NAME slider.width=$WIDTH + 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
\ No newline at end of file |
