LinuxCommandLibrary

pactl

Control PulseAudio sound server

TLDR

Show information about the sound server

$ pactl info
copy

List all sinks (or other types - sinks are outputs and sink-inputs are active audio streams)
$ pactl list [sinks] short
copy

Change the default sink (output) to 1 (the number can be retrieved via the list subcommand)
$ pactl set-default-sink [1]
copy

Move sink-input 627 to sink 1
$ pactl move-sink-input [627] [1]
copy

Set the volume of sink 1 to 75%
$ pactl set-sink-volume [1] [0.75]
copy

Toggle mute on the default sink (using the special name @DEFAULT_SINK@)
$ pactl set-sink-mute [@DEFAULT_SINK@] toggle
copy

SYNOPSIS

pactl [options] [command [arguments]]

PARAMETERS

-h, --help
    Show help message.

--version
    Show PulseAudio and protocol version information.

-s SERVER, --server=SERVER
    Connect to the specified PulseAudio server instead of the default one.

-n NAME, --client-name=NAME
    Specify the client name to be used when connecting to the server.

-f FORMAT, --format=FORMAT
    Output information in a specific format (e.g., 'json' for machine-readable output).

-v, --verbose
    Enable verbose output, providing more details on operations.

-i ID, --id=ID
    Specify an object ID for commands that operate on specific objects.

DESCRIPTION

pactl is a command-line utility used to control a running PulseAudio sound server. It provides a more programmatic and scriptable interface compared to pacmd, which is typically interactive. pactl can be used to perform a wide range of actions, such as listing sinks (output devices), sources (input devices), and clients; setting default audio devices; adjusting volumes; muting/unmuting; loading and unloading modules; and managing card profiles. Its non-interactive nature makes it ideal for shell scripts and automated tasks to manage the PulseAudio sound environment.

CAVEATS

pactl requires a running PulseAudio daemon to function. If PulseAudio is not running, commands will fail to connect.
Permissions are crucial. The user running pactl must have sufficient rights to interact with the PulseAudio server, typically meaning they are logged into the same graphical session or configured for remote access.
While powerful, some advanced configurations might still require direct editing of PulseAudio configuration files or using the interactive pacmd for complex scenarios.

COMMON SUBCOMMANDS

info: Displays detailed information about the PulseAudio server, including default sink/source, server version, and module list.
list [type]: Lists properties of various PulseAudio objects. Common types include sinks, sources, sink-inputs, source-outputs, cards, clients, and modules.
set-default-sink NAME|INDEX: Sets the default audio output device by its name or index.
set-sink-volume NAME|INDEX VOLUME: Sets the volume of a specific sink. Volume can be specified as a percentage (e.g., 100%) or absolute value.
set-sink-mute NAME|INDEX 0|1: Mutes (1) or unmutes (0) a specific sink.
load-module NAME [ARGUMENTS]: Loads a PulseAudio module, optionally with specific arguments.
unload-module INDEX|NAME: Unloads a previously loaded PulseAudio module by its index or name.
set-card-profile NAME|INDEX PROFILE: Changes the profile of a sound card (e.g., switching between stereo output, surround sound, or input-only profiles).

HISTORY

pactl is an integral part of the PulseAudio project, which began development around 2004 and gained significant traction in the Linux desktop environment in the late 2000s and early 2010s. It was designed to provide a modern, networked sound server capable of handling multiple audio sources and sinks, per-application volume control, and network audio. pactl emerged as the primary non-interactive tool for scripting and managing this complex audio system, complementing the interactive pacmd.

SEE ALSO

pulseaudio(1), pacmd(1), aplay(1), arecord(1)

Copied to clipboard