pavolctld
pavolctld is a minimal volume control daemon for PulseAudio written in C.
It uses libpulse
’s threaded/asynchronous API for communicating with the
PulseAudio server. Unlike other CLI solutions for controlling audio, pavolctld
acts as a persistent client. This allows for realtime monitoring of output
sinks/volume levels, low-latency volume control, and minimal overhead.
The stdin/stdout buffers are used for IO, and all events are logged to stdout
as csv data with a one letter prefix specifying the event type. Commands are
sent via stdin using a similar syntax.
pavolctld is designed specifically for use with window managers and is extremely versatile due to its simple design. It can also be used interactively in the terminal. It is released by me under the MIT license.
- You can clone or view the git repository here:
- https://git.tjkeller.xyz/pavolctld
Simply compile pavolctld.c
using make
and install it somewhere in your path.
But isn’t PulseAudio superseded by PipeWire?
Yes, PulseAudio is superseded by PipeWire-Pulse, which is a PulseAudio-compatible daemon that integrates with the PipeWire media server. It is more or less a requirement for any system using PipeWire since most software still uses libpulse on the backend.
PipeWire documentation is also extremely lackluster in regards to controlling the audio server, likely because a PipeWire specific API is an afterthought, libpulse compatibility has always been target. libpulse is simply the more mature and better documented option.
pavolctld has no compatibility issues with either PulseAudio or PipeWire-Pulse.
How it works
State change events
When pavolctld is ran, it will immediately log the state of all sinks to stdout. When any change is made to a sink thereafter, it will be logged as a new event. Each event is output on a new line.
Here are the possible events and their parameters:
-
v[Sink Index],[Volume Percentage],[Volume dBs],[Muted]
- Volume level/mute change
-
f[Sink Index]
- Default sink changed
-
s[Sink Index],[Sink Name],[Sink Description]
- New sink added
-
x[Sink Index]
- Sink removed
Volume control commands
Sink parameters can be modified by entering commands via stdin. Note that the
default sink is not necessarily the sink being modified. Instead, you can set
the “command sink” using the s
command. This way, you can modify a sink
without making it the default sink. The initial command sink however is the
default sink for convenience.
Here are the commands and their parameters:
-
s[Sink Index]
- Set the command sink to sink index. If sink index is not specified, it will be set to the default sink instead.
-
v[+-][Volume Percentage]
- Set the volume level of the command sink. If ‘+’ or ‘-’ are specified, then the current value will be incremented or decremented instead.
-
m[Mute State]
- Mute/Unmute the command sink. Mute state is either ‘0’ for unmuted, or ‘1’ for muted. If mute state is not specified, then mute will be toggled instead.
-
f[Sink Index]
- Set the default sink to sink index. If sink index is not specified, it will be set to the command sink instead.