Media keys for change sound configurations not working properly

When I use the media keys for increase, decrease or mute sound, they change for the wrong device…

in the /etc/i3/config the bind for the keys are:

bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status

When i click in one of the media keys with pavucontrol opened, I can see the commands are changing other device configuration, not the default one. But if I run any of these commands in terminal, the change is made in the correct device.

I cannot send links or screenshots yet, Sorry :confused:

Welcome to Manjaro forum @iagorochaporto

PulseAudio may be configured to use the ‘other’ device as @DEFAULT_SINK@
The default sink can be changed or the key binds can be modified to use a specific named sink

Please post more information about PulseAudio configuration

pactl info; pactl list sinks

Thanks @nikgnomic!

Now no media key is working, but if I copy and paste any media command in the /etc/i3/config, the volume is changing.

my pactl outputs are in portuguese

pactl info:

String do servidor: /run/user/1000/pulse/native
Versão do protocolo da biblioteca: 35
Versão do protocolo do servidor: 35
É local: sim
Índice do cliente: 24
Tamanho de fragmento: 65472
Nome do usuário: iago
Nome da máquina: iago-xps139300
Nome do servidor: pulseaudio
Versão do servidor: 16.1
Especificação padrão de amostragem: s16le 2ch 44100Hz
Mapa de canais padrão: front-left,front-right
Destino padrão: bluez_sink.64_68_76_AA_11_5C.a2dp_sink
Fonte padrão: alsa_input.usb-FIFINE_Microphones_Mic_test_REV1.0-00.analog-stereo
Cookie: 3001:bcd4

pactl list sinks

Destino #0
	Estado: SUSPENDED
	Nome: alsa_output.usb-FIFINE_Microphones_Mic_test_REV1.0-00.analog-stereo
	Descrição: Mic_test Estéreo analógico
	Driver: module-alsa-card.c
	Especificação da amostragem: s16le 2ch 44100Hz
	Mapa dos canais: front-left,front-right
	Módulo proprietário: 6
	Mudo: não
	Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
	        balanço 0,00
	Volume base: 65536 / 100% / 0,00 dB
	Fonte de monitoração: alsa_output.usb-FIFINE_Microphones_Mic_test_REV1.0-00.analog-stereo.monitor
	Latência: 0 useg, 0 useg configurado
	Sinalizadores: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
	Propriedades:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "USB Audio"
		alsa.id = "USB Audio"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "1"
		alsa.card_name = "Mic_test"
		alsa.long_card_name = "FIFINE Microphones Mic_test at usb-0000:00:14.0-8.2, full speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:00:14.0-usb-0:8.2:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8.2/3-8.2:1.0/sound/card1"
		udev.id = "usb-FIFINE_Microphones_Mic_test_REV1.0-00"
		device.bus = "usb"
		device.vendor.id = "3142"
		device.vendor.name = "FIFINE Microphones"
		device.product.id = "0100"
		device.product.name = "Mic_test"
		device.serial = "FIFINE_Microphones_Mic_test_REV1.0"
		device.string = "front:1"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Estéreo analógico"
		device.description = "Mic_test Estéreo analógico"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	Portas:
		analog-output: Analog Output (tipo: Analógico, prioridade: 9900, disponibilidade desconhecida)
	Porta ativa: analog-output
	Formatos:
		pcm

Destino #1
	Estado: SUSPENDED
	Nome: alsa_output.usb-KTMicro_KT_USB_AUDIO_214b206000000178-00.analog-stereo
	Descrição: KT_USB_AUDIO Estéreo analógico
	Driver: module-alsa-card.c
	Especificação da amostragem: s16le 2ch 44100Hz
	Mapa dos canais: front-left,front-right
	Módulo proprietário: 7
	Mudo: não
	Volume: front-left: 68812 / 105% / 1,27 dB,   front-right: 68812 / 105% / 1,27 dB
	        balanço 0,00
	Volume base: 65536 / 100% / 0,00 dB
	Fonte de monitoração: alsa_output.usb-KTMicro_KT_USB_AUDIO_214b206000000178-00.analog-stereo.monitor
	Latência: 0 useg, 0 useg configurado
	Sinalizadores: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
	Propriedades:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "USB Audio"
		alsa.id = "USB Audio"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "2"
		alsa.card_name = "KT_USB_AUDIO"
		alsa.long_card_name = "KTMicro KT_USB_AUDIO at usb-0000:00:14.0-8.3.4, full speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:00:14.0-usb-0:8.3.4:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8.3/3-8.3.4/3-8.3.4:1.0/sound/card2"
		udev.id = "usb-KTMicro_KT_USB_AUDIO_214b206000000178-00"
		device.bus = "usb"
		device.vendor.id = "31b2"
		device.vendor.name = "KTMicro"
		device.product.id = "0011"
		device.product.name = "KT_USB_AUDIO"
		device.serial = "KTMicro_KT_USB_AUDIO_214b206000000178"
		device.string = "front:2"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Estéreo analógico"
		device.description = "KT_USB_AUDIO Estéreo analógico"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	Portas:
		analog-output-speaker: Speakers (tipo: Auto-falante, prioridade: 10000, disponibilidade desconhecida)
	Porta ativa: analog-output-speaker
	Formatos:
		pcm

Destino #2
	Estado: SUSPENDED
	Nome: alsa_output.pci-0000_00_1f.3.analog-stereo
	Descrição: Áudio interno Estéreo analógico
	Driver: module-alsa-card.c
	Especificação da amostragem: s16le 2ch 48000Hz
	Mapa dos canais: front-left,front-right
	Módulo proprietário: 8
	Mudo: não
	Volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
	        balanço 0,00
	Volume base: 65536 / 100% / 0,00 dB
	Fonte de monitoração: alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
	Latência: 0 useg, 0 useg configurado
	Sinalizadores: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
	Propriedades:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC289 Analog"
		alsa.id = "ALC289 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0x603dbb0000 irq 182"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1f.3"
		sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "34c8"
		device.product.name = "Ice Lake-LP Smart Sound Technology Audio Controller"
		device.form_factor = "internal"
		device.string = "front:0"
		device.buffering.buffer_size = "384000"
		device.buffering.fragment_size = "192000"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Estéreo analógico"
		device.description = "Áudio interno Estéreo analógico"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	Portas:
		analog-output-speaker: Speakers (tipo: Auto-falante, prioridade: 10000, disponibilidade desconhecida)
		analog-output-headphones: Headphones (tipo: Fones de ouvido, prioridade: 9900, grupo de disponibilidade: Legacy 2, não disponível)
	Porta ativa: analog-output-headphones
	Formatos:
		pcm

Destino #3
	Estado: SUSPENDED
	Nome: bluez_sink.64_68_76_AA_11_5C.a2dp_sink
	Descrição: EDIFIER W820NB
	Driver: module-bluez5-device.c
	Especificação da amostragem: s16le 2ch 44100Hz
	Mapa dos canais: front-left,front-right
	Módulo proprietário: 25
	Mudo: não
	Volume: front-left: 58622 /  89% / -2,91 dB,   front-right: 58622 /  89% / -2,91 dB
	        balanço 0,00
	Volume base: 65536 / 100% / 0,00 dB
	Fonte de monitoração: bluez_sink.64_68_76_AA_11_5C.a2dp_sink.monitor
	Latência: 0 useg, 0 useg configurado
	Sinalizadores: HARDWARE HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
	Propriedades:
		bluetooth.protocol = "a2dp_sink"
		bluetooth.codec = "sbc"
		device.description = "EDIFIER W820NB"
		device.string = "64:68:76:AA:11:5C"
		device.api = "bluez"
		device.class = "sound"
		device.bus = "bluetooth"
		device.form_factor = "headset"
		bluez.path = "/org/bluez/hci0/dev_64_68_76_AA_11_5C"
		bluez.class = "0x240404"
		bluez.alias = "EDIFIER W820NB"
		device.icon_name = "audio-headset-bluetooth"
		device.intended_roles = "phone"
	Portas:
		headset-output: Headset (tipo: Headset, prioridade: 0, disponibilidade desconhecida)
	Porta ativa: headset-output
	Formatos:
		pcm

As a workaround you can try with scripts.

sound-down

#!/bin/bash
pactl set-sink-volume @DEFAULT_SINK@ -5% ; notify-send "🔉 $($USER/bin/volume)" -i " "

volume

#!/bin/bash
# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info>
# Copyright (C) 2014 Alexander Keller <github@nycroth.com>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

#------------------------------------------------------------------------

# The second parameter overrides the mixer selection
# For PulseAudio users, use "pulse"
# For Jack/Jack2 users, use "jackplug"
# For ALSA users, you may use "default" for your primary card
# or you may use hw:# where # is the number of the card desired
MIXER="default"
[ -n "$(lsmod | grep pulse)" ] && MIXER="pulse"
[ -n "$(lsmod | grep jack)" ] && MIXER="jackplug"
MIXER="${2:-$MIXER}"

# The instance option sets the control to report and configure
# This defaults to the first control of your selected mixer
# For a list of the available, use `amixer -D $Your_Mixer scontrols`
SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols |
                  sed -n "s/Simple mixer control '\([A-Za-z ]*\)',0/\1/p" |
                  head -n1
                )}"

# The first parameter sets the step to change the volume by (and units to display)
# This may be in in % or dB (eg. 5% or 3dB)
STEP="${1:-5%}"

#------------------------------------------------------------------------

capability() { # Return "Capture" if the device is a capture device
  amixer -D $MIXER get $SCONTROL |
    sed -n "s/  Capabilities:.*cvolume.*/Capture/p"
}

volume() {
  amixer -D $MIXER get $SCONTROL $(capability)
}

format() {
  perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)'
  perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "'
  # If dB was selected, print that instead
  perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1')
  perl_filter+='"; exit}'
  perl -ne "$perl_filter"
}

#------------------------------------------------------------------------

case $BLOCK_BUTTON in
  3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;;  # right click, mute/unmute
  4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase
  5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease
esac

volume | format

sound-up

#!/bin/bash
pactl set-sink-volume @DEFAULT_SINK@ +5% ; notify-send "🔊 $($USER/bin/volume)" -i " "

sound-on-off

#!/bin/bash

output=$(pulsemixer --get-mute)

if [[ $output -eq 0 ]] ; then
pulsemixer --mute ; notify-send "🔇 Muted" -i " "
fi

if [[ $output -eq 1 ]] ; then
pulsemixer --unmute ; notify-send "🔈 Sound" -i " "
fi

Scripts in $USER/bin

1 Like

Default sink (Destino padrão) is set to use Bluetooth headphones bluez_sink.64_68_76_AA_11_5C.a2dp_sink

To change default-sink to Onboard Audio:

pactl set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo

To change audio levels Onboard Audio without changing default-sink

pactl set-sink-volume alsa_output.pci-0000_00_1f.3.analog-stereo +10%
pactl set-sink-volume alsa_output.pci-0000_00_1f.3.analog-stereo -10%

For i3wm it may be simpler to use pulsemixer CLI mixer

1 Like

Thanks! I’ll use the pulsemixer, its very handy!

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.