Difference between revisions of "Microphone Mute Button"
(â†Created page with '== General == Some Thinkpads come with a Microphone Mute Button possibly with an led. The Microphone Mute Button on the T410 and T410s does not work on Ubuntu 10.10 an...') |
(→F20: Explanation about the ACPI mapping.) |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
Some Thinkpads come with a Microphone Mute Button possibly with an led. | Some Thinkpads come with a Microphone Mute Button possibly with an led. | ||
− | + | It does not work on Ubuntu, a bug has been reported and a patch has been proposed: https://bugs.launchpad.net/ubuntu/+source/udev/+bug/408903 | |
− | https://bugs.launchpad.net/ubuntu/+source/ | + | |
+ | If you don't have {{path|/sys/devices/platform/thinkpad_acpi/leds/tpacpi::micmute}}, you'll need to patch your kernel with | ||
+ | [http://permalink.gmane.org/gmane.linux.drivers.platform.x86.devel/1962 this patch]. | ||
== Workaround using acpid == | == Workaround using acpid == | ||
− | Pressing the mic mute | + | Pressing the mic mute button will generate a acpi event |
− | $ | + | $ acpi_listen |
+ | button/micmute MICMUTE 00000080 00000000 K | ||
+ | Depending on your model and your version of acpid it may generate a different event | ||
+ | $ acpi_listen | ||
ibm/hotkey HKEY 00000080 0000101b | ibm/hotkey HKEY 00000080 0000101b | ||
− | add a acpid rule to handle this event in {{ | + | add a acpid rule to handle this event in {{path|/etc/acpi/events/lenovo-mutemic}}: |
− | event= | + | event=button/micmute MICMUTE 00000080 00000000 K |
action=/etc/acpi/lenovo-mutemic.sh | action=/etc/acpi/lenovo-mutemic.sh | ||
− | the script ({{path|/etc/acpi/lenovo-mutemic.sh} to toggle the mice look like this: | + | the script ({{path|/etc/acpi/lenovo-mutemic.sh}}) to toggle the mice look like this: |
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
Line 31: | Line 36: | ||
fi | fi | ||
</pre> | </pre> | ||
+ | Explanation: | ||
+ | * <tt>led</tt> contain the path to the led in the mute button (see below) | ||
+ | * <tt>user</tt> is the name of the user, which is currently signed in in X11 and <tt>notify-send</tt> will send a notification to that user. Remove these lines if you don't like it. | ||
+ | * Pressing the button will toggle the state of the ALSA capture device, which is maybe not optimal in all cases as it disables all capture devices. <tt>Mic</tt> would be another choice, but on some thinkpads it is named <tt>Internal Mic</tt>. | ||
+ | |||
+ | ALSA will not remember the state of the led at startup, so one need another small start-up script: | ||
+ | <pre> | ||
+ | #!/bin/bash | ||
+ | |||
+ | led="/sys/devices/platform/thinkpad_acpi/leds/tpacpi::micmute/brightness" | ||
+ | if [[ $(amixer sget Capture) == *"[off]"* ]]; then | ||
+ | [[ -f $led ]] && echo 1 > $led | ||
+ | fi | ||
+ | </pre> | ||
+ | and put it in {{path|/etc/local.d/lenovo-mutemic.sh}}. | ||
+ | |||
+ | == F20 == | ||
+ | |||
+ | If you have a recent version of udev/systemd (see [http://cgit.freedesktop.org/systemd/systemd/commit/keymaps?id=1563c0c35a8005f5b71f04abe32c95d849efb420 this patch]) the acpi trick will not work. The mic mute button will be mapped to F20 (keycode 190), which you should be able to configure normally using the GNOME keyboard settings or similar. | ||
+ | The ACPI mapping is defined in {{path|/lib/udev/keymaps/module-lenovo}}, there you can see if 0x1A is mapped to micmute or F20. | ||
==Needed for models== | ==Needed for models== | ||
{{T410}}, {{T410s}}, {{X230}} | {{T410}}, {{T410s}}, {{X230}} |
Latest revision as of 20:42, 10 January 2014
General
Some Thinkpads come with a Microphone Mute Button possibly with an led.
It does not work on Ubuntu, a bug has been reported and a patch has been proposed: https://bugs.launchpad.net/ubuntu/+source/udev/+bug/408903
If you don't have /sys/devices/platform/thinkpad_acpi/leds/tpacpi::micmute, you'll need to patch your kernel with this patch.
Workaround using acpid
Pressing the mic mute button will generate a acpi event
$ acpi_listen button/micmute MICMUTE 00000080 00000000 K
Depending on your model and your version of acpid it may generate a different event
$ acpi_listen ibm/hotkey HKEY 00000080 0000101b
add a acpid rule to handle this event in /etc/acpi/events/lenovo-mutemic:
event=button/micmute MICMUTE 00000080 00000000 K action=/etc/acpi/lenovo-mutemic.sh
the script (/etc/acpi/lenovo-mutemic.sh) to toggle the mice look like this:
#!/bin/bash led="/sys/devices/platform/thinkpad_acpi/leds/tpacpi::micmute/brightness" user=$(who | awk '/0\.0/{print $1; exit;}') [[ -z $user ]] && user=root if [[ $(amixer sget Capture) == *"[on]"* ]]; then logger "Microphone is now muted (for $user) $USER" amixer sset Capture nocap [[ -f $led ]] && echo 1 > $led sudo -u $user DISPLAY=":0.0" notify-send -i microphone-sensitivity-muted-symbolic "Microphone" "Microphone is now <b>MUTED</b>" else logger "Microphone is now on (for $user)" amixer sset Capture cap [[ -f $led ]] && echo 0 > $led sudo -u $user DISPLAY=":0.0" notify-send -i microphone-sensitivity-high-symbolic "Microphone" "Microphone is now <b>ON</b>" fi
Explanation:
- led contain the path to the led in the mute button (see below)
- user is the name of the user, which is currently signed in in X11 and notify-send will send a notification to that user. Remove these lines if you don't like it.
- Pressing the button will toggle the state of the ALSA capture device, which is maybe not optimal in all cases as it disables all capture devices. Mic would be another choice, but on some thinkpads it is named Internal Mic.
ALSA will not remember the state of the led at startup, so one need another small start-up script:
#!/bin/bash led="/sys/devices/platform/thinkpad_acpi/leds/tpacpi::micmute/brightness" if [[ $(amixer sget Capture) == *"[off]"* ]]; then [[ -f $led ]] && echo 1 > $led fi
and put it in /etc/local.d/lenovo-mutemic.sh.
F20
If you have a recent version of udev/systemd (see this patch) the acpi trick will not work. The mic mute button will be mapped to F20 (keycode 190), which you should be able to configure normally using the GNOME keyboard settings or similar.
The ACPI mapping is defined in /lib/udev/keymaps/module-lenovo, there you can see if 0x1A is mapped to micmute or F20.