Set Default Sound Output Device With pactl and systemd
My laptop's audio output port is screwed up and only the left channel works. So I have my laptop connected by HDMI to a 22" monitor and a 3-feet aux cable hooked up to the audio output of the monitor. Linux Mint always toggles to the default sound output device so I use this systemd user service to toggle the HDMI output device.
Make sure you have pactl available on your system.
- Run
pactl list - Note the valid
output:entries under theProfilessection and theActive Profile. At boot time, we need to set the active profile to one of the validoutput:*options (output:hdmi-stereoin my case) - Create a systemd user service file at
~/.config/systemd/user/set-sound-profile.servicewith the following contents:
[Unit]
Description=Set default sound output device
Requires=sound.target dbus.service
After=sound.target dbus.service
[Service]
Type=simple
ExecStart=/usr/bin/pactl set-card-profile 0 output:hdmi-stereo
[Install]
WantedBy=default.target
- Remember to change
0(per your system sound cards) andoutput:hdmi-stereo(per valid profiles on your system) in the above file - Enable and start the systemd user service:
systemctl --user daemon-reloadsystemctl --user enable set-sound-profile.servicesystemctl --user start set-sound-profile.service