Use the pactl command-line utility to change the default sink or source in PipeWire immediately. Run pactl set-default-sink [name] to switch output devices without editing configuration files, ensuring your changes apply instantly for the current user session.
Identifying Available Audio Devices
Before changing the default device, you must know the exact name of the target sink (output) or source (input). PipeWire manages audio streams similarly to PulseAudio, allowing you to use familiar tools. The most effective way to list all connected and available audio endpoints is using thepactl command with the list sinks or list sources flags.
Open your terminal and execute the following command to see a comprehensive list of output devices:
pactl list sinks short
This command returns a concise table containing the index number, the name of the sink, and the driver module. Look for entries that correspond to your hardware, such as "alsa_output.pci-0000_01_00.1.analog-stereo" for built-in speakers or "bluez_sink.00_11_22_33_44_55.a2dp_sink" for Bluetooth headphones. If you need to identify input devices like microphones, replace sinks with sources in the command.
Note that the names shown here are unique identifiers used by the PipeWire server. They often include prefixes indicating the backend technology, such as alsa_, bluez_, or loopback_. Copy the full name string exactly as it appears, including underscores and hyphens, because any typo will cause the subsequent setting command to fail. For a more verbose view that includes volume levels and active ports, use pactl list sinks without the short flag, though this produces significantly more output.
Setting the Default Sink via Command Line
Once you have identified the correct name of your desired audio device, you can set it as the default for your current session. This method is immediate and does not require restarting any services or logging out. Use theset-default-sink subcommand followed by the device name you copied earlier.
For example, to switch to a specific ALSA output device, run:
pactl set-default-sink alsa_output.pci-0000_01_00.1.analog-stereo
If you prefer to use the numeric index instead of the long name, you can substitute the name with the index number obtained from the previous listing step. However, using the name is generally safer because indices can shift if devices are disconnected and reconnected, whereas names remain consistent for the same hardware instance.
After executing the command, verify the change by running pactl info. Look for the line labeled "Default Sink:" near the top of the output. It should now display the name of the device you just selected. You can test the audio by playing a sound file or checking the system volume slider in your desktop environment; it should reflect the new selection immediately.
Configuring Default Sources for Microphones
Changing the default output is only half the equation. Many users also need to switch the default input device, particularly when toggling between built-in laptop microphones and external USB headsets. The process mirrors that of sinks but uses different commands. To list available input devices, use:pactl list sources short
Then, set your preferred microphone as the default using the set-default-source command:
pactl set-default-source alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-mono
Verify the change with pactl info and check the "Default Source:" line. Applications that record audio, such as voice chat clients or recording software, will automatically pick up the newly designated source upon restart or sometimes dynamically depending on how they handle audio routing.
Persisting Settings Across Reboots
The commands described above only affect the current runtime session. If you reboot your computer or log out, PipeWire will revert to its automatic selection logic, which typically chooses the first detected device or the last manually configured one stored in memory. To make these changes permanent, you cannot simply edit a static config file with hardcoded device names, as this approach is fragile and prone to breaking when hardware configurations change. Instead, the recommended approach for persistence involves using PipeWire's client-side configuration or relying on desktop environment settings. However, for shell-based management, many users find it practical to create a small script or alias that applies thepactl commands at login. You can add these lines to your ~/.bashrc or ~/.profile file, ensuring they run after the PipeWire daemon has started.
Alternatively, some desktop environments provide graphical interfaces to manage audio profiles. Using these GUI tools often writes the preference to the user's local state directory, which PipeWire respects on startup. If you require strict programmatic control, refer to How to Set the Sound Device's Profile at the Shell Prompt for deeper integration techniques involving profile switching rather than simple sink assignment.
Another common issue arises when using USB audio interfaces, where PipeWire may stop working shortly after connection due to permission or module loading errors. Understanding these underlying mechanisms can help troubleshoot why your default setting might not stick. See Pipewire Stops Working Minutes After Using USB Audio Interface on Linux MX-23.4 for detailed troubleshooting steps related to USB audio stability.
Troubleshooting Common Issues
If the default device does not switch correctly, ensure that the PipeWire service is running properly. You can check the status withsystemctl --user status pipewire. Additionally, verify that no other application is holding exclusive control over the audio stream, which can prevent the default sink from being utilized correctly.
Some applications may ignore the system default and use their own internal audio routing. In such cases, you may need to configure the application specifically or use virtual sinks created by PipeWire-Jack or loopback modules. For advanced loopback configurations involving multiple headphone outputs, consult Configuring ALSA Loopback with Simultaneous Headphone Outputs on Ubuntu 22.04.
Frequently Asked Questions
Why does my default sound device change back after reboot?
The pactl commands only modify the runtime state of the PipeWire server and do not write to persistent configuration files. To maintain a setting across reboots, you must either add the commands to your shell login scripts or use your desktop environment's audio settings panel to save the preference.
Can I use the index number instead of the device name?
Yes, you can use the numeric index provided by pactl list sinks short in place of the device name. However, using the name is safer because indices can change dynamically if devices are unplugged or reordered, whereas names remain stable for the same hardware instance.
How do I check if PipeWire is actually handling my audio?
Run pactl info and look for the "Server Name" field. If it says "PipeWire," then PipeWire is active. If it still references PulseAudio, your system may be falling back to legacy compatibility layers, or PipeWire may not be fully initialized yet.
What should I do if the device name contains special characters?
Always enclose the device name in quotes if it contains spaces or special characters. For example, use pactl set-default-sink "my device name". This prevents the shell from misinterpreting the command arguments and ensures the correct string is passed to the PipeWire server.
Does changing the default sink affect all applications?
Most modern applications respect the system default sink. However, some specialized audio software or games may bypass the system default and connect directly to specific hardware nodes. In those cases, you may need to configure the application individually or use virtual sinks to route audio as needed.