Created
June 8, 2019 17:24
-
-
Save BobSynfig/b27e2ed9614a837576658e0a9322b334 to your computer and use it in GitHub Desktop.
External keyboard with a different layout under Linux
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
| #!/bin/bash | |
| # String identifying the keyboard (under "Virtual core keyboard" with xinput list) | |
| EXT_KEYB_STR="NOVATEK USB Keyboard" | |
| # Taken from Command line | |
| EXT_KEYB_LANG=$1 | |
| EXT_KEYB_ID=`xinput list|grep "$EXT_KEYB_STR"|awk -F" " '{print $5}'|awk -F= '{if($2!="") print $2}'|head -n 1` | |
| # This is field #5 because (Word count of EXT_KEYB_STR + 2) --^ | |
| setxkbmap -verbose -device $EXT_KEYB_ID -layout $EXT_KEYB_LANG |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use an external keyboard with a different layout (Greek :) ).
Instead of switching all the time the lang from the keyboard shortcut, it can be defined separately.
Usage
ext-keyb grext-keyb usext-keyb frext-keyb yourLangHow to install
Download the file and make it executable (
chmod +x ./ext-keyb)Enter
xinput listand find your keyboard string under "Virtual core keyboard"Set it in EXT_KEYB_STR (mine is "NOVATEK USB Keyboard")
The field $5 in EXT_KEYB_ID could be changed if needed.
Move it to /usr/bin to be able to use it system-wide (
sudo mv ./ext-keyb /usr/bin)Hoping that it could be useful :)