Last active
June 18, 2021 07:15
-
-
Save ouuan/c7b313afef9f3506aadb259cb794d399 to your computer and use it in GitHub Desktop.
Auto-pause players on pulseaudio sink remove
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LANG=C pactl subscribe | grep --line-buffered "Event 'remove' on sink" | xargs -L1 playerctl -a pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can change
"Event 'remove' on sink"
according to your use case. Runpactl subscribe
and then plug/unplug your headphone, etc. to see what it outputs.On my laptop,
remove
andnew
works fine for the bluetooth headphone, but it doesn't work for my 3.5mm earphone, when which is unplugged the event ischange
instead ofremove
.