Skip to content

Instantly share code, notes, and snippets.

@nicman23

nicman23/vol

Last active Feb 10, 2021
Embed
What would you like to do?
volume manipulation of pipewire split front and back
#!/bin/bash
card_name='Generic [HD-Audio Generic], device 0: ALC1220 Analog [ALC1220 Analog]' ##### PLEASE EDIT THIS
card_name=$(sed -e 's/\[/\\\[/g' -e 's/\]/\\\]/g' <<< "$card_name")
[[ -z "$1" || -n "$2" ]] && {
echo usage: $(basename $0) '[:num]?(%)(-+)'
echo same number / percentage accepted by 'amixer set'
echo ie vol 5%+
echo ie vol 5
exit 1
}
vol=$1
output=$(pactl info | grep Default\ Sink | cut -f2- -d: | awk '{print $1}')
card=$(aplay -ql | grep "$card_name" | perl -lne 'print $1 if /([0-9])/')
if [ "$output" == 'headphones' ]; then
amixer -c $card set Surround $vol
else
amixer -c $card set Front $vol
amixer -c $card set LFE $vol
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment