Skip to content

Keyboard layout falls back to "us" when localed is not available, ignoring the layout X is already using #13997

Description

@Fantu

On a system without systemd there is no org.freedesktop.locale1, and Cinnamon then ends
up with us as the only input source, whatever the system is actually configured with.
With a single source there is no layout indicator in the panel and nothing for the switch
shortcut to alternate, so the user loses both.

InputSourceSettings calls loadSystemLayouts() when input-sources sources is empty
(js/ui/keyboardManager.js):

loadSystemLayouts() {
    // Set a usable default then queue loading from locale1 (/etc/default/keyboard)
    let sources = GLib.Variant.new('a(ss)', [[INPUT_SOURCE_TYPE_XKB, DEFAULT_LAYOUT]]);
    this._settings.set_value(KEY_INPUT_SOURCES, sources);

    let locale1 = new Locale1Settings();
    locale1.populateLayouts();
}

"us" is written first and is meant to be corrected asynchronously from locale1. When
locale1 is not there, populateLayouts() just logs "Could not get properties from
org.freedesktop.locale1" and returns, so the placeholder stays — and it stays in gsettings,
so it persists across sessions.

Reproducing it does not need a systemd-less install; masking localed is enough:

# systemctl mask systemd-localed.service
$ gsettings set org.cinnamon.desktop.input-sources sources "[]"
$ # restart Cinnamon
$ gsettings get org.cinnamon.desktop.input-sources sources
[('xkb', 'us')]
$ setxkbmap -query | grep layout
layout:     us,it

Note the last two lines: X already knows the right layout, Cinnamon just never asks. On
Debian/Ubuntu/Mint the same information is also in /etc/default/keyboard
(XKBLAYOUT/XKBVARIANT/XKBOPTIONS) — which is, incidentally, exactly what localed
itself reads there.

Would you take a fallback for the case where locale1 does not answer — reading
/etc/default/keyboard, or the XKB rules from the X server — instead of leaving "us"
behind? I am happy to prepare it if you tell me which of the two you would rather have.

Reported downstream as Debian bug #1130322
and Debian bug #1143945 (same
root cause, now merged): Devuan in one case, Debian with sysvinit and elogind in the other.
Cinnamon 6.6.9 is where I checked; the 6.4 code path is the same idea in
csd-keyboard-manager.c, which falls back to #define DEFAULT_LAYOUT "us" when the
localed proxy is NULL.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions