Automatic Mute Speakers When Headphones are Unplugged
I listen to music almost any time I am on my computer. I often accidentally unplug my headphones. This has resulted in disturbing others around me. Does any one know of a way to mute the speakers (and potentiality pause VLC) when headphones are unplugged?
I would like to do this on my Laptop. It is an Acer Aspire One D150. The speakers are built-in to the computer. My headphones are standard 1/8 in which connect through the headphone jack.
Solution 1:
Just had the same problem and made a small script for it, really late but I thought I'd share it anyway
in /etc/acpi/events/
make a file headphone-plug
with contents:
event=jack/headphone
action=/usr/local/bin/headphone-plug.sh %e
this will run the script in 'action' when a plug event occurs
create /usr/local/bin/headphone-plug.sh
with content:
#!/bin/bash
case "$3" in
unplug)
su [USER] -c "DISPLAY=:0 xdotool key XF86AudioMute"
;;
esac
and make it executable.
It's a bit of a hack, as this will only work for a single user on a single x session. But it's enough for me