summaryrefslogtreecommitdiff
path: root/volsv
diff options
context:
space:
mode:
Diffstat (limited to 'volsv')
-rwxr-xr-xvolsv42
1 files changed, 32 insertions, 10 deletions
diff --git a/volsv b/volsv
index a34d591..6c59379 100755
--- a/volsv
+++ b/volsv
@@ -1,5 +1,7 @@
#!/bin/sh
+re='^[0-9]+$'
+
#{{{ detect
detect () {
if pgrep -x pulseaudio >/dev/null; then
@@ -16,17 +18,17 @@ detect () {
#{{{ up
up () {
- [ -n "$SNDIO" ] && sndioctl output.level=+0.05
- [ -n "$PULSE$PIPEWIRE" ] && pamixer -i 5
- [ -n "$ALSA" ] && amixer sset Master 5%+
+ [ -n "$SNDIO" ] && sndioctl output.level=+"$(printf "%0.02f" "$(( amt * 0.01 ))")"
+ [ -n "$PULSE$PIPEWIRE" ] && pamixer -i $amt
+ [ -n "$ALSA" ] && amixer sset Master "${amt}%+"
}
#}}}
#{{{ down
down () {
- [ -n "$SNDIO" ] && sndioctl output.level=-0.05
- [ -n "$PULSE$PIPEWIRE" ] && pamixer -d 5
- [ -n "$ALSA" ] && amixer sset Master 5%-
+ [ -n "$SNDIO" ] && sndioctl output.level=-"$(printf "%0.02f" "$(( amt * 0.01 ))")"
+ [ -n "$PULSE$PIPEWIRE" ] && pamixer -d $amt
+ [ -n "$ALSA" ] && amixer sset Master "${amt}%-"
}
#}}}
@@ -87,8 +89,8 @@ volsv: volume setter v, sets the volume despite the sound server
supported sound servers are sndio, pulseaudio, pipewire, and alsa (no bluealsa)
Actions:
- -i Increase the volume
- -d Decrease the volume
+ -i x Increase the volume by x (5% if not given)
+ -d x Decrease the volume by x (5% if not given)
-t Mute the default output
-m Mute the default mic
-v Get the volume of the default output
@@ -100,8 +102,28 @@ EOF
#{{{ getopts
while getopts "idtmvga" o; do case "${o}" in
- i) setact up || exit 1 ;;
- d) setact down || exit 1 ;;
+ i)
+ eval nextopt=\${$OPTIND}
+ if [ -n "$nextopt" -a "$nextopt" != "-*" ]; then
+ OPTIND=$((OPTIND + 1))
+ amt=$nextopt
+ fi
+ case "$amt" in
+ ''|*[!0-9]*) amt=5 ;;
+ esac
+ setact up || exit 1
+ ;;
+ d)
+ eval nextopt=\${$OPTIND}
+ if [ -n "$nextopt" -a "$nextopt" != "-*" ]; then
+ OPTIND=$((OPTIND + 1))
+ amt=$nextopt
+ fi
+ case "$amt" in
+ ''|*[!0-9]*) amt=5 ;;
+ esac
+ setact down || exit 1
+ ;;
t) setact mute || exit 1 ;;
m) setact micm || exit 1 ;;
v) setact getv || exit 1 ;;