0

I have an issue with keyboard shortcuts conflict (an event is triggered upon a key press instead of release). (This is a very old issue which is common for users using 2 or more keyboard layouts).

An X server patch exists for this issue. I'd like to apply it but I'm not sure how to properly do that.

The solution from this comment:

As an ordinary Gentoo Linux user, I:
- download patch attached to this issue named "The same patch, but based on 1.19.1 (fixed)" into directory /etc/portage/patches/x11-base/xorg-server/
- run emerge xorg-server to reinstall Xorg with this patch applied
- restart X to enjoy working hotkeys :)

Question: How do you (properly) patch the X server on Ubuntu? (I'm currently using Ubuntu 24.04.)

ENIAC
  • 1,051

1 Answers1

1

In terminal:

  1. Get the sources with git clone https://gitlab.freedesktop.org/xorg/xserver

  2. Enter the cloned directory cd xserver

    • (optional): you might want to switch the code to some release branch with git checkout branch-name. Doesn't matter much in terms of stability because xserver has very little devel activity these days (because people mostly moved to Wayland). But if the patch doesn't apply, you might have to switch to some older branch.
  3. Put the patch to the current dir (e.g. by downloading with wget url-to-the.patch)

  4. Apply it: git am -3 your.patch.

    Worth noting here, sometimes people mistakenly call "patch" what is actually a diff. The big difference is that α) git-am will throw a file-format error β) applying a diff works worse than a patch because git can't look down the history for renames and other changes that might have messed up the application of the diff but in a way that git could handle just fine.

    git apply your.diff has to be used if it's actually a diff and not a patch.

Note that patch/diff application may fail if the code it's being applied to has changed. Two things you can do in this case: 1. Resolve conflicts manually 2. Use git checkout … to find a version of XServer that works.

Further steps are out of scope of your question, but basically you then have to compile xserver with meson setup build --prefix=/usr […other options…] && ninja -C build, make a package of it (it's important, because otherwise a system update might overwrite files), then install it. Don't forget during meson configuration to pass --prefix=/usr option (like in the previous sentence). For an example of script that creates a package out of the build you can look the bottom of this answer, alternatively you can use checkinstall. For an example of meson-configuration options in XServer you can look up this block.

Hi-Angel
  • 4,810