Created
April 30, 2023 08:44
-
-
Save nicolargo/7e7a455a6d86bcd027d68a7347c36380 to your computer and use it in GitHub Desktop.
Change automaticaly the Linux keyboard layout on my laptop when an external keyboard is connected/disconnected
This file contains 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
Plug your external keyboard and enter the following command line to get the vendor/product id: | |
# lsusb | |
Bus 002 Device 065: ID 05ac:024f Apple, Inc. Aluminium Keyboard (ANSI) | |
For example, my Keychron keyboard is detected as an Apple keyboard with vendorid=05ac and productid=024f | |
Create the following scripts: | |
# sudo vi /etc/udev/rules.d/10-keyboard-plug.sh | |
ACTION=="add", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="024f", ENV{XKBMODEL}="pc105", ENV{XKBLAYOUT}="us" | |
# sudo vi /etc/udev/rules.d/10-keyboard-unplug.sh | |
ACTION=="remove", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="024f", ENV{XKBMODEL}="pc105", ENV{XKBLAYOUT}="fr" | |
Note: in order to get keyboard layout configuration, use the *setxkbmap -query* command. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment