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