Skip to content

Instantly share code, notes, and snippets.

@DeckerSU
Created November 10, 2022 15:39
Show Gist options
  • Save DeckerSU/6367eaa78752f244486187859ff8619d to your computer and use it in GitHub Desktop.
Save DeckerSU/6367eaa78752f244486187859ff8619d to your computer and use it in GitHub Desktop.
evdev:input:b0003v05ACp0250*
KEYBOARD_KEY_70068=insert # F13: Insert
KEYBOARD_KEY_7006a=sysrq # F15: PrinScr / SysRq
evdev:input:b0003v05ACp026C*
KEYBOARD_KEY_70068=insert # F13: Insert
KEYBOARD_KEY_7006a=sysrq # F15: PrinScr / SysRq
KEYBOARD_KEY_700e2=leftmeta # key marked left alt -> left meta
KEYBOARD_KEY_700e3=leftalt # key marked left meta -> left alt
@DeckerSU
Copy link
Author

DeckerSU commented Nov 10, 2022

sudo apt install evtest
sudo evtest

Choose keyboard:

Select the device event number [0-18]: 3
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x5ac product 0x26c version 0x110
Input device name: "Apple Inc. Magic Keyboard with Numeric Keypad"

F18-F19 buttons:

Event: time 1668094994.574162, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7006d
Event: time 1668094994.574162, type 1 (EV_KEY), code 188 (KEY_F18), value 0
Event: time 1668094994.574162, -------------- SYN_REPORT ------------
Event: time 1668094994.630152, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7006e
Event: time 1668094994.630152, type 1 (EV_KEY), code 189 (KEY_F19), value 0
Event: time 1668094994.630152, -------------- SYN_REPORT ------------

So, to make F19 works as an euro symbol, according to keyboard-keys-from-name.h we need append 98-apple-keyboard.hwdb by following:

# KEYBOARD_KEY_7006d=dollar      # key marked F18 -> dollar
# KEYBOARD_KEY_7006e=euro        # key marked F19 -> euro

Then:

sudo udevadm hwdb --update
sudo udevadm trigger

@DeckerSU
Copy link
Author

@DeckerSU
Copy link
Author

DeckerSU commented Jan 18, 2023

Solution with hid_apple module:

echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode # one-time changes
echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf # permanent changes
# create /etc/udev/hwdb.d/98-apple-keyboard.hwdb
sudo udevadm hwdb --update
sudo udevadm trigger
sudo update-initramfs -u -k all # needed for 
sudo reboot

Solution with systemd:

  1. Create a new file for SystemD to start.
gedit /usr/lib/systemd/system/mac-keyboard.service

Ensure the file contains the following

[Unit]
 Description=mac-keyboard
[Service]
 Type=oneshot
 ExecStart=/bin/sh -c "echo 2 > /sys/module/hid_apple/parameters/fnmode"
 ExecStop=/bin/sh -c "echo 1 > /sys/module/hid_apple/parameters/fnmode"
 RemainAfterExit=yes
[Install]
 WantedBy=multi-user.target
  1. Reload SystemD to read your new file
systemctl --system daemon-reload
  1. Start the SystemD service.
systemctl start mac-keyboard.service
  1. Enable service to start on boot.
systemctl enable mac-keyboard.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment