diff --git a/dotfiles/lib/shellenv/linux.sh b/dotfiles/lib/shellenv/linux.sh index 84d9a0fe..a5bcad92 100644 --- a/dotfiles/lib/shellenv/linux.sh +++ b/dotfiles/lib/shellenv/linux.sh @@ -4,7 +4,13 @@ pasink () { pacmd list-sinks | grep '* index' | get_cols ' -1' } -pavolume () { - pactl list sinks | grep '^[[:space:]]Volume:' | \ - head -n $(( $(pasink) + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' +pasink() { + pacmd stat | awk -F": " '/^Default sink name: /{print $2}' +} + +pavolume () { + pacmd list-sinks | + awk '/^\s+name: /{indefault = $2 == "<'$(pasink)'>"} + /^\s+volume: / && indefault {print $5; exit}' + }