Last active
August 21, 2020 08:04
-
-
Save toneomgomg/fa58663e0c120e940be71f954afd3508 to your computer and use it in GitHub Desktop.
Remap the function keys on MS Natural Ergonomic Keyboard 4000 to ALWAYS be function keys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Copyright (c) 2019-2020 Thomas Hellström <[email protected]> | |
# | |
# This software is released under the MIT License. | |
# https://opensource.org/licenses/MIT | |
cat <<EOF | sudo tee /etc/udev/hwdb.d/61-microsoft-natural-ergonomic-keyboard-4000.hwdb | |
#: ============================================================================ | |
#: Microsoft Natural Ergonomic Keyboard 4000 | |
#: ============================================================================ | |
evdev:input:b*v045Ep00DB* | |
# ---------------------------------------------------------------------------- | |
# | |
# Remap the utterly USELESS secondary function keys to act as normal function | |
# keys. (Seriously, Microsoft, what were you smoking?) | |
# | |
# help => f1 | |
# undo => f2 | |
# redo => f3 | |
# new => f4 | |
# open => f5 | |
# close => f6 | |
# reply => f7 | |
# fwd => f8 | |
# send => f9 | |
# spell => f10 (This one is impossible to remap with xkb without this hack) | |
# save => f11 | |
# print => f12 | |
# | |
# ---------------------------------------------------------------------------- | |
KEYBOARD_KEY_c0095=f1 | |
KEYBOARD_KEY_c021a=f2 | |
KEYBOARD_KEY_c0279=f3 | |
KEYBOARD_KEY_c0201=f4 | |
KEYBOARD_KEY_c0202=f5 | |
KEYBOARD_KEY_c0203=f6 | |
KEYBOARD_KEY_c0289=f7 | |
KEYBOARD_KEY_c028b=f8 | |
KEYBOARD_KEY_c028c=f9 | |
KEYBOARD_KEY_c01ab=f10 | |
KEYBOARD_KEY_c0207=f11 | |
KEYBOARD_KEY_c0208=f12 | |
EOF | |
# Update udevadm | |
sudo udevadm hwdb --update | |
sudo udevadm control --reload | |
# 'Unplug and replug' the keyboard | |
for X in /sys/bus/usb/devices/*; do | |
idVendor=$(cat "$X/idVendor" 2>/dev/null) | |
idProduct=$(cat "$X/idProduct" 2>/dev/null) | |
if [ "$idVendor" == "045e" ] && [ "$idProduct" == "00db" ]; then | |
sudo sh -c "echo 0 > $X/authorized" | |
sudo sh -c "echo 1 > $X/authorized" | |
fi | |
done | |
# Sing a happy song! | |
cat <<EOF | |
=============================================================================== | |
Installation done! Your function keys are now working as intended. | |
=============================================================================== | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Worked like a charm. Many thanks for this.
Microsoft makes great hardware, but they manage to mess up even the bit of firmware that runs on it.