summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2025-08-30 01:23:23 -0500
committerzachir <zachir@librem.one>2025-08-30 01:23:23 -0500
commit61c287af21a43a6abf1b8c4e16c82d0673974424 (patch)
tree48713c48ec592a9d3947d9594c4c9aa018673d52
parentad827fb7c4fd6bdd84be8e8882e63735beca33ce (diff)
Make more POSIX compliantHEADmaster
Using shellcheck.
-rwxr-xr-xvolsv20
1 files changed, 10 insertions, 10 deletions
diff --git a/volsv b/volsv
index 8c377ca..3a649e7 100755
--- a/volsv
+++ b/volsv
@@ -20,8 +20,8 @@ detect () {
up () {
case "$AUDIO_SERVER" in
WP) wpctl set-volume @DEFAULT_AUDIO_SINK@ "${amt}%+" ;;
- SNDIO) sndioctl output.level=+"$(printf "%0.02f" "$(( amt * 0.01 ))")" ;;
- PULSE|PW) pactl set-sink-volume $(pactl get-default-sink) "+${amt}%" ;;
+ SNDIO) sndioctl output.level=+"$(printf "%s" "$amt" | awk '{printf "%0.02f" ($1 * 0.01)}')" ;;
+ PULSE|PW) pactl set-sink-volume "$(pactl get-default-sink)" "+${amt}%" ;;
ALSA) amixer sset Master "${amt}%+" ;;
esac
}
@@ -31,8 +31,8 @@ up () {
down () {
case "$AUDIO_SERVER" in
WP) wpctl set-volume @DEFAULT_AUDIO_SINK@ "${amt}%-" ;;
- SNDIO) sndioctl output.level=-"$(printf "%0.02f" "$(( amt * 0.01 ))")" ;;
- PULSE|PW) pactl set-sink-volume $(pactl get-default-sink) "-${amt}%" ;;
+ SNDIO) sndioctl output.level=-"$(printf "%s" "$amt" | awk '{printf "%0.02f" ($1 * 0.01)}')" ;;
+ PULSE|PW) pactl set-sink-volume "$(pactl get-default-sink)" "-${amt}%" ;;
ALSA) amixer sset Master "${amt}%-" ;;
esac
}
@@ -45,7 +45,7 @@ mute () {
case "$AUDIO_SERVER" in
WP) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
SNDIO) sndioctl output.mute=! ;;
- PULSE|PW) pactl set-sink-mute $(pactl get-default-sink) toggle ;;
+ PULSE|PW) pactl set-sink-mute "$(pactl get-default-sink)" toggle ;;
ALSA) amixer sset Master toggle ;;
esac
;;
@@ -53,7 +53,7 @@ mute () {
case "$AUDIO_SERVER" in
WP) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle ;;
SNDIO) sndioctl input.mute=! ;;
- PULSE|PW) pactl set-source-mute $(pactl get-default-source) toggle ;;
+ PULSE|PW) pactl set-source-mute "$(pactl get-default-source)" toggle ;;
ALSA) amixer sset Capture toggle ;;
esac
;;
@@ -124,8 +124,8 @@ EOF
#{{{ getopts
while getopts "hidtmvga" o; do case "${o}" in
i)
- eval nextopt=\${$OPTIND}
- if [ -n "$nextopt" -a "$nextopt" != "-*" ]; then
+ eval nextopt="\${$OPTIND}"
+ if [ -n "$nextopt" ] && [ "$nextopt" != "-*" ]; then
OPTIND=$((OPTIND + 1))
amt=$nextopt
fi
@@ -135,8 +135,8 @@ while getopts "hidtmvga" o; do case "${o}" in
setact up || exit 1
;;
d)
- eval nextopt=\${$OPTIND}
- if [ -n "$nextopt" -a "$nextopt" != "-*" ]; then
+ eval nextopt="\${$OPTIND}"
+ if [ -n "$nextopt" ] && [ "$nextopt" != "-*" ]; then
OPTIND=$((OPTIND + 1))
amt=$nextopt
fi