Keyboard Layout Switch

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Keyboard Layout Switch

Unread post by machinebacon » Sun Oct 25, 2015 6:09 am

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.
..gnutella..

User avatar
simgin
Meme Fodder
Posts: 1167
Joined: Sun Jan 06, 2013 12:07 am
Location: Bradford-on-Avon, UK

Re: Keyboard Layout Switch

Unread post by simgin » Sun Oct 25, 2015 8:29 am

^ Scriptmaster Bacon :)
Nice one, thank you.
Someone told me that I am delusional, I almost fell off my unicorn.

User avatar
rust collector
Motörhead
Posts: 536
Joined: Mon Jan 13, 2014 3:56 pm
Location: no_nb

Re: Keyboard Layout Switch

Unread post by rust collector » Sun Oct 25, 2015 4:26 pm

aah, that is very cool!

Post Reply