Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a laptop which I use an external keyboard with. When I type using the external keyboard I want to use a US keyboard layout, since that's the type of external keyboard I have. On the other hand, when I type using the integrated keyboard I'd like to use a Swedish layout.

Is this possible? And how would I go about doing it?

I'm asking here as I think we'll find most Linux expertise here.

share|improve this question

migrated from serverfault.com Nov 27 '09 at 6:21

This question came from our site for professional system and network administrators.

    
honestly, this sounds more like a question for superuser.com ... –  quack quixote Nov 27 '09 at 1:44
2  
Heh, I needed this myself when pair programming--I use a Japanese layout, and my colleague preferred the US one. Obviously, this was whilst working in Ireland... ;) –  Josh Glover Apr 17 '11 at 11:42

4 Answers 4

First, you have to find the device ID of the keyboard to change:

$ xinput -list | grep -i key
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ LITEON Technology USB Keyboard            id=9    [slave  keyboard (3)]
    ↳ LITEON Technology USB Keyboard            id=10   [slave  keyboard (3)]

Then change the layout using setxkbmap:

$ setxkbmap -device 9 dvorak

Some versions of setxkbmap need a '-layout' argument:

$ setxkbmap -device 9 -layout dvorak
share|improve this answer
    
Hi there, I did this and it works great for everything but the arrow keys and other directional keys (which no longer work at all). It could be that the keyboard is one of those ergonomic ones that have funky key mappings...any idea how to get those working again? –  btelles Nov 3 '11 at 13:12
2  
P.S. I had to use setxkbmap -device 9 -layout dvorak (with the 'layout' option)...just putting 'dvorak' with out 'layout' caused an argument error. –  btelles Nov 3 '11 at 13:13
3  
So what's the best way to set this configuration at boot instead of having to manually invoke setxkbmap? –  Richard Turner Jun 25 '13 at 10:53

I can positively say that what you want to do is indeed possible. I achieved the specified scenario by first

sudo cat /dev/input/event(0,1,2..)

while typing on each keyboard to ensure that they were recognized as separate devices. Then I simply applied trial-and-error, experimenting with

setxkbmap -device (1-x) us.

I discovered that setxkbmap -device 1 us configured both (all) keyboards, while setxkbmap -device 6 us only affected the secondary. Of relevance is perhaps that they both were connected via PS/2.

This of course is not guaranteed to work for you, and doesn't even classify as a proper answer, but it confirms that it's at all possible. I don't know according to which scheme the individual keyboards are named in /dev/input, but I'm sure that the names can be specified in udev, making it possible to put the appropriate setxkbmap command in /etc/rc.local or similar.

share|improve this answer

It might be possible, judging by the -device argument to setxkbmap:

       -device device
               Specifies the numeric device id of the input device to be
               updated with the new keyboard layout. If not specified, the
               core keyboard device of the X server is updated.

Naturally, however, I do not have a second keyboard to try it at the moment.

-A Dvorak user

share|improve this answer
    
Hmph. -device 0 switches both, -device 2 (should be the on-board keyboard per Arkenklo's answer) doesn't switch anything, at least on my laptop and USB keyboard. –  Tommy McGuire Dec 4 '09 at 0:19

I don't think you can do this exactly the way you want. There are two options that I know of:

1) You can make switching a simple mouse click / keystroke.

With Ubuntu / GNOME:

Mouse Click

In Ubuntu / Gnome, providing you have your input layouts setup, go to an empty spot on your panel, right click and click 'Add to Panel'. Select 'Keyboard Indicator' to add this to the panel. That should input a tiny little piece of text indicating your keyboard layout and you can click this to switch.

Keyboard shortcut

System -> Preferences -> Keyboard -> Layouts -> Layout Options

There's an option there "Key(s) to change layout". You can set it to Alt+Shift, which shouldn't disturb any normal keyboard shortcuts.

I presume there is a KDE way of doing that also.

2) The other alternative is http://en.wikipedia.org/wiki/Xneur, but I am not sure if this is available for Swedish and it may not be possible for languages which have similar constructs to English.

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.