Created
December 12, 2021 06:47
-
-
Save rbreaves/da3bef57a03e4d38d53cea2d46b6ab9e to your computer and use it in GitHub Desktop.
Remap USB keyboards on Linux to be like an Apple Keyboard - swaps Alt/Win(Super)
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
sudo apt install evtest | |
sudo evtest | |
----------------------------------- No device specified, trying to scan all of /dev/input/event* | |
Available devices: | |
/dev/input/event0: Lid Switch | |
/dev/input/event1: Video Bus | |
/dev/input/event2: gpio-keys | |
/dev/input/event3: gpio-keys | |
/dev/input/event4: HDA Intel PCH Mic | |
/dev/input/event5: HDA Intel PCH Headphone | |
/dev/input/event6: HDA Intel PCH HDMI/DP,pcm=3 | |
/dev/input/event7: HDA Intel PCH HDMI/DP,pcm=7 | |
/dev/input/event8: HDA Intel PCH HDMI/DP,pcm=8 | |
/dev/input/event9: HDA Intel PCH HDMI/DP,pcm=9 | |
/dev/input/event10: HDA Intel PCH HDMI/DP,pcm=10 | |
/dev/input/event11: IPTS Touch | |
/dev/input/event12: IPTS Stylus | |
/dev/input/event13: Brydge 12.3 Pro+ Keyboard | |
/dev/input/event14: Brydge 12.3 Pro+ Mouse | |
/dev/input/event15: Brydge 12.3 Pro+ | |
Select the device event number [0-15]: | |
------------------------ | |
Left Alt key pressed | |
Event: time 1639287706.517273, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e2 | |
Event: time 1639287706.517273, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 1 | |
Event: time 1639287706.517273, -------------- SYN_REPORT ------------ | |
Event: time 1639287706.719758, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e2 | |
Event: time 1639287706.719758, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 0 | |
Left Win key pressed | |
Event: time 1639288037.957455, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e3 | |
Event: time 1639288037.957455, type 1 (EV_KEY), code 125 (KEY_LEFTMETA), value 1 | |
Event: time 1639288037.957455, -------------- SYN_REPORT ------------ | |
Event: time 1639288038.058736, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e3 | |
Event: time 1639288038.058736, type 1 (EV_KEY), code 125 (KEY_LEFTMETA), value 0 | |
Left Ctrl key pressed | |
Event: time 1639288466.378348, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0 | |
Event: time 1639288466.378348, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0 | |
Event: time 1639288466.378348, -------------- SYN_REPORT ------------ | |
Event: time 1639288466.761341, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0 | |
Event: time 1639288466.761341, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1 | |
------------------------------------------- | |
git clone https://github.com/stefansaraev/keytable | |
cd ./keytable | |
make | |
# Remap Alt to Win | |
sudo ./keytable -k 0x700e2=125 --device /dev/input/event13 | |
# Remap Win to Alt | |
sudo ./keytable -k 0x700e3=56 --device /dev/input/event13 |
Will need to update this so that this fix gets applied on the USB keyboard always. (disconnects and reconnects causes it to lose the setting)
https://unix.stackexchange.com/questions/65891/how-to-execute-a-shellscript-when-i-plug-in-a-usb-device
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is useful for if you want Kinto.sh to use the "Apple" keyboard layout instead so that you can remote into macOS with the right keyboard layout, so that you will not need to re-arrange your key layout any on macOS.
The built in laptop keyboards can be remapped as well via setkeycodes
On windows you would use Sharpkeys and a file from kinto. https://github.com/rbreaves/kinto/blob/master/windows/WinToMac_AltWin_swap.skl?raw=true