切换音频输出时音量键停止工作

我正在使用pavucontrol在声卡和USB DAC之间切换。 每当我更改输出设备时 – 音量键不再控制音量。

这是我的.i3 /配置文件

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 

我尝试用MOD + Shift + r刷新我的i3Status。 有谁知道如何解决这一问题?

我想从内部音频切换到我的USB条形音箱时遇到了同样的问题。 厌倦了手动操作,因为我经常忘记单击输出设备选项卡中的绿色勾选按钮,我决定编写脚本并从启动器调用它。

我的脚本(我称之为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