ALSACTL_INIT(7)
π ALSACTL_INIT(7) β the alsactl init glow-up guide π
okay bestie, welcome to ALSACTL_INIT(7), aka the manual page for alsactl init. this is the lore drop on how alsactl init sets up your soundcard, and honestly? it's giving config-file energy and we're obsessed. let's get into it. β¨
πΈ NAME πΈ
alsactl_init β alsa control management β initialization. that's it, that's the name, no cap. π
β¨ DESCRIPTION β¨
"alsactl init" provides soundcard specific initialization. like, it does the soundcard-specific setup thing. that's the whole job. iconic behavior. π
π CONFIGURATION π
all "alsactl init" configuration files live in the /usr/share/alsa/init/ directory. the top level configuration file is /usr/share/alsa/init/00main. π«Ά
you can also point at a different default top-level file using the -i or --initfile parameter for the alsactl tool. slay, flexible.
every file is just a set of lines of text. all empty lines, or lines beginning with #, get ignored. so go ahead and comment your heart out, it's fine. π
π Rules files π
the "alsactl init" rules are read from the files located in the /usr/share/alsa/init/*. the top level configuration file is /usr/share/alsa/init/00main. (yes it said that twice, and yes it still slaps. π)
every line in the rules file contains at least one key value pair. there are two kind of keys: match keys and assignment keys. if all match keys are matching against its value, the rule gets applied and the assign keys get the specified value assigned. that's the whole vibe check. π₯
a rule may consists of a list of one or more key value pairs separated by a comma. each key has a distinct operation, depending on the used operator. valid operators are:
==β compare for equality.!=β compare for non-equality.=β assign a value to a key. keys that represent a list are reset, and only this single value is assigned.+=β add the value to a key that holds a list of entries.:=β assign a value to a key finally; disallow any later changes, which may be used to prevent changes by any later rules. it's the "no take-backs" operator, periodt.
the following key names can be used to match against device properties:
CARDINDEXβ match the card index of the ALSA driver.CTL{attribute}β set or test universal control attribute. possible attributes:numidβ numeric control identification.iface,interfaceβ control interface name (CARD,HWEDEP,MIXER,PCM,RAWMIDI,TIMER,SEQUENCER).subdev,subdeviceβ subdevice number.nameβ control name.indexβ control index.typeβ control type (BOOLEAN,INTEGER,INTEGER64,ENUMERATED,BYTES,IEC958).attr,attributeβ attributes (stored in a string β use match characters*and?):rβ control is readablewβ control is writablevβ control is volatileiβ control is inactivelβ control is lockedRβ control is TLV readableWβ control is TLV writableCβ control is TLV commandableoβ process is owner of this controluβ control created in user space
ownerβ control owner process PID number.countβ control count of values.minβ value range β minimum value.maxβ value range β maximum value.stepβ value range β step value.dBminβ value range β minimum dB value.dBmaxβ value range β maximum dB value.itemsβ enumerated value β number of text items.enumsβ enumerated value β list of text names stored between'|'character.valueβ value of control stored to a string delimited by comma (,).do_searchβ search for a control. value"1"is returned if a control was found. theCTL{name}key might contain match characters*and?. an control index might be specified as first argument starting from zero (e.g.CTL{do_search 2}="1").do_countβ search for a controls and return total count of matched ones. theCTL{name}key might contain match characters*and?.
CONFIG{sysfs_device}β the relative path to sysfs subsystem specifying the root directory of a soundcard device. usually, it should be set to"/class/sound/card$cardinfo{card}/device".ATTR{filename}β match sysfs attribute values of the soundcard device. the relative path to sysfs tree must be defined byCONFIG{sysfs_device}key. trailing whitespace in the attribute values is ignored, if the specified match value does not contain trailing whitespace itself. depending on the type of operator, this key is also used to set the value of a sysfs attribute.ENV{key}β match against the value of an environment variable. up to fiveENVkeys can be specified per rule. depending on the type of operator, this key is also used to export a variable to the environment.PROGRAMβ execute external program. the key is true, if the program returns without exit code zero. the whole event environment is available to the executed program. the program's output printed to stdout is available for theRESULTkey.
several buildin commands are available:
__ctl_searchβ search for a control. theCTL{name}key might contain match characters*and?. an control index might be specified as first argument starting from zero (e.g.PROGRAM="__ctl_search 2").__ctl_countβ search for a controls and return total count of matched ones. theCTL{name}key might contain match characters*and?.
RESULTβ match the returned string of the lastPROGRAMcall. this key can be used in the same or in any later rule after aPROGRAMcall.
most of the fields support a shell style pattern matching. the following pattern characters are supported:
*β matches zero, or any number of characters.?β matches any single character.[]β matches any single character specified within the brackets. for example, the pattern string'tty[SR]'would match either'ttyS'or'ttyR'. ranges are also supported within this match with the'-'character. for example, to match on the range of all digits, the pattern[0-9]would be used. if the first character following the'['is a'!', any characters not enclosed are matched.
the following keys can get values assigned:
CTL{numid},CTL{iface},CTL{device},CTL{subdev},CTL{name},CTL{index}, β select universal control element.CTL{value}β value is set (written) also to soundcard's control device andRESULTkey is set to errno code. the result of set operation is always true (it means continue with next key on line).CTL{values}β value is set (written) also to soundcard's control device (all control values are set to specified value) andRESULTkey is set to errno code. the result of set operation is always true (it means continue with next key on line).CTL{write}β value is set (written) also to soundcard's control device (all control values are set to specified value). the result of set operation is true when operation succeed (it means continue with next key on line).ENV{key}β export a variable to the environment. depending on the type of operator, this key is also to match against an environment variable.RESULTβ setRESULTvariable. note thatPROGRAMalso sets this variable, but setting this variable manually might be useful to change code execution order (included files).LABELβ named label where aGOTOcan jump to.GOTOβ jumps to the nextLABELwith a matching name. the goto cannot jump backward. πINCLUDEβ include the specified filename or files in specified directory.
when a directory is specified, only the files with the extension ".conf" are read. also they are read in the alphabetical order. thus it's highly recommended to use some number prefix (e.g. "01-something.conf") to assure the order of execucions.
ACCESSβ check if specified file or directory existsCONFIG{sysfs_device}β the relative path to sysfs subsystem specifying the root directory of a soundcard device. usually, it should be set to"/class/sound/card$cardinfo{card}/device".PRINTβPRINTvalue to stdout.ERRORβPRINTvalue to stderr.EXITβ exit immediately and set program exit code to value (should be integer). if value is"return"string, parser leaves current included file and returns to parent configuration file.
the PROGRAM, RESULT, CTL{value}, PRINT, ERROR, EXIT, CONFIG{} fields support simple printf-like string substitutions. it allows the use of the complete environment set by earlier matching rules. for all other fields, substitutions are applied while the individual rule is being processed. the available substitutions are:
$cardinfo{attribute},%i{attribute}β seeCARDINFO{}for more details.$ctl{attribute},%C{attribute}β seeCTL{}for more details.$attr{file},%s{file}β the value of a sysfs attribute found at the device, where all keys of the rule have matched. if the attribute is a symlink, the last element of the symlink target is returned as the value.$env{key},%E{key}β the value of an environment variable.$result,%cβ the string returned by the external program requested withPROGRAM. a single part of the string, separated by a space character may be selected by specifying the part number as an attribute:%c{N}. if the number is followed by the'+'char this part plus all remaining parts of the result string are substituted:%c{N+}$sysfsroot,%rβ root directory where sysfs file-system is mounted. ususally, this value is just"/sys".$config{key},%g{key}β the value of a configuration variable. seeCONFIG{}for more details.%%β the'%'character itself.$$β the'$'character itself.
the count of characters to be substituted may be limited by specifying the format length value. for example, '%3s{file}' will only insert the first three characters of the sysfs attribute. cute little slice, honestly. βοΈ
π AUTHOR π
written by Jaroslav Kysela <perex@perex.cz>. π
some portions are written by Greg Kroah-Hartman <greg@kroah.com> and Kay Sievers <kay.sievers@vrfy.org>. the founding mothers and fathers of this whole situation, fr fr. π«‘
π₯ SEE ALSO π₯
alsactl(1)β go read it bestie, it's the main character of this franchise. π
and that's the page!! π this whole thing is from the alsactl manual, dated July 2008, and it lives under ALSACTL_INIT(7). go forth and init those soundcards, you absolute icon. πβ¨ππ¦
π¦ where this page comes from
- alpine 3.22: alsa-utils-doc 1.2.14-r0 Β· GPL-2.0-or-later
- alpine 3.23: alsa-utils-doc 1.2.14-r4 Β· GPL-2.0-or-later
- alpine 3.24: alsa-utils-doc 1.2.15.2-r1 Β· GPL-2.0-or-later
- arch rolling: alsa-utils 1.2.16-1 Β· GPL-2.0-or-later
- centos-stream 10: alsa-utils 1.2.16-1.el10 Β· GPL-2.0-or-later
- centos-stream 9: alsa-utils 1.2.16-1.el9 Β· GPLv2+
- debian bookworm: alsa-utils 1.2.8-1 Β· GPL-2.0-only
- debian trixie: alsa-utils 1.2.14-1 Β· GPL-2.0-only
- fedora 43: alsa-utils 1.2.14-2.fc43 Β· GPL-2.0-or-later
- fedora 43: alsa-utils 1.2.16-1.fc43 Β· GPL-2.0-or-later
- fedora 44: alsa-utils 1.2.15.2-3.fc44 Β· GPL-2.0-or-later
- fedora 44: alsa-utils 1.2.16-1.fc44 Β· GPL-2.0-or-later
- opensuse-leap 16.0: alsa-utils 1.2.14-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: alsa-utils 1.2.14-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: alsa-utils 1.2.14-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: alsa-utils 1.2.14-160000.2.2 Β· GPL-2.0-or-later
- ubuntu jammy: alsa-utils 1.2.6-1ubuntu1 Β· GPL-2.0-only
- ubuntu noble: alsa-utils 1.2.9-1ubuntu5 Β· GPL-2.0-only
- ubuntu questing: alsa-utils 1.2.14-1ubuntu1
- ubuntu resolute: alsa-utils 1.2.15.2-1ubuntu1 Β· GPL-2.0-only
- ubuntu stonking: alsa-utils 1.2.15.2-1ubuntu2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms