Score:2

How to make ubuntu respect my choice of keyboard layout when keyboard is replugged

cn flag

I've found that if I disconnect my USB keyboard and reconnects it it seem to resort to using "standard" US layout, but I want US intl. layout (the same layout as in windows). In order to make that happen I have to after I reconnect the keyboard select another layout and then US intl. which is rather annoying since it means that I have to do this rain-dance each time I connect the keyboard (besides I also have to have another keyboard layout installed that I don't intend to use, but have to have in order to change the layout).

I've tried to run dpkg-reconfigure keyboard-configuration, but with no luck.

Before I disconnect the keyboard, with appropriate keymap I get:

> cat /etc/default/keyboard 
# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT="intl"
XKBOPTIONS="lv3:ralt_switch"

BACKSPACE="guess"

> localectl status
   System Locale: LANG=en_US.UTF-8
                  LANGUAGE=en_US:en
                  LC_NUMERIC=sv_SE.UTF-8
                  LC_TIME=sv_SE.UTF-8
                  LC_MONETARY=sv_SE.UTF-8
                  LC_PAPER=sv_SE.UTF-8
                  LC_NAME=sv_SE.UTF-8
                  LC_ADDRESS=sv_SE.UTF-8
                  LC_TELEPHONE=sv_SE.UTF-8
                  LC_MEASUREMENT=sv_SE.UTF-8
                  LC_IDENTIFICATION=sv_SE.UTF-8
       VC Keymap: n/a
       X11 Layout: us
       X11 Model: pc105
       X11 Variant: intl
       X11 Options: lv3:ralt_switch

> setxkbmap -print
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "pc+us(intl)+inet(evdev)+level3(ralt_switch)"   };
    xkb_geometry  { include "pc(pc105)" };
};

But after disconnecting the keyboard and reconnecting it gives:

> localectl status
   System Locale: LANG=en_US.UTF-8
          LANGUAGE=en_US:en
          LC_NUMERIC=sv_SE.UTF-8
          LC_TIME=sv_SE.UTF-8
          LC_MONETARY=sv_SE.UTF-8
          LC_PAPER=sv_SE.UTF-8
          LC_NAME=sv_SE.UTF-8
          LC_ADDRESS=sv_SE.UTF-8
          LC_TELEPHONE=sv_SE.UTF-8
          LC_MEASUREMENT=sv_SE.UTF-8
          LC_IDENTIFICATION=sv_SE.UTF-8
   VC Keymap: n/a
  X11 Layout: us
   X11 Model: pc105
 X11 Variant: intl
 X11 Options: lv3:ralt_switch
> setxkbmap -print
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "pc+us(altgr-intl)+inet(evdev)+level3(ralt_switch)" };
    xkb_geometry  { include "pc(pc105)" };
};

> gsettings get org.gnome.desktop.input-sources sources
[('xkb', 'se+dvorak'), ('xkb', 'se'), ('xkb', 'us')]

I note that localectl status doesn't seem to tell the truth here. setxkbmap -print however seem to tell that the keymap is no longer the same (and not what I think I requested in /etc/default/keymap)

It turned out that there were two places that one could configure the layout: in Settings > Keyboard > Layout and in the thingy on the statusline where you can switch current layout has Configuration > Input Methods. It turned out that the former contained a layout that I didn't want. Setting the layout there to to use US intl seemed to solve my problem.

Now the remaining question is more of curiosity, some explanation of this behavior (why, how etc). Should I take further action?

Gunnar Hjalmarsson avatar
uz flag
My first thought is that you should have exactly the variant you want to use in `/etc/default/keyboard` (or the `localectl` output). Please note that there are quite a few English US variants, and that `altgr-intl` is not the same as `intl`.
skyking avatar
cn flag
@GunnarHjalmarsson Thanks, it seem to be that `intl` is the layout I want, but changing so that `/etc/default/keyboard` points to that doesn't seem to solve the issue here (although `localectl` seem to say that it is)
skyking avatar
cn flag
For some (to me unknown) reason there's TWO places where one can configure the keyboard layout. First there's Settings > Keyboard > Layout, but also there's in the language/layout selection on the statusbar that has Configuration > Input Methods. I guess these would need to be kept in sync or Murphy's law will make Ubuntu chose the configuration you don't want:(
Gunnar Hjalmarsson avatar
uz flag
Good that you figured it out. This part: "the thingy on the statusline where you can switch current layout has Configuration > Input Methods" confuses me, though. As far as I know the input source indicator in the top bar does not have any "Configuration" option. Maybe you can show a screenshot or something?
skyking avatar
cn flag
I right clicked on it and there's preferences which brings up a window called "IBus Preferences" where there is a Input Method tab where I can add layouts.
Gunnar Hjalmarsson avatar
uz flag
In that case you are not on standard Ubuntu, right? Ubuntu Budgie maybe?
skyking avatar
cn flag
Standard Ubuntu 22.04 LTS, but using xfce if that matters
Gunnar Hjalmarsson avatar
uz flag
Actually it matters a lot!! If you had mentioned that in your question or via a tag, some confusion during our conversation could have been avoided.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.