Difference between revisions of "Microphone Mute Button"

From ThinkWiki
Jump to: navigation, search
(←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...')
 
(Workaround using acpid)
Line 9: Line 9:
 
  $ apci_listen
 
  $ apci_listen
 
  ibm/hotkey HKEY 00000080 0000101b
 
  ibm/hotkey HKEY 00000080 0000101b
add a acpid rule to handle this event in {{patch|/etc/acpi/events/lenovo-mutemic}}:  
+
add a acpid rule to handle this event in {{path|/etc/acpi/events/lenovo-mutemic}}:  
 
  event=ibm/hotkey HKEY 00000080 0000101b
 
  event=ibm/hotkey HKEY 00000080 0000101b
 
  action=/etc/acpi/lenovo-mutemic.sh
 
  action=/etc/acpi/lenovo-mutemic.sh
Line 31: Line 31:
 
fi
 
fi
 
</pre>
 
</pre>
 
+
Explanation:
 +
* <tt>led</tt> contain the path to the led in the mute botton (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>.
  
 
==Needed for models==
 
==Needed for models==
 
{{T410}}, {{T410s}}, {{X230}}
 
{{T410}}, {{T410s}}, {{X230}}

Revision as of 23:36, 14 December 2012

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 and Ubuntu 11.04. https://bugs.launchpad.net/ubuntu/+source/acpi-support/+bug/728310

Workaround using acpid

Pressing the mic mute botton will generate a acpi event

$ apci_listen
ibm/hotkey HKEY 00000080 0000101b

add a acpid rule to handle this event in /etc/acpi/events/lenovo-mutemic:

event=ibm/hotkey HKEY 00000080 0000101b
action=/etc/acpi/lenovo-mutemic.sh

the script ({{path|/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 botton (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.

Needed for models

T410, T410s, X230