Skip to content

Instantly share code, notes, and snippets.

@zorn-v
Last active May 9, 2024 08:50
Show Gist options
  • Save zorn-v/df0dccd14af81e017fbe8a4e1523ddf5 to your computer and use it in GitHub Desktop.
Save zorn-v/df0dccd14af81e017fbe8a4e1523ddf5 to your computer and use it in GitHub Desktop.
xkb switch on release deb build
#!/bin/bash
rm -rf build
mkdir -p build
cd build
sudo apt install devscripts -y
sudo mk-build-deps -t'apt-get -y' -ir xserver-xorg-core
apt source xserver-xorg-core
SRC_DIR=`ls | cut -f1 | head -n1`
#https://bugs.freedesktop.org/show_bug.cgi?id=865
#wget -O ../xkb_switch_on_release.patch https://bugs.freedesktop.org/attachment.cgi?id=129861
patch ${SRC_DIR}/xkb/xkbActions.c < ../xkb_switch_on_release.patch || exit 1
pushd ${SRC_DIR}
dch -n ''
debuild -us -uc
popd
sudo apt purge xorg-server-build-deps devscripts --auto-remove -y
sudo dpkg -i xserver-common_*.deb
sudo dpkg -i xserver-xorg-core_*.deb
rm -rf ../build
@asavochkin
Copy link

Need also:
sudo apt install equivs

@artemkovalyov
Copy link

Set them on hold to prevent upgrading them
sudo apt-mark hold xserver-common_*
sudo apt-mark hold xserver-xorg-core_*

@zorn-v
Copy link
Author

zorn-v commented Jul 23, 2019

Set them on hold to prevent upgrading them

Nope. I do not want soft with vulnerabilites on my PC
I just run this script one more time after update X.org

Yep, not working switch kb layout on release key is better then vulnerable soft

@N0rbert
Copy link

N0rbert commented Jul 23, 2019

For anyone interested - there is my PPA with this patch from Kyak: https://launchpad.net/~nrbrtx/+archive/ubuntu/xorg-hotkeys

So on all releases from 16.04 LTS (with HWE) and upwards you have to use the simple sequence:

sudo add-apt-repository ppa:nrbrtx/xorg-hotkeys
sudo apt-get update

and then read PPA description (I'll cite it here)

This PPA contain Xorg packages with patch from from ArchLinux AUR (https://aur.archlinux.org/packages/xorg-server-bug865/) for

  • Ubuntu 16.04 LTS with xserver-xorg-hwe-16.04
  • Ubuntu 18.04 LTS
  • Ubuntu 18.04 LTS with xserver-xorg-hwe-18.04
  • Ubuntu 18.10
  • Ubuntu 19.04

They fix the corresponding bugs:

Warranty disclaimer: packages were tested in

  • 16.04 LTS with HWE (Unity, MATE, Xfce)
  • 18.04 LTS (Cinnamon, KDE, MATE, Xfce)
  • 18.10 (Cinnamon, KDE, MATE, Xfce)
  • 19.04 (Cinnamon, KDE, MATE, Unity, Xfce).
    However other desktops may have issues even after applying the patch.
    These packages do not fix problems for GNOME Shell (18.04 LTS, 18.10 and 19.04) and Unity (in 18.04 LTS and 18.10).

Install with the following command:

sudo apt-get dist-upgrade

Optionally pin (lock/hold) related packages to prevent their upgrade with:

cat <<EOF | sudo tee /etc/apt/preferences.d/pin-xorg-hotkeys
Package: *
Pin: release o=LP-PPA-nrbrtx-xorg-hotkeys
Pin-Priority: 1337
EOF

Remove with commands:

sudo apt-get install ppa-purge
sudo ppa-purge ppa:nrbrtx/xorg-hotkeys
sudo rm /etc/apt/preferences.d/pin-xorg-hotkeys

@koutsenko
Copy link

@N0rbert, how can I use your PPA on debian? It shows

E: The repository 'http://ppa.launchpad.net/nrbrtx/xorg-hotkeys/ubuntu groovy Release' does not have a Release file.

@N0rbert
Copy link

N0rbert commented Jun 19, 2020

The packages for Ubuntu 20.10 (groovy) are built. Thank you, @koutsenko .

@morozov
Copy link

morozov commented Dec 20, 2020

@N0rbert I tried to use the PPA above on Ubuntu 20.10 (GNOME) as well as building the packages myself using an approach similar to the one in this gist, but in both cases, if I chose Ctrl+Shift to switch the layout, the switch happens on keypress, not on release.

These are the installed packages:

$ apt policy xserver-xorg-core xserver-common
xserver-xorg-core:
  Installed: 2:1.20.9-2ubuntu2ppa3
  Candidate: 2:1.20.9-2ubuntu2ppa3
  Version table:
 *** 2:1.20.9-2ubuntu2ppa3 500
        500 http://ppa.launchpad.net/nrbrtx/xorg-hotkeys/ubuntu groovy/main amd64 Packages
        100 /var/lib/dpkg/status
     2:1.20.9-2ubuntu1.1 500
        500 http://us.archive.ubuntu.com/ubuntu groovy-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu groovy-security/main amd64 Packages
     2:1.20.9-2ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu groovy/main amd64 Packages
xserver-common:
  Installed: 2:1.20.9-2ubuntu2ppa3
  Candidate: 2:1.20.9-2ubuntu2ppa3
  Version table:
 *** 2:1.20.9-2ubuntu2ppa3 500
        500 http://ppa.launchpad.net/nrbrtx/xorg-hotkeys/ubuntu groovy/main amd64 Packages
        500 http://ppa.launchpad.net/nrbrtx/xorg-hotkeys/ubuntu groovy/main i386 Packages
        100 /var/lib/dpkg/status
     2:1.20.9-2ubuntu1.1 500
        500 http://us.archive.ubuntu.com/ubuntu groovy-updates/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu groovy-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu groovy-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu groovy-security/main i386 Packages
     2:1.20.9-2ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu groovy/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu groovy/main i386 Packages

Are there any known incompatibilities of this patch with certain desktop environments or versions?

@N0rbert
Copy link

N0rbert commented Dec 20, 2020

It is known that packages from my PPA and others with this patch are not compatible with GNOME Shell.

But really this means that GNOMEs Hell should be removed from the system and replaced by normal and fully-functional desktops like Cinnamon, KDE, MATE (my favorite), Xfce or Unity.

@morozov
Copy link

morozov commented Dec 20, 2020

Thanks, @N0rbert. It does work with Unity. Time to switch to another shell :-)

@ACheshirov
Copy link

It is known that packages from my PPA and others with this patch are not compatible with GNOME Shell.

But really this means that GNOMEs Hell should be removed from the system and replaced by normal and fully-functional desktops like Cinnamon, KDE, MATE (my favorite), Xfce or Unity.

I was using your patch for years on KDE but now I have switched to Gnome (Pop OS).
So, I found out that it doesn't work good. The keyboard layout switch happens on keypress instead of release. Which is kind of annoying.
There is no way to fix this for Gnome, right? I don't want to change DE because I really liked the Gnome.

@N0rbert
Copy link

N0rbert commented Dec 21, 2020

@ACheshirov I do not have solution for GNOME. We can try to contact @kyak from AUR.

@kyak
Copy link

kyak commented Dec 21, 2020

Hi guys,

(un)Fortunately, I'm not using GNOME, so I can't tell for sure.

I feel the problem might be due to that fact that GNOME now defaults to Wayland session instead of Xorg if your GPU drivers allow for that. So this might be the reason why this patch doesn't work.

That would be very funny if the same problem exists on Wayland, too!

BTW, if you're interested in an up-to-date patch for a given version of Xorg, you should explore the history of package from AUR: https://aur.archlinux.org/cgit/aur.git/log/?h=xorg-server-bug865. There you can find versions of this patch from Xorg 1.17 (from 2015) to 1.20. Some older patches are either lost or can be found in the original bug report.

@ACheshirov
Copy link

@kyak, I'm not sure that I'm using Wayland.
I think its X11.
image

@unoexperto
Copy link

Folk, does anyone have a patch for Ubuntu 22.10 ? I've been using @N0rbert PPA for years but unfortunately it doesn't have binary for Kinetic.

@zorn-v
Copy link
Author

zorn-v commented Apr 21, 2023

Did you try just my script ?
Patch is avail on same link in comment https://bugs.freedesktop.org/attachment.cgi?id=129861

@unoexperto
Copy link

@zorn-v For some reason it fails for me on command sudo mk-build-deps -t'apt-get -y' -ir xserver-xorg-core with error

mk-build-deps: Unable to install xorg-server-build-deps at /usr/bin/mk-build-deps line 468.
mk-build-deps: Unable to install all build-dep packages

@zorn-v
Copy link
Author

zorn-v commented Apr 21, 2023

Maybe some network problem ?
Logs above this error will be helpfull

@unoexperto
Copy link

@zorn-v

/tmp/xorg_patch$ sudo mk-build-deps -t'apt-get -y' -ir xserver-xorg-core
dpkg-buildpackage: info: source package xorg-server-build-deps
dpkg-buildpackage: info: source version 2:21.1.4-2ubuntu1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Equivs Dummy Package Generator <root@thinkpad>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build .
 debian/rules clean
dh clean
   dh_clean
 debian/rules binary
dh binary
   dh_update_autotools_config
   dh_autoreconf
   create-stamp debian/debhelper-build-stamp
   dh_prep
   dh_auto_install --destdir=debian/xorg-server-build-deps/
   dh_install
   dh_installdocs
   dh_installchangelogs
   dh_perl
   dh_link
   dh_strip_nondeterminism
   dh_compress
   dh_fixperms
   dh_missing
   dh_dwz
   dh_strip
   dh_makeshlibs
   dh_shlibdeps
   dh_installdeb
   dh_gencontrol
   dh_md5sums
   dh_builddeb
dpkg-deb: building package 'xorg-server-build-deps' in '../xorg-server-build-deps_21.1.4-2ubuntu1_amd64.deb'.
 dpkg-genbuildinfo --build=binary -O../xorg-server-build-deps_21.1.4-2ubuntu1_amd64.buildinfo
 dpkg-genchanges --build=binary -O../xorg-server-build-deps_21.1.4-2ubuntu1_amd64.changes
dpkg-genchanges: info: binary-only upload (no source code included)
 dpkg-source --after-build .
dpkg-buildpackage: info: binary-only upload (no source included)

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!
Selecting previously unselected package xorg-server-build-deps.
(Reading database ... 233043 files and directories currently installed.)
Preparing to unpack xorg-server-build-deps_21.1.4-2ubuntu1_amd64.deb ...
Unpacking xorg-server-build-deps (2:21.1.4-2ubuntu1) ...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  bison flex libfl-dev libfl2 quilt
Suggested packages:
  bison-doc flex-doc default-mta | mail-transport-agent graphviz procmail
The following packages will be REMOVED
  xorg-server-build-deps
The following NEW packages will be installed
  bison flex libfl-dev libfl2 quilt
0 to upgrade, 5 to newly install, 1 to remove and 4 not to upgrade.
1 not fully installed or removed.
Need to get 1,375 kB of archives.
After this operation, 4,464 kB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu kinetic/main amd64 flex amd64 2.6.4-8build2 [307 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu kinetic/main amd64 bison amd64 2:3.8.2+dfsg-1build1 [748 kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu kinetic/main amd64 libfl2 amd64 2.6.4-8build2 [10.7 kB]
Get:4 http://gb.archive.ubuntu.com/ubuntu kinetic/main amd64 libfl-dev amd64 2.6.4-8build2 [6,236 B]
Get:5 http://gb.archive.ubuntu.com/ubuntu kinetic/universe amd64 quilt all 0.66-2.1 [304 kB]
Fetched 1,375 kB in 1s (1,005 kB/s)
(Reading database ... 233047 files and directories currently installed.)
Removing xorg-server-build-deps (2:21.1.4-2ubuntu1) ...
Selecting previously unselected package flex.
(Reading database ... 233043 files and directories currently installed.)
Preparing to unpack .../flex_2.6.4-8build2_amd64.deb ...
Unpacking flex (2.6.4-8build2) ...
Selecting previously unselected package bison.
Preparing to unpack .../bison_2%3a3.8.2+dfsg-1build1_amd64.deb ...
Unpacking bison (2:3.8.2+dfsg-1build1) ...
Selecting previously unselected package libfl2:amd64.
Preparing to unpack .../libfl2_2.6.4-8build2_amd64.deb ...
Unpacking libfl2:amd64 (2.6.4-8build2) ...
Selecting previously unselected package libfl-dev:amd64.
Preparing to unpack .../libfl-dev_2.6.4-8build2_amd64.deb ...
Unpacking libfl-dev:amd64 (2.6.4-8build2) ...
Selecting previously unselected package quilt.
Preparing to unpack .../quilt_0.66-2.1_all.deb ...
Unpacking quilt (0.66-2.1) ...
Setting up flex (2.6.4-8build2) ...
Setting up quilt (0.66-2.1) ...
Setting up libfl2:amd64 (2.6.4-8build2) ...
Setting up bison (2:3.8.2+dfsg-1build1) ...
update-alternatives: using /usr/bin/bison.yacc to provide /usr/bin/yacc (yacc) in auto mode
Setting up libfl-dev:amd64 (2.6.4-8build2) ...
Processing triggers for libc-bin (2.36-0ubuntu4) ...
Processing triggers for man-db (2.10.2-2) ...
Processing triggers for install-info (6.8-6) ...
mk-build-deps: Unable to install xorg-server-build-deps at /usr/bin/mk-build-deps line 468.
mk-build-deps: Unable to install all build-dep packages

@zorn-v
Copy link
Author

zorn-v commented Apr 21, 2023

Did you add "sources" in software lists ?
/etc/apt/sources.list with like deb-src starts

@unoexperto
Copy link

unoexperto commented Apr 21, 2023

Yes, here is my sources.list

# deb cdrom:[Kubuntu 22.04 LTS _Jammy Jellyfish_ - Release amd64 (20220419)]/ jammy main multiverse restricted universe

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ kinetic main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ kinetic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ kinetic-updates main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ kinetic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://gb.archive.ubuntu.com/ubuntu/ kinetic universe
deb-src http://gb.archive.ubuntu.com/ubuntu/ kinetic universe
deb http://gb.archive.ubuntu.com/ubuntu/ kinetic-updates universe
deb-src http://gb.archive.ubuntu.com/ubuntu/ kinetic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://gb.archive.ubuntu.com/ubuntu/ kinetic multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ kinetic multiverse
deb http://gb.archive.ubuntu.com/ubuntu/ kinetic-updates multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ kinetic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://gb.archive.ubuntu.com/ubuntu/ kinetic-backports main restricted universe multiverse
deb-src http://gb.archive.ubuntu.com/ubuntu/ kinetic-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu kinetic-security main restricted
deb-src http://security.ubuntu.com/ubuntu kinetic-security main restricted
deb http://security.ubuntu.com/ubuntu kinetic-security universe
deb-src http://security.ubuntu.com/ubuntu kinetic-security universe
deb http://security.ubuntu.com/ubuntu kinetic-security multiverse
deb-src http://security.ubuntu.com/ubuntu kinetic-security multiverse

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.

@zorn-v
Copy link
Author

zorn-v commented Apr 21, 2023

I just tried on 23.04

Finished running lintian.
~/patches/xkb_patch/build

and so on

@zorn-v
Copy link
Author

zorn-v commented Apr 21, 2023

Maybe apt update ?

@zorn-v
Copy link
Author

zorn-v commented Apr 21, 2023

Also maybe you have broken /usr/bin/mk-build-deps script )

@N0rbert
Copy link

N0rbert commented Apr 22, 2023

Patched Xorg packages for kinetic (22.10) and lunar (23.04) are built in my PPA.

@uralets
Copy link

uralets commented Jul 22, 2023

Patched Xorg packages for kinetic (22.10) and lunar (23.04) are built in my PPA.

Thank you for you service.
The fact that the devs and most of the distro maintainers chose to ignore it is absolutely insane.

@unoexperto
Copy link

@N0rbert Would you be so kind to publish patch for mantic (23.10) ?

@uralets
Copy link

uralets commented Nov 22, 2023 via email

@N0rbert
Copy link

N0rbert commented Nov 22, 2023

Patched Xorg packages for mantic (23.10) are now built in my PPA. Tested only on Ubuntu MATE 23.10.

@N0rbert
Copy link

N0rbert commented May 9, 2024

@unoexperto commented on this gist.
Good morning! Any chance you could publish artifact for 24.04? :)

Patched Xorg packages for noble (24.04 LTS) are already built in my PPA.
Just tested it again only on Ubuntu MATE 24.04 LTS.

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