When setting up a new Arch Linux system, you might encounter issues getting audio output through HDMI, especially when using a monitor with built-in speakers. This article will introduce my experience of configuring my system to output audio via HDMI.
Prerequisites #
- An Arch Linux system with administrative privileges.
- A monitor with built-in speakers connected via HDMI.
- Basic knowledge of the command line.
Step 1: Install Necessary Packages #
First, ensure you have the required audio utilities installed.
Install alsa-utils
#
The alsa-utils package provides essential tools for managing ALSA (Advanced Linux Sound Architecture).
sudo pacman -S alsa-utils
Step 2: Identify Your Audio Devices #
Before configuring audio output, identify your system’s audio devices.
List Audio Playback Devices #
Use the aplay command to list all playback devices:
aplay -l
Sample Output #
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [LG ULTRAFINE]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC269VC Analog [ALC269VC Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
Interpretation:
- Card 0: HDMI audio device (your monitor).
- Card 1: Internal audio device (motherboard’s sound card).
Step 3: Install and Configure PulseAudio #
PulseAudio is a powerful sound server that can manage audio devices more effectively than ALSA alone.
Install PulseAudio and Related Packages #
sudo pacman -S pulseaudio pulseaudio-alsa
Start PulseAudio #
Start the PulseAudio service:
pulseaudio --start
Note: If you receive a command not found error, ensure that the installation was successful.
Step 4: Set HDMI as the Default Audio Output #
To ensure audio outputs through HDMI by default, configure PulseAudio accordingly.
Create Configuration Directory #
If the directory doesn’t exist, create it:
mkdir -p ~/.config/pulse
Create or Edit client.conf
#
nvim ~/.config/pulse/client.conf # The editor I use is neovim
Add the Following Configuration #
autospawn = yes
Identify the HDMI Sink Name #
List all available sinks to find the HDMI output’s sink name:
pactl list sinks short
Sample Output #
0 alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra1 module-alsa-card.c s16le 2ch 44100Hz RUNNING
1 alsa_output.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
Identify the sink corresponding to your HDMI output (usually containing hdmi in the name).
Update client.conf with Default Sink
#
Add or modify the default-sink line in client.conf:
autospawn = yes
default-sink = alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra1
Replace alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra1 with the sink name identified in the previous step.
Restart PulseAudio #
Apply the changes by restarting PulseAudio:
pulseaudio -k
pulseaudio --start
Step 5: Use pavucontrol to Manage Audio Devices
#
pavucontrol (PulseAudio Volume Control) provides a user-friendly graphical interface to manage audio devices.
Install pavucontrol
#
sudo pacman -S pavucontrol
Launch pavucontrol
#
pavucontrol
Configure Output Device #
- Navigate to the Output Devices tab.
- Find your HDMI device (e.g.,
HDMI / DisplayPortor the name of your monitor). - Set it as the default output device by using the webpage.
Note #
If you encounter the message Establishing connection to PulseAudio. Please wait..., it indicates that pavucontrol cannot connect to the PulseAudio server. Ensure that PulseAudio is running correctly (see the following for troubleshooting).
Step 6: Troubleshooting Common Issues #
Issue: pulseaudio Command Not Found
#
Symptom: Running pulseaudio --check or pulseaudio --start results in command not found.
Solution:
-
Ensure
pulseaudiois installed:sudo pacman -S pulseaudio pulseaudio-alsa -
Verify installation:
which pulseaudioThis should output the path to the
pulseaudiobinary, such as/usr/bin/pulseaudio.
Issue: pavucontrol Cannot Connect to PulseAudio
#
Symptom: pavucontrol displays Establishing connection to PulseAudio. Please wait... indefinitely.
Solution:
-
Check if PulseAudio is Running:
pulseaudio --checkIf no output is returned, PulseAudio is running.
-
Start PulseAudio Manually:
pulseaudio --start -
Restart PulseAudio:
pulseaudio -k pulseaudio --start -
Check for Errors:
View PulseAudio logs for any errors:
journalctl --user -xe | grep pulseaudio
Issue: No Sound Output After Configuration #
Symptom: After setting HDMI as the default output, there’s still no sound.
Solution:
-
Check Volume Levels:
Ensure that the output is not muted and the volume is turned up.
alsamixerUse the arrow keys to adjust volume and
Mto toggle mute. -
Test Audio Playback:
Use
speaker-testto test audio output:speaker-test -D hw:0,7 -c 2 -t wavReplace
hw:0,7with your HDMI card and device numbers from theaplay -loutput. -
Ensure Correct Sink Is Set:
Verify the default sink in PulseAudio:
pactl info | grep "Default Sink"It should match your HDMI sink name.