Correct pactl command
This commit is contained in:
parent
00dfa3678e
commit
5adab1a936
|
@ -93,10 +93,10 @@ This allows you to replace any instance of the full `xinput(1)` command with `ma
|
|||
|
||||
I want the default PulseAudio sink to change to HDMI when HDMI is plugged in, and back to analog when disconnected.
|
||||
|
||||
Changing the default sink in pulse is as easy as running `pacmd set-default-sink <sink id>` where `<sink id>` is the id of the desired sink. Unfortunately, this is another situation where the id might change unexpectedly. We also don't have an easy interface to determine the id number from a name like we did with `xinput(1)`, so we're forced to parse the output of `pacmd list short` like so:
|
||||
Changing the default sink in pulse is as easy as running `pacmd set-default-sink <sink id>` where `<sink id>` is the id of the desired sink. Unfortunately, this is another situation where the id might change unexpectedly. We also don't have an easy interface to determine the id number from a name like we did with `xinput(1)`, so we're forced to parse the output of `pactl list sinks short` like so:
|
||||
|
||||
{{{class="prettyprint"
|
||||
pacmd set-default-sink $(pacmd list short | grep "hdmi" | grep -o "^\S\+")
|
||||
pacmd set-default-sink $(pactl list sinks short | grep "hdmi" | grep -o "^\S\+")
|
||||
}}}
|
||||
|
||||
This command lists all sinks in short form, then greps for a line containing "hdmi", uses grep to only print the first character (the sink id), then sets the default sink with `pacmd(1)`. Since this will also need to be run any time the display configuration changes, a function is, again, appropriate:
|
||||
|
@ -105,11 +105,11 @@ This command lists all sinks in short form, then greps for a line containing "hd
|
|||
setpasink() {
|
||||
# setpasink <name>
|
||||
# Find a unique string in the output of `pacmd list short` to use for <name>
|
||||
pacmd set-default-sink $(pacmd list short | grep "$1" | grep -o "^\S\+")
|
||||
pacmd set-default-sink $(pactl list sinks short | grep "$1" | grep -o "^\S\+")
|
||||
}
|
||||
}}}
|
||||
|
||||
This allows you to change the default PulseAudio sink with `setpasink <name>` where `<name>` is any arbitrary string that is unique to the line that corresponds to the desired sink in the output of `pacmd list short`.
|
||||
This allows you to change the default PulseAudio sink with `setpasink <name>` where `<name>` is any arbitrary string that is unique to the line that corresponds to the desired sink in the output of `pactl list sinks short`.
|
||||
|
||||
----
|
||||
|
||||
|
|
Loading…
Reference in New Issue