Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On my laptop the Alt and Windows keys are in the opposite positions that I'd prefer them in. Swapping them is fairly easy. However, my external (USB) keyboard has the Alt and Windows keys in the order I prefer, meaning when I switch over to the external keyboard I have the unpreferable keyboard arrangement.

Is there some manner of Linux-y voodoo I can invoke to detect whether input is coming from an external keyboard or not, and have it swap the two keys accordingly? If that's pushing it, I'd settle for a way to detect when an external keyboard is plugged in. Or are there any other reasonable solutions that I haven't considered?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

You can have entirely different layout settings for every keyboard you connect; the Unreliable Guide to xkb configuration might be helpful. In your case, you might get by with "Doing it the easy way" therein.

Be advised, though, that the guide was written at a time when the X server had a config file that was honoured. Since then, configuration of the keyboard has moved at least into HAL and back out again, so heaven knows where you have to put your extra Options "XkbOptions" "..." when it's a new moon now.

If all else fails and your X is sufficiently recent, yes, get the device number from xinput list and call setxkbmap -device ... ..., call it in your X startup file and maybe also look at udev to be notified when that keyboard is plugged in.

share|improve this answer
    
Thanks! This should be enough to put me well on my way. –  noffle Mar 22 '12 at 13:09

You can use xinput list to check for an external keyboard.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.