Skip to content

auto mute audio when headphones are unplugged

Here is a nifty acpi script to mute audio when you unplug your headphones. Save it as ~/.unplug-mute.sh


  1 #!/bin/bash
  2 
  3 case "$1" in
  4     jack/headphone)
  5         case "$3" in
  6             plug)
  7                 amixer set Master unmute
  8                 amixer set Headphone unmute
  9             ;;
 10             unplug)
 11                 amixer set Master mute
 12             ;;
 13         esac
 14     ;;
 15 esac

Then edit /etc/acpi/events/headphone-plug to:


  1 event=jack/*
  2 action=~/.unplug-mute.sh %e

When the acpi events are detected for jack/* the above script will run. It will mute the audio when the headphones are unplugged and unmute it when they are plugged back in.

Comments are closed, but trackbacks and pingbacks are open.