pa-cli is a lightweight, asynchronous C utility for managing PulseAudio sound server settings. It provides a streamlined command-line interface to control sinks, sources, and playback streams using the native libpulse API.
You need the PulseAudio development headers and a C compiler to build this project.
sudo apt update
sudo apt install libpulse-dev build-essentialsudo pacman -S libpulse base-develsudo dnf install pulseaudio-libs-devel gcc makeRun make in the root directory to compile the binary:
makeThe Makefile moves the binary to /usr/bin and the documentation to your system's manual path:
sudo make installTo remove all files associated with pa-cli:
sudo make uninstallpa-cli — PulseAudio command-line tool for device and stream management.
pa-cli [DEVICE] [ACTION] [ARGUMENT]
pa-cli help
pa-cli interacts with the PulseAudio sound server via the asynchronous libpulse API. It allows users to list hardware devices, query status, adjust volume levels, and manage default routing.
Stream Migration: A key feature of pa-cli is that whenever a new default sink or source is set, the tool automatically attempts to move all currently active audio streams (sink-inputs) to that new device for a seamless transition.
The first argument defines the target category:
- sink: Physical output devices (e.g., speakers, headphones).
- source: Physical input devices (e.g., microphones).
- sink-input: Active playback streams from individual applications.
- list: Displays index, name, and description of devices.
- get-default: Prints the name of the current default device.
- set-default [NAME]: Sets the default device and migrates active streams.
- get-volume: Returns the volume of the default device (0-100).
- adjust-volume [+/- VALUE]: Adjusts the volume of the default device relative to current levels.
- is-muted: Returns
1if muted,0otherwise. - mute: Toggles the mute state of the default device.
- 0: Success.
- 1: Connection failure or invalid arguments.
- 2: Action not supported for the specific device type.
Increase system volume by 5%:
pa-cli sink adjust-volume 5Toggle microphone mute:
pa-cli source muteList all active application streams:
pa-cli sink-input listWritten by Alisson Bruno.