commit 02487bee63a5b0149edaea534f927e3b9565fc5c parent 2bc55735d3aafd9d283fa74d4b83f1f0e612f648 Author: hhvn <dev@hhvn.uk> Date: Sun, 25 Apr 2021 13:30:24 +0100 .s/b/hvol: use sndioctl(1) Diffstat:
M | .scripts/bin/hvol | | | 31 | ++++++++++++++++++++++++++++++- |
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/.scripts/bin/hvol b/.scripts/bin/hvol @@ -1,4 +1,33 @@ #!/bin/sh -amixer set Master $1 + +[ "$(uname)" = "Linux" ] && amixer set Master "$1" +[ "$(uname)" = "OpenBSD" ] && { + echo "$1" | grep '%' >/dev/null && { + case "$(echo "$1" | sed -E 's/.*(.)$/\1/')" in + "+") t="+" ;; + "-") t="-" ;; + *) t="" ;; + esac + + percent=$(echo "$1" | tr -d '%+-') + units=$(echo "scale=3; $percent / 100" | bc) + + sndioctl output.level="${t}${units}" + + exit 0 + } + + case "$1" in + "mute") sndioctl output.mute=1 ;; + "unmute") sndioctl output.mute=0 ;; + "toggle") + case "$(sndioctl output.mute | sed 's/.*=//')" in + 1) sndioctl output.mute=0 ;; + 0) sndioctl output.mute=1 ;; + esac + ;; + *) sndioctl output.level=$1 ;; + esac +} $HOME/.scripts/dwmblocks/vol > /tmp/blocks/vol