X-Git-Url: https://git.xandkar.net/?p=khatus.git;a=blobdiff_plain;f=x2%2Fsrc%2Fawk%2Fexe%2Fparse_pactl_list_sinks.awk;h=5177d723fc90c3c5cc8c0864fd81a907cafaeea9;hp=017a17e85a97da380b7a09126ab44db69e3108c8;hb=c7a86f0fb9cf5678537f4427958ee685885683e5;hpb=e05c10ea70078771831aeb19ce9b01a730c26996 diff --git a/x2/src/awk/exe/parse_pactl_list_sinks.awk b/x2/src/awk/exe/parse_pactl_list_sinks.awk index 017a17e..5177d72 100644 --- a/x2/src/awk/exe/parse_pactl_list_sinks.awk +++ b/x2/src/awk/exe/parse_pactl_list_sinks.awk @@ -4,19 +4,16 @@ next } -/^\t[A-Z].+:/ { - section = $1 -} - -section == "Properties:" { - read_property() -} - /\tState:/ { state[sink] = $2 next } +/\tName:/ { + name[sink] = $2 + next +} + /\tMute:/ { mute[sink] = $2 next @@ -40,21 +37,12 @@ section == "Properties:" { END { for (sink in state) { - device = properties[sink, "alsa.device"] - print("state" Kfs device, state[sink]) - print("mute" Kfs device, mute[sink]) - print("vol_left" Kfs device, vol_left[sink]) - print("vol_right" Kfs device, vol_right[sink]) + # default_sink set via CLI + if (name[sink] == default_sink) { + print("state" , state[sink]) + print("mute" , mute[sink]) + print("vol_left" , vol_left[sink]) + print("vol_right" , vol_right[sink]) + } } } - -function read_property() { - key = $1 - # Yes, the sequence (x-1+1) is redundant, but it keeps the variable names - # true to their meaning: - val_begin = index($0, "\"") + 1 # +1 to exclude first quote - val_end = length($0) - 1 # -1 to exclude last quote - val_len = (val_end - val_begin) + 1 # +1 to include final character - val = substr($0, val_begin, val_len) - properties[sink, key] = val -}