aboutsummaryrefslogtreecommitdiff
path: root/users/ryan/modules/sketchybar/bar-config/plugins/volume.sh
diff options
context:
space:
mode:
Diffstat (limited to 'users/ryan/modules/sketchybar/bar-config/plugins/volume.sh')
-rwxr-xr-xusers/ryan/modules/sketchybar/bar-config/plugins/volume.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/users/ryan/modules/sketchybar/bar-config/plugins/volume.sh b/users/ryan/modules/sketchybar/bar-config/plugins/volume.sh
new file mode 100755
index 0000000..667d0e8
--- /dev/null
+++ b/users/ryan/modules/sketchybar/bar-config/plugins/volume.sh
@@ -0,0 +1,36 @@
1#!/usr/bin/env bash
2source "$CONFIG_DIR/colors.sh"
3source "$CONFIG_DIR/icons.sh"
4
5STEP=5 # % per scroll tick (Waybar used scroll-step: 1 — bump this down to taste)
6
7if [ "$SENDER" = "mouse.scrolled" ]; then
8 CUR="$(osascript -e 'output volume of (get volume settings)')"
9 case "$SCROLL_DELTA" in
10 -*) VOL=$(( CUR - STEP )) ;; # scroll down
11 *) VOL=$(( CUR + STEP )) ;; # scroll up
12 esac
13 [ "$VOL" -lt 0 ] && VOL=0
14 [ "$VOL" -gt 100 ] && VOL=100
15 osascript -e "set volume output volume $VOL"
16elif [ "$SENDER" = "volume_change" ]; then
17 VOL="$INFO"
18else
19 VOL="$(osascript -e 'output volume of (get volume settings)')"
20fi
21
22MUTED="$(osascript -e 'output muted of (get volume settings)')"
23
24if [ "$MUTED" = "true" ] || { [ "$VOL" -eq 0 ] 2>/dev/null; }; then
25 sketchybar --set "$NAME" label="$VOL_MUTE" # format-muted
26 exit 0
27fi
28
29if [ "$VOL" -ge 66 ]; then ICON=$VOL_3
30elif [ "$VOL" -ge 33 ]; then ICON=$VOL_2
31elif [ "$VOL" -ge 1 ]; then ICON=$VOL_1
32else ICON=$VOL_0
33fi
34
35# Waybar: {volume} {icon}
36sketchybar --set "$NAME" label="$VOL $ICON"