Page 1 of 1

Keyboard Layout Switch

Posted: Sun Oct 25, 2015 6:09 am
by machinebacon
Nothing big, just a special case situation. Imagine you have a laptop with Japanese keyboard. Whenever a US keyboard is plugged, the layouts won't match. This script will help you fix it quickly (call it from ~/.xinitrc):

Code: Select all

#!/bin/bash
setxkbmap jp & # set JP first
keyb=`lsusb | grep Keyboard`
[ -n "$keyb" ] && setxkbmap us & # set US if USB keyboard found
If you write an udev rule for it, the script can be run whenever the device is plugged in.

Re: Keyboard Layout Switch

Posted: Sun Oct 25, 2015 8:29 am
by simgin
^ Scriptmaster Bacon :)
Nice one, thank you.

Re: Keyboard Layout Switch

Posted: Sun Oct 25, 2015 4:26 pm
by rust collector
aah, that is very cool!