LinuxCommandLibrary

alsactl

Save and restore ALSA soundcard settings

SYNOPSIS

alsactl [-h|-V] [-f filename] [-I|-i] [-L] [-R] [-X] [-g] [-q] [-D] [-v] [card#] { store | restore | init | kill | monitor }

PARAMETERS

-h, --help
    Show help message and exit.

-V, --version
    Print alsactl version.

-f, --file #FILENAME
    Specify alternate state file.

-I, --no-init
    Skip card initialization.

-i, --init
    Force card initialization.

-L, --lock
    Lock state file against concurrent access.

-R, --no-restore
    Do not restore state during init.

-X, --detach
    Detach from controlling terminal.

-g, --ignore
    Ignore errors during restore.

-q, --quiet
    Reduce output verbosity.

-D, --debug
    Enable debug output.

-v, --verbose
    Increase verbosity.

DESCRIPTION

alsactl is a command-line utility from the Advanced Linux Sound Architecture (ALSA) suite used to save and restore mixer settings for sound cards. It captures the current state of volume levels, mute switches, and other audio controls, storing them in a persistent file, typically /var/lib/alsa/asound.state. This ensures consistent audio configurations across reboots, user logins, or system suspend/resume cycles.

Key operations include store to snapshot current settings, restore to apply saved states, and init to reset cards to defaults. It supports multiple sound cards via card# argument and uses locking to prevent concurrent access issues. alsactl is commonly invoked by init systems like systemd at boot (e.g., via alsa-restore.service) or shutdown. It interacts with ALSA's kernel API for safe control manipulation, supporting PCM devices, MIDI, and hardware-specific mixers.

For user-specific states, combine with --file option. Debug and verbose modes aid troubleshooting. Widely used in desktops, servers, and embedded systems relying on ALSA for audio.

CAVEATS

Requires read/write access to state file (default /var/lib/alsa/asound.state); system-wide use often needs root. Concurrent runs may conflict without -L. Some controls may fail restore if hardware state changed. Not compatible with OSS emulation.

DEFAULT STATE FILE

/var/lib/alsa/asound.state - Binary file holding mixer control values for all cards.

COMMON USAGE

alsactl store - Save current settings.
alsactl restore - Load last saved state.
alsactl --file ~/.asoundrc.state store - User-specific save.

HISTORY

Developed as part of ALSA project starting 1998 by Jaroslav Kysela. alsactl appeared in early ALSA utils (alsa-lib 0.9.x ~2000), maturing with kernel 2.6+. Evolved for multi-card support, PulseAudio integration, and systemd services.

SEE ALSO

alsamixer(1), amixer(1), aplay(1), arecord(1)

Copied to clipboard