Кнопки громкости прекращают работать, когда я переключаю аудиовыходы

Я использую pavucontrol для свопинга между моей звуковой картой и моим DAC USB. Каждый раз, когда я изменяю свое устройство вывода - кнопки громкости больше не управляют громкостью.

Вот мой .i3/config файл

bindsym XF86AudioRaiseVolume exec pactl set-sink-volume 0 +5% || pactl set-sink-volume 0 -- +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume 0 -5% || pactl set-sink-volume 0 -- -5%
bindsym XF86AudioMute exec pactl set-sink-mute 0 toggle

Я попытался обновить свой i3Status с MOD+Shift+r. Кто-либо знает, как зафиксировать это?

0
задан 8 October 2017 в 12:21

1 ответ

Я думаю, что у меня была та же проблема, переключающаяся от внутреннего аудио до моей панели звука USB. Надоевший с ручными действиями и поскольку я часто забывал нажимать зеленую кнопку галочки на вкладке Output Device, я решил написать сценарий и назвать ее от Средства запуска.

Мой сценарий (я звонил, это ToggleAudioOutput) использует вывод pacmd list-sinks запрашивать для всех выходных приемников и переключателей к следующему. Моя система имеет аудио HDMI, но поскольку я не использую его, сценарий пропускает его. Существует достаточно комментариев в сценарии для обеспечения настройки к собственной системе.
Я надеюсь, что это помогает.

#!/bin/bash
###############################################################################
# -- ToggleAudioOutput -- Script to change audio output sink.
#
################
# Program logic
#
# The function GetSinks performs a query and transformation.
# The output of GetSinks is stored in a variable.
# The number of sinks and the active sink (*) is determined.
# An array of all sinks is created, the active sink's position is saved.
# The next (or rolling to the first) sink in the array is marked.
# The marked sink is made active. 
# Is an application using the previous sink, force it to use the active.
# A notification about the active sink is shown on the screen.
################

function GetSinks()
{
# Function logic
#
# From the (lengthy) output of 'pacmd list-sinks':
#   grep for 'index' and 'device.description'; giving 2 lines,
#   awk merges 2 lines to 1,
#   remove the 'HDMI' line,  (optional)
#   remove 'index:' and 'device.description ='
#
# For example, the result on my system
#    index: 0
#       device.description = "Built-in Audio Digital Stereo (HDMI)"
#    index: 1
#       device.description = " Logitech Z305   Analog Stereo"
#  * index: 2
#       device.description = "Built-in Audio Analog Stereo"
#
# is transformed to:
#   1  Logitech Z305   Analog Stereo
#  *2 Built-in Audio Analog Stereo
#

################
# Function body.

Property="device.description"

# if HDMI must be in the toggle, comment it out or delete it.
# Be sure to not change the sequence of the following lines.
pacmd list-sinks                    |\
  grep -e"index:" -e"${Property}"   |\
  awk 'NR%2{printf "%s",$0;next;}1' |\
  grep -v HDMI                      |\
  sed "s/^\ \ //"                   |\
  sed "s/ index: //"                |\
  sed "s/[ \x9]*$Property = / /"    |\
  tr -d '\"'
}
# End Of Function

################
# Script body.

Sinks=$(GetSinks)       # call the function, store the output in a variable.
NrSinks=$(echo "$Sinks" | wc -l)
ActSink=$(echo "$Sinks" | grep '*' | cut -c2)

# fill the array, save the active sink's position.
i=1
while read Line
do
  set -- $Line
  SinkNr[$i]=$1;shift
  SinkName[$i]="$@"
  ((SinkNr[$i]==ActSink)) && ((Index=i))
  ((i++))
done < <(echo "$Sinks" | tr -d '*')

# The next or first sink becomes the active.
((Index++))
if ((Index > NrSinks))
then
  Index=1
fi

# Make it happen:
pacmd set-default-sink ${SinkNr[$Index]}

for InputIndex in $(pacmd list-sink-inputs | grep 'index:' | awk '{print $2}')
do
  pacmd move-sink-input $InputIndex ${SinkNr[$Index]}
done

notify-send "Audio output device set to:   >${SinkName[$Index]}<" -t 5000
# End Of File
0
ответ дан 2 November 2019 в 03:46

Другие вопросы по тегам:

Похожие вопросы: