You are not logged in.

#1 2025-01-24 01:15:22

Dave_G
Member
Registered: 2021-09-02
Posts: 12

[SOLVED] Function keys work for laptop speakers but not for headphones

I have a laptop running Pipewire and PulseAudio, with i3 as the window manager. In my i3 config file I have these commands controlling the audio function keys (F1, F2, and F3):

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

This works for @DEFAULT_SINK@, i.e. the laptop speakers. But when I send sound to bluetooth headphones instead of the speakers, the function keys have no effect, presumably because the sink ID of the bluetooth device is something different from @DEFAULT_SINK@.

I could find the sink ID of the bluetooth device and change it manually, but that would break the functions when I use the speakers. Is there a way with pactl to automatically change the sink depending on where the sound is actually going?

Last edited by Dave_G (2025-01-26 17:43:06)

Offline

#2 2025-01-24 10:09:38

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,377

Re: [SOLVED] Function keys work for laptop speakers but not for headphones

yes by reconfiguring the default sink with

pactl set-default-sink $SINKNAME

where $SINKNAME is the relevant  sink you want to make the default. After that all @DEFAULT_SINK@ references will point to the set default sink.

If you actually want to do this more dynamically than that, you could do some more scripting and first check which sink is actually in RUNNING state and then use that id for the volume arguments.

Also because of the first sentence, are you actually using pulseaudio directly still or simply via pipewire-pulse?

Last edited by V1del (2025-01-24 10:13:20)

Offline

#3 2025-01-26 02:33:10

Dave_G
Member
Registered: 2021-09-02
Posts: 12

Re: [SOLVED] Function keys work for laptop speakers but not for headphones

Thanks, that's working. I think will script something. Question: Are the sink IDs persistent throughout reboots, upgrades, etc., or are they likely to change?

(And to answer your question, I'm using pipewire-pulse.)

Offline

#4 2025-01-26 11:47:38

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,377

Re: [SOLVED] Function keys work for laptop speakers but not for headphones

the numerical ids aren't, the names will be, pick the names.

Offline

#5 2025-01-26 14:05:34

Dave_G
Member
Registered: 2021-09-02
Posts: 12

Re: [SOLVED] Function keys work for laptop speakers but not for headphones

Thanks. I'd mark this topic as [SOLVED] but I'm not able to edit the subject.

Offline

#6 2025-01-26 15:55:14

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,377

Re: [SOLVED] Function keys work for laptop speakers but not for headphones

you can in the first post, but there's a char limit you're likely hitting, maybe shorten the existing title a bit.

Offline

Board footer

Powered by FluxBB