feat: optimized set-vol

This commit is contained in:
AngeD 2022-10-17 23:16:04 +02:00
parent b0d91bc2da
commit e11af581e6

View File

@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash
set -e set -e
# TODO: multiple fast invocation cause volume not to be updated
PACTL_SINK='@DEFAULT_SINK@' PACTL_SINK='@DEFAULT_SINK@'
SINK="$PACTL_SINK" SINK="$PACTL_SINK"
@ -21,9 +23,7 @@ set +e
get_vol get_vol
set -e set -e
VOL="$(echo "$VOL" | grep -o -E '[0-9]{,3}%' | head -n 1)" VOL="$(echo "$VOL" | grep -Po '\d+(?=%)' | head -n 1)"
# Remove everything after first '%'
VOL="${VOL%%%*}"
VOL="$((VOL - VOL % "$1"))" VOL="$((VOL - VOL % "$1"))"
case "${1:0:1}" in case "${1:0:1}" in