Skip to content

Instantly share code, notes, and snippets.

@jsfaint
Created June 20, 2014 12:33
Show Gist options
  • Save jsfaint/d9c4142416d051543604 to your computer and use it in GitHub Desktop.
Save jsfaint/d9c4142416d051543604 to your computer and use it in GitHub Desktop.
An ACPI handler, auto disable Speaker when headset plugin, enable Speaker when headset removed.

headset_hotplug

An ACPI handler, auto disable Speaker when headset plugin, enable Speaker when headset removed.

Installation

###Archlinux User makepkg -si

###Other Linux User Install acpid alsa-utils, then

cp headset_hotplug /etc/acpi/events/
cp headset_hotplug.sh /etc/acpi/actions/
event=jack/*
action=/etc/acpi/actions/headset_hotplug.sh %e
#!/bin/bash
case "$1" in
jack/headphone)
case "$3" in
plug)
amixer set Speaker mute
;;
unplug)
amixer set Speaker unmute
;;
*)
amixer set Speaker unmute
;;
esac
;;
esac
# Maintainer: Jason <jsfaint@gmail.com>
pkgname=headset_hotplug
pkgver=0.2
pkgrel=1
pkgdesc="Auto disable/enable Speaker when headset plugin/unplugin"
arch=('any')
license=("GPL")
source=("headset_hotplug" "headset_hotplug.sh")
md5sums=('e80a22a4ca1c97b5fc6d77fc7a0c5c10'
'0b8a46a4137b28f988262fca3d2a3c38')
depends=('acpid' 'alsa-utils')
package()
{
install -Dm644 ${srcdir}/headset_hotplug ${pkgdir}/etc/acpi/events/headset_hotplug
install -Dm755 ${srcdir}/headset_hotplug.sh ${pkgdir}/etc/acpi/actions/headset_hotplug.sh
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment