OneDeadKey / kalamine

Keyboard Layout Maker
MIT License
113 stars 29 forks source link

xkalamine doesn't work with Fedora Silverblue and immutable OSes in general #180

Open axelsimon opened 4 months ago

axelsimon commented 4 months ago

xkalamine install layout.toml reasonably assumes that /usr/share/X11/xkb exists and can be written to.

These assumptions fail when it comes to Fedora Silverblue (and by extension, all the other members of the wild Universal Blue family), as /usr is read-only since the root partition is immutable. That is, after all, one of the main selling points of these OSes.

The normal approach to making any necessary changes to your immutable OS install is to either install Flatpaks to userland or to overlay rpm to the base OS image, using rpm-ostree install.

This essentially means building your own rpm to install your custom keyboard layout. At least, that's the only answer I've found so far. I have not wanted to do that so far, so I've not been able to install custom keyboard layouts (and learn them).

I'm not sure what I expect here, but I suppose my goal in opening this issue is twofold:

  1. document the fact that xkalamine doesn't know it can run on immutable OSes and that it falls apart when trying to use it to install
  2. share what I've found so far, and see if others have better options or ideas

thanks!

Ced-C commented 3 months ago

by default, when /usr/share/X11/xkb is not writable (e.g. used without sudo, immutable distro. etc.) kalamine fallbacks to userspace (i.e. installing in ~/.config/xkb/)… So I do not understand how it is not working, unless Fedora Silverblus do not support Wayland ? Userspace install only work under wayland.

Edit : it seems KDE do not support userspace install c.f. #124

axelsimon commented 3 months ago

Hmm, i just tried it again, after updating to kalamine 0.38 (via pipx in a toolbox): xkalamine apply ergol.toml

You appear to be running Wayland, which does not support this operation.

xkalamine install ergol.toml

Traceback (most recent call last):
  File "/var/home/axel/.local/bin/xkalamine", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/var/home/axel/.local/share/pipx/venvs/kalamine/lib64/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/axel/.local/share/pipx/venvs/kalamine/lib64/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/var/home/axel/.local/share/pipx/venvs/kalamine/lib64/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/axel/.local/share/pipx/venvs/kalamine/lib64/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/axel/.local/share/pipx/venvs/kalamine/lib64/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/axel/.local/share/pipx/venvs/kalamine/lib64/python3.12/site-packages/kalamine/cli_xkb.py", line 84, in install
    xkb_index = xkb_install(xkb_root)
                ^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/axel/.local/share/pipx/venvs/kalamine/lib64/python3.12/site-packages/kalamine/cli_xkb.py", line 76, in xkb_install
    xkb.update()
  File "/var/home/axel/.local/share/pipx/venvs/kalamine/lib64/python3.12/site-packages/kalamine/xkb_manager.py", line 83, in update
    update_symbols(self._rootdir, self._index)  # XKB/symbols/{locales}
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/axel/.local/share/pipx/venvs/kalamine/lib64/python3.12/site-packages/kalamine/xkb_manager.py", line 303, in update_symbols
    with path.open("w") as file:
         ^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/pathlib.py", line 1013, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/X11/xkb/symbols/fr

It's true, /usr/share/X11/xkb does not exist in Fedora Silverblue. But if i enter the toolbx (toolbx enter) and in that mutable environment manually create: /usr/share/X11/xkb /usr/share/X11/xkb/fr /usr/share/X11/xkb/symbols/ then xkalamine acts as you described:

/usr/share/X11/xkb
    Not writable: switching to user-space.

... /var/home/axx/.config/xkb/rules/evdev.xml
... /var/home/axx/.config/xkb/symbols/fr
      + fr/ergol

Successfully installed.
Warning: user-space layouts only work with Wayland.

So it looks like before realising that /usr can't be written to, xkalamine makes a hard assumption that the xkb subdirectory exists and fails if it doesn't. Hope this helps!

cfergeau commented 2 weeks ago

In addition to this, might be nice to document ~/.config/xkb install in https://github.com/OneDeadKey/kalamine?tab=readme-ov-file#linux-root-xkb_symbols as system-wide install is not an option for immutable OSes users.