Skip to content

Instantly share code, notes, and snippets.

@robertkirkman
Last active September 6, 2024 10:01
Show Gist options
  • Save robertkirkman/8cf5020ccbfe2118cc0972e0691d8903 to your computer and use it in GitHub Desktop.
Save robertkirkman/8cf5020ccbfe2118cc0972e0691d8903 to your computer and use it in GitHub Desktop.
Gentoo Mod: wayland-free Gentoo.

Warning

This is a downstream solution to https://bugs.gentoo.org/923305. Upstream should continue to focus on supporting systems where wayland is unmasked because this masked-wayland configuration is NOT necessary for normal users. Do not ask for support with this in Gentoo channels, instead use the comments section here.

How to use Gentoo without installing Wayland - period.

  1. Add the package.mask and package.use lines below to their respective locations in /etc/portage/
  2. Save each X-Y.patch file in a new folder in /etc/portage/patches/ following the pattern /etc/portage/patches/X/Y/ - you can reference Gentoo Package Search and Gentoo Wiki if you are unsure how to use /etc/portage/patches/
  3. Save emerge-sync-purge-wayland.sh anywhere with any filename and from now on, run it instead of emerge --sync
  4. Run emerge-sync-purge-wayland.sh, then perform a world upgrade with emerge -avuDU world followed (after the first completely successful world upgrade) by emerge -c
#!/bin/bash
# (NOBODY SHOULD COPY THIS UNLESS THEY NEVER USE WAYLAND)
emerge --sync || exit 1
unnecessarily_wayland_depending_packages=(
'guru/gnome-extra/yad'
'gentoo/media-video/obs-studio'
'gentoo/games-util/heroic-bin'
'gentoo/kde-frameworks/kauth'
'gentoo/x11-misc/pcmanfm-qt'
)
ebuild_repo_path=/var/db/repos
for package in "${unnecessarily_wayland_depending_packages[@]}"
do
for ebuild in $(find $ebuild_repo_path/$package -type f)
do
sed -i -e '/dev-libs\/wayland/d' \
-e '/kde-plasma\/layer-shell-qt/d' \
-e 's/\[wayland\]//' $ebuild
done
done
--- a/src/backends/polkit-1/Polkit1Backend.cpp
+++ b/src/backends/polkit-1/Polkit1Backend.cpp
@@ -11,7 +11,6 @@
#include "Polkit1Backend.h"
#include "kauthdebug.h"
-#include <KWaylandExtras>
#include <KWindowSystem>
#include <QCoreApplication>
@@ -66,22 +65,6 @@ void Polkit1Backend::preAuthAction(const QString &action, QWindow *parentWindow)
// Are we running our KDE auth agent?
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.kde.polkit-kde-authentication-agent-1"))) {
- if (KWindowSystem::isPlatformWayland()) {
- KWaylandExtras::exportWindow(parentWindow);
- connect(
- KWaylandExtras::self(),
- &KWaylandExtras::windowExported,
- this,
- [this, action, parentWindow](QWindow *window, const QString &handle) {
- if (window == parentWindow) {
- sendWindowHandle(action, handle);
- }
- },
- Qt::SingleShotConnection);
-
- // Generate and send an XDG Activation token.
- sendActivationToken(action, parentWindow);
- } else {
// Retrieve the dialog root window Id
const qulonglong wId = parentWindow->winId();
@@ -97,7 +80,6 @@ void Polkit1Backend::preAuthAction(const QString &action, QWindow *parentWindow)
if (reply.type() != QDBusMessage::ReplyMessage) {
qWarning() << "Failed to set window id" << wId << "for" << action << reply.errorMessage();
}
- }
} else {
qCDebug(KAUTH) << "KDE polkit agent appears too old or not registered on the bus";
}
@@ -124,33 +106,6 @@ void Polkit1Backend::sendWindowHandle(const QString &action, const QString &hand
void Polkit1Backend::sendActivationToken(const QString &action, QWindow *window)
{
- const auto requestedSerial = KWaylandExtras::lastInputSerial(window);
- connect(
- KWaylandExtras::self(),
- &KWaylandExtras::xdgActivationTokenArrived,
- this,
- [this, requestedSerial, action](quint32 serial, const QString &token) {
- if (serial != requestedSerial || token.isEmpty()) {
- return;
- }
- QDBusMessage methodCall =
- QDBusMessage::createMethodCall(c_kdeAgentService, c_kdeAgentPath, c_kdeAgentInterface, QLatin1String("setActivationTokenForAction"));
- methodCall << action;
- methodCall << token;
-
- const auto reply = QDBusConnection::sessionBus().asyncCall(methodCall);
- auto *watcher = new QDBusPendingCallWatcher(reply, this);
- connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher, token, action] {
- watcher->deleteLater();
-
- QDBusPendingReply<> reply = *watcher;
- if (reply.isError()) {
- qCWarning(KAUTH) << "Failed to set activation token" << token << "for" << action << reply.error().message();
- }
- });
- },
- Qt::SingleShotConnection);
- KWaylandExtras::requestXdgActivationToken(window, requestedSerial, {});
}
Action::AuthStatus Polkit1Backend::authorizeAction(const QString &action)
dev-libs/wayland
x11-base/xwayland
dev-util/wayland-scanner
dev-libs/wayland-protocols
kde-plasma/layer-shell-qt
*/* -wayland
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,6 @@ find_package(Qt6LinguistTools ${QT_MINIMUM_VERSION} REQUIRED)
find_package(Qt6Widgets ${QT_MINIMUM_VERSION} REQUIRED)
find_package(fm-qt6 ${LIBFMQT_MINIMUM_VERSION} REQUIRED)
find_package(lxqt2-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
-find_package(LayerShellQt ${SHELLQT_MINIMUM_VERSION} REQUIRED)
message(STATUS "Building ${PROJECT_NAME} with Qt ${Qt6Core_VERSION}")
diff --git a/pcmanfm/CMakeLists.txt b/pcmanfm/CMakeLists.txt
index c670d2d..dd98b1e 100644
--- a/pcmanfm/CMakeLists.txt
+++ b/pcmanfm/CMakeLists.txt
@@ -90,7 +90,6 @@ target_include_directories(pcmanfm-qt
target_link_libraries(pcmanfm-qt
Qt6::Widgets
Qt6::DBus
- LayerShellQtInterface
fm-qt6
)
diff --git a/pcmanfm/desktopwindow.cpp b/pcmanfm/desktopwindow.cpp
index 1deda86..cb1cd91 100644
--- a/pcmanfm/desktopwindow.cpp
+++ b/pcmanfm/desktopwindow.cpp
@@ -43,8 +43,6 @@
#include <QRandomGenerator>
#include <QToolTip>
-#include <LayerShellQt/shell.h>
-#include <LayerShellQt/window.h>
#include "./application.h"
#include "mainwindow.h"
@@ -194,23 +192,6 @@ DesktopWindow::DesktopWindow(int screenNum):
shortcut = new QShortcut(QKeySequence(Qt::SHIFT | Qt::Key_Delete), this); // force delete
connect(shortcut, &QShortcut::activated, this, &DesktopWindow::onDeleteActivated);
- // set the layer and anchors under Wayland
- if(static_cast<Application*>(qApp)->underWayland()) {
- winId();
- if(QWindow* win = windowHandle()) {
- if(LayerShellQt::Window* layershell = LayerShellQt::Window::get(win)) {
- layershell->setLayer(LayerShellQt::Window::Layer::LayerBackground);
- LayerShellQt::Window::Anchors anchors = {LayerShellQt::Window::AnchorTop
- | LayerShellQt::Window::AnchorBottom
- | LayerShellQt::Window::AnchorLeft
- | LayerShellQt::Window::AnchorRight};
- layershell->setAnchors(anchors);
- layershell->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityOnDemand);
- layershell->setExclusiveZone(-1); // not moved to accommodate for other surfaces
- layershell->setScope(QStringLiteral("desktop")); // just for distinguishing it
- }
- }
- }
}
DesktopWindow::~DesktopWindow() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment