Skip to content

Instantly share code, notes, and snippets.

@cobalamin
Created June 16, 2019 20:29
Show Gist options
  • Save cobalamin/f9567452cf7f21b03e1fe66f0a390028 to your computer and use it in GitHub Desktop.
Save cobalamin/f9567452cf7f21b03e1fe66f0a390028 to your computer and use it in GitHub Desktop.
Audio management (prev/play+pause/next, volume up/down, speaker/headphone switching) via the command line
# I used the commands below not only on the command line, but also set up the aliased commands as global keyboard shortcuts.
# This can be useful if you have a keyboard that lacks media keys, or if the media keys don't behave exactly as you want them to.
# Everything below assumes PulseAudio on top of ALSA.
alias volup="amixer set 'Master' 10%+" # Using amixer because pacmd/pactl can increase beyond 100% volume, which I don't want.
alias voldn="amixer set 'Master' 10%-"
# This assumes sink port #1 and the naming of these ports. Check `pacmd list-sinks` and make adjustments if necessary.
alias outsp='pacmd "set-sink-port 1 analog-output;output-speaker' # output to speakers
alias outhp='pacmd "set-sink-port 1 analog-output;output-headphones-1' # output to headphones
# [!!!] See https://github.com/acrisci/playerctl for media control (prev/playpause/next).
# I specified "-p spotify" so this always controls Spotify.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment