Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cosmic-settings: failed to get keyboard layouts after trying to add input source #74

Open
edgar-vincent opened this issue Apr 18, 2024 · 8 comments

Comments

@edgar-vincent
Copy link

In cosmic-settings, clicking on Add input source in the Input Devices section yields the following error:

  ERROR  failed to get keyboard layouts, why: Os { code: 2, kind: NotFound, message: "No such file or directory" }

I presume that this is not expected, since support for keyboard layout configuration seems to have been implemented, but I may be wrong.

Thanks!

@man0lis
Copy link
Contributor

man0lis commented Jun 28, 2024

I was told keyboard layout settings should work, so I looked into this issue.

The problem is, that the xkb-data crate used by cosmic-settings, checks a hard coded path for the base.xml that lists available keyboard layouts. The hard coded path is /usr/share/X11/xkb/rules/base.xml which is not nixos compatible.

A very hacky workaround to fix this would be the following:

sudo mkdir -p /usr/share/X11/xkb/rules/
sudo ln -s "$(nix-build --no-out-link '<nixpkgs>' -A xkeyboard_config)/share/X11/xkb/rules/base.xml" /usr/share/X11/xkb/rules/base.xml

After running this the input source options work for me, but don't use this as a permanent solution.

I prepared a patch for xkb-data to make the base.xml path configurable via an environment variable. man0lis/xkb-data@47c87c4

If there are no objections, I will open a pull request.

EDIT:
opened PR pop-os/xkb-data#3

EDIT2:
I'm currently using this in my configuration.nix to work around the problem:

systemd.tmpfiles.rules = [
  "L /usr/share/X11/xkb/rules/base.xml - - - - ${pkgs.xkeyboard_config}/share/X11/xkb/rules/base.xml"
];

EDIT3:
updated the xkb-data PR to reflect recent changes

@edgar-vincent
Copy link
Author

edgar-vincent commented Jun 29, 2024

I was wondering whether it was a hard coded path somewhere. Thanks a lot for looking into this and for the patch, @man0lis!

Meanwhile, something like this also works:

# ~/.config/cosmic/com.system76.CosmicComp/v1/
(
    rules: "",
    model: "",
    layout: "fr",
    variant: "oss",
    options: Some(",compose:rctrl,caps:escape"),
)

@man0lis
Copy link
Contributor

man0lis commented Jul 1, 2024

This issue also affects cosmic-greeter.
The keyboard layout selection on the loginscreen does not work.

@onsails
Copy link

onsails commented Aug 13, 2024

anyone figured out how to set a keyboard shortcut to switch input sources?

@man0lis
Copy link
Contributor

man0lis commented Aug 20, 2024

pop-os/xkb-data#3 got merged and version 0.2.1 of xkb-data with the patch was released. We can now add a wrapper for the affected binaries which correctly sets X11_BASE_RULES_XML and X11_EXTRA_RULES_XML environment variables. (or set them globally, not sure about that one). With that, as soon as cosmic-settings and cosmic-greeter start using the new version of xkb-data, the problems should be gone.

@jilinoleg
Copy link

jilinoleg commented Aug 29, 2024

anyone figured out how to set a keyboard shortcut to switch input sources?

@onsails, If you edit ~/.config/cosmic/com.system76.CosmicComp/v1/xkb_config manually, you can use something like this:

(
    rules: "",
    model: "pc104",
    layout: "us,ru",
    variant: "",
    options: Some("terminate:ctrl_alt_bksp,grp:alt_shift_toggle"),
    repeat_delay: 600,
    repeat_rate: 25,
)

The key lines here are layout (put codes for your layouts of choice), and "grp" in options. My example is for Alt+Shift key combination, there is also an option for Win+Space, grp:win_space_toggle, and grp:caps_toggle for using CapsLock key.

@man0lis
Copy link
Contributor

man0lis commented Sep 16, 2024

The problem is now fixed for cosmic-settings. cosmic-greeter, cosmic-applet-input-sources and cosmic-applet-tiling still use version 0.1 of xkb-data and should start working as soon as upstream bumps them to 0.2.1 or higher.

joshuamegnauth54 added a commit to joshuamegnauth54/cosmic-applets that referenced this issue Nov 22, 2024
Closes: pop-os#725

The inputs applet uses an outdated `xkb-data` which causes some configs
to fail which in turn leads to an empty list.

See: lilyinstarlight/nixos-cosmic#74 (comment)
joshuamegnauth54 added a commit to joshuamegnauth54/cosmic-greeter that referenced this issue Nov 22, 2024
Closes: #1160

See these for more info:
* pop-os/cosmic-applets#725
* lilyinstarlight/nixos-cosmic#484
* lilyinstarlight/nixos-cosmic#74

Also, thanks to @Thatoo for all of the help in figuring this out!
@joshuamegnauth54
Copy link

I opened two small PRs to fix this on COSMIC's side:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants