(scripts) renamed select-audio-sink.sh, added selection of currently
used sink
This commit is contained in:
@@ -22,13 +22,13 @@ width=1
|
|||||||
radius=0
|
radius=0
|
||||||
|
|
||||||
[colors]
|
[colors]
|
||||||
background=#0C0610C0
|
background=#0C0610E4
|
||||||
text=#EFEFEFFF
|
text=#EFEFEFFF
|
||||||
prompt=#586E75FF
|
prompt=#586E75FF
|
||||||
input=#657B83FF
|
input=#657B83FF
|
||||||
placeholder=#93A1A1FF
|
placeholder=#93A1A1FF
|
||||||
match=#7070DFFF
|
match=#7070DFFF
|
||||||
selection=#404050C0
|
selection=#404050E4
|
||||||
selection-text=#EFEFEFFF
|
selection-text=#EFEFEFFF
|
||||||
selection-match=#7070DFFF
|
selection-match=#7070DFFF
|
||||||
counter=#93A1A1FF
|
counter=#93A1A1FF
|
||||||
|
|||||||
@@ -4,22 +4,34 @@ select_audio_sink() {
|
|||||||
sinks="$(pactl list sinks)"
|
sinks="$(pactl list sinks)"
|
||||||
|
|
||||||
IFS=$(echo -en "\n\b")
|
IFS=$(echo -en "\n\b")
|
||||||
|
devices=($(echo "${sinks}" | grep -ioP "(?<=name: ).*$"))
|
||||||
ids=($(echo "${sinks}" | grep -ioP "(?<=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[@]}" ]] || [[ "${#ids[@]}" != "${#devices[@]}" ]]; then
|
||||||
echo "ERROR: #ids (${#ids[@]}) != #names (${#names[@]})"
|
echo "ERROR: #ids (${#ids[@]}) != #names (${#names[@]})"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
unset number
|
||||||
|
for n in ${!devices[@]}; do
|
||||||
|
if [[ "${devices[$n]}" == "$(pactl get-default-sink)" ]]; then
|
||||||
|
number=$n
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ -z "${number}" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
if ((${#ids[@]} > 16)); then
|
if ((${#ids[@]} > 16)); then
|
||||||
lines=16
|
lines=16
|
||||||
else
|
else
|
||||||
lines=${#ids[@]}
|
lines=${#ids[@]}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
selection="$(printf "%s\n" "${names[@]//\"/}" | fuzzel --lines ${lines} --dmenu)"
|
selection="$(printf "%s\n" "${names[@]//\"/}" | fuzzel --lines ${lines} --dmenu --select-index ${number})"
|
||||||
|
|
||||||
if [[ -z "${selection}" ]]; then
|
if [[ -z "${selection}" ]]; then
|
||||||
return 1
|
return 1
|
||||||
@@ -29,6 +41,7 @@ select_audio_sink() {
|
|||||||
for n in ${!names[@]}; do
|
for n in ${!names[@]}; do
|
||||||
if [[ "${names[$n]}" == *"${selection}"* ]]; then
|
if [[ "${names[$n]}" == *"${selection}"* ]]; then
|
||||||
number=$n
|
number=$n
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ bar {
|
|||||||
|
|
||||||
# start screen locker
|
# start screen locker
|
||||||
exec swayidle -w \
|
exec swayidle -w \
|
||||||
timeout 300 'swaymsg "output * power off"' \
|
timeout 300 'swaylock -f -e -i ~/dotfiles/images/city_skyline.png' \
|
||||||
timeout 330 'swaylock -f -e -i ~/dotfiles/images/city_skyline.png; systemctl suspend' \
|
timeout 330 'swaymsg "output * power off"; systemctl suspend' \
|
||||||
resume 'swaymsg "output * power on"' \
|
resume 'swaymsg "output * power on"' \
|
||||||
before-sleep 'swaylock -f -e -i ~/dotfiles/images/city_skyline.png'
|
before-sleep 'swaylock -f -e -i ~/dotfiles/images/city_skyline.png'
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"sway/window": {
|
"sway/window": {
|
||||||
"max-length": 50
|
"max-length": 50
|
||||||
},
|
},
|
||||||
|
|
||||||
"sway/language": {
|
"sway/language": {
|
||||||
"format": " {short} {variant}",
|
"format": " {short} {variant}",
|
||||||
"tooltip": true
|
"tooltip": true
|
||||||
|
|||||||
Reference in New Issue
Block a user