Skip to content

Instantly share code, notes, and snippets.

@ouuan
Last active June 18, 2021 07:15
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ouuan/c7b313afef9f3506aadb259cb794d399 to your computer and use it in GitHub Desktop.
Save ouuan/c7b313afef9f3506aadb259cb794d399 to your computer and use it in GitHub Desktop.
Auto-pause players on pulseaudio sink remove
#!/bin/bash
LANG=C pactl subscribe | grep --line-buffered "Event 'remove' on sink" | xargs -L1 playerctl -a pause
@ouuan
Copy link
Author

ouuan commented Jun 12, 2021

You can change "Event 'remove' on sink" according to your use case. Run pactl subscribe and then plug/unplug your headphone, etc. to see what it outputs.

On my laptop, remove and new works fine for the bluetooth headphone, but it doesn't work for my 3.5mm earphone, when which is unplugged the event is change instead of remove.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment