0

I've been going down the i3wm road of pain and can't for the life of me understand how to change the output device with cli commands.

Setup:

  • Using i3-gaps (Base Distro is Garuda Linux)
  • pipewire is the audio provider
  • When using pavucontrol I can switch between my Headphones and Speakers as the output port but can't seem to figure what is changing in the background with pactl, wpctl, aplay
  • I have headphones connected to my front aux panel and speakers connected to the rear aux panel.

Any help would be appreciated :)

Update: Found a solution and posted it in the comments

Roy W
  • 1
  • 3

2 Answers2

1

With pactl list short sinks you should be able to list your sinks, your output devices and with pactl info you get information about the actual configuration. The Default Sink should name the actual output.

To switch the default sink, you can use pactl set-default-sink <sink_name>.

I found a script online, that switches through the possible sinks each time it is called: https://ericlathrop.com/2021/02/changing-pulseaudio-outputs-programmatically/

Allthough it says it is for pulse, it works (at least for me) with pipewire as well.

rathier
  • 341
  • 1
  • 5
  • Thanks for the answer, they were both on the same sink for me but I found a solution and will add it to the main post – Roy W Nov 26 '22 at 14:15
0

Found a solution and wrote a short script for it

if [[ $(pactl list | grep "Active Port: analog-output") == *"headphones"* ]]; then
    pactl set-sink-port 0 analog-output-lineout
else
    pactl set-sink-port 0 analog-output-headphones
fi

Also added this to my i3config:

bindsym F6 exec --no-startup-id sh ~/path/to/script/switch_output.sh
Roy W
  • 1
  • 3