Skip to content

Instantly share code, notes, and snippets.

@lu0
Created June 20, 2021 16:33
Show Gist options
  • Save lu0/fd4a22d6869edab2592173f691043195 to your computer and use it in GitHub Desktop.
Save lu0/fd4a22d6869edab2592173f691043195 to your computer and use it in GitHub Desktop.
Enable micmute button on the Thinkpad Compact USB Keyboard with Trackpoint
#!/bin/bash
# The micmute (Fn+F4) button of the Thinkpad Compact USB Keyboard
# doesn't work out of the box as its keycode (248) is outside the
# range of the X server, therefore it is not recognizable with xev.
#
# This script enables the button by connecting to the acpid socket
# to catch the acpi event and then simulate the keypress on the X server.
#
# With this running at startup, we don't need to toggle the mic with
# alsa/pulseaudio, nor do we need to implement hacky workarounds
# to toggle the LED on the internal keyboard.
#
# Lucero Alvarado
# <https://github.com/lu0>
coproc acpi_listen
trap 'kill $COPROC_PID' EXIT
while read -u "${COPROC[0]}" -a event; do
[ "${event[0]}" = 'button/micmute' ] \
&& xdotool key XF86AudioMicMute
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment