From c7ead0ec0c01c3b43d998aafd1cb9fa76b62daaf Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Fri, 17 Mar 2017 17:38:03 -0700 Subject: [PATCH] [Linux] Improved pavolume command --- dotfiles/lib/shellenv/linux.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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}' + }