Here are some basic commands for pulseaudio management. How to start, stop and restart pulseaudio server without logout. How to control volume level via both amixer and pactl utilities. It is preferable to control the sound of course via pulseaudio itself (pactl), but amixer also easily copes with this task. In any, I didn’t notice the problems.
Start, stop and restart pulseaudio without logout and sudo
This is useful when you are working with settings and configuration of pulseaudio and don’t want to reboot or logout from user session.
Here is the command to stop pulseaudio server, it doesn’t require sudo
systemctl --user stop pulseaudio.socket && systemctl --user stop pulseaudio.service
To start it again, use
systemctl --user start pulseaudio.socket && systemctl --user start pulseaudio.service
You can restart it with just one command
systemctl --user restart pulseaudio.socket && systemctl --user restart pulseaudio.service
Systemctl is a good tool for managing Linux services.
Volume control via amixer
To increase volume level by 5%, use
amixer -D default sset Master 5%+
To decrease volume level by 5%, use
amixer -D default sset Master 5%-
To set volume level directly, use
amixer -D default sset Master 40%
There is a pseudogui representation of amixer called alsamixer.
You can control the volume using the keyboard keys. Press the up arrow to increase the volume by 1%. And press the down arrow to decrease the volume by 1%.
Volume control via pactl (pulseaudio itself)
To increase volume by 5%
pactl set-sink-volume @[email protected] +5%
To decrease by 5%
pactl set-sink-volume @[email protected] -5%
To set volume level directly
pactl set-sink-volume @[email protected] 40%
Your can mute/unmute default sink by the following command
pactl set-sink-mute @[email protected] toggle
Pulseaudio allows other types of values, such as integer, decibel, linear factor. Each type has its own format. So for the percentage format you just use % character.
Unlike amixer, pactl allows you to set volume level over 100%, so be careful with that, don’t damage your hearing
If some utility doesn’t work with pulseaudio or conflicts with other applications
Pulseaudio is a modern sound server, so, some old applications may not include pulseaudio support by default. You can search for how to use pulseaudio as default sound receiver in such application. For example, old music player mpg123 can enable pulseaudio by using -o pulse option
mpg123 -o pulse some_music.mp3
But it uses alsa by default, so, without -o pulse option it will conflict with other applications that use pulseaudio as default, Firefox for example.
Maybe you will need to compile the application with pulseaudio support, or use some plugins. In any case, this problem sometimes arises and you can try to find how to solve it. Good luck!