(scripts) minor clean up in scripts/select-audio-sink.sh
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
select_audio_sink() {
|
||||
sinks="$(pactl list sinks | grep -iozP "(?s)(?<=Properties:).*?(?=Ports:)" | tr -d '\0')"
|
||||
sinks="$(pactl list sinks)"
|
||||
|
||||
IFS=$(echo -en "\n\b")
|
||||
ids=($(echo "${sinks}" | grep -io -P "(?<=object.serial = ).*$"))
|
||||
ids=($(echo "${sinks}" | grep -ioP "(?<=object.serial = ).*$"))
|
||||
names=($(echo "${sinks}" | grep -ioP "(?<=device\.description = ).*$"))
|
||||
unset IFS
|
||||
|
||||
if [[ "${#ids[@]}" != "${#names[@]}" ]]; then
|
||||
echo "ERROR: #ids (${#ids[@]}) != #names (${#names[@]})"
|
||||
return 0
|
||||
return 1
|
||||
fi
|
||||
|
||||
selection="$(printf "%s\n" "${names[@]//\"/}" | rofi -dmenu)"
|
||||
@@ -24,7 +24,7 @@ select_audio_sink() {
|
||||
|
||||
if [[ -z "${number}" ]]; then
|
||||
echo "something went wrong.."
|
||||
return 0
|
||||
return 1
|
||||
fi
|
||||
|
||||
pactl set-default-sink ${ids[$number]//\"/}
|
||||
|
||||
Reference in New Issue
Block a user