From fbdd5e14bb17c149e3de422f68ece2c1381fa381 Mon Sep 17 00:00:00 2001 From: wheaney <42350981+wheaney@users.noreply.github.com> Date: Mon, 25 Aug 2025 17:57:49 -0700 Subject: [PATCH] Improve setup and add auto-enabling of the XR driver --- kwin/bin/breezy_kwin_uninstall | 10 ++---- kwin/bin/setup | 6 ++-- kwin/src/breezydesktopeffect.cpp | 62 +++++++++++++++++++++++++++++++- kwin/src/breezydesktopeffect.h | 1 + 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/kwin/bin/breezy_kwin_uninstall b/kwin/bin/breezy_kwin_uninstall index b16003a..b14d6de 100755 --- a/kwin/bin/breezy_kwin_uninstall +++ b/kwin/bin/breezy_kwin_uninstall @@ -47,13 +47,9 @@ if [[ -f "$CONFIG_SO" ]]; then $SUDO rm -f "$CONFIG_SO" fi -if [ -e "$XDG_BIN_HOME/xr_driver_uninstall" ]; then - [ "$for_install" -eq 0 ] && echo "Uninstalling XRLinuxDriver" - if [ "$for_install" -eq 1 ]; then - sudo $XDG_BIN_HOME/xr_driver_uninstall --for-install - else - sudo $XDG_BIN_HOME/xr_driver_uninstall - fi +if [[ -e "$XDG_BIN_HOME/xr_driver_uninstall" && "$for_install" -eq 0 ]]; then + echo "Uninstalling XRLinuxDriver" + sudo "$XDG_BIN_HOME/xr_driver_uninstall" fi # this script is self-deleting, leave this as the last command diff --git a/kwin/bin/setup b/kwin/bin/setup index 086ee50..5c70ae1 100755 --- a/kwin/bin/setup +++ b/kwin/bin/setup @@ -80,7 +80,7 @@ EOF fi # set up the XR driver using the local binary -echo "Installing xrDriver" +echo "Installing xrDriver (requires sudo)" echo "BEGIN - xr_driver_setup" if [ -z "$1" ] then @@ -89,4 +89,6 @@ else sudo bin/xr_driver_setup -v $1 $(pwd)/xrDriver.tar.gz fi -echo "END - xr_driver_setup" \ No newline at end of file +echo "END - xr_driver_setup" + +printf "\n\033[1;33m!!! IMPORTANT !!!\033[0m You must log out and back in, then enable Breezy Desktop from the Desktop Effects in System Settings\n\n" \ No newline at end of file diff --git a/kwin/src/breezydesktopeffect.cpp b/kwin/src/breezydesktopeffect.cpp index bbb294c..0399437 100644 --- a/kwin/src/breezydesktopeffect.cpp +++ b/kwin/src/breezydesktopeffect.cpp @@ -123,6 +123,8 @@ BreezyDesktopEffect::BreezyDesktopEffect() connect(m_cursorUpdateTimer, &QTimer::timeout, this, &BreezyDesktopEffect::updateCursorPos); m_cursorUpdateTimer->setInterval(16); // ~60Hz m_cursorUpdateTimer->start(); + + enableDriver(); } void BreezyDesktopEffect::setupGlobalShortcut(const BreezyShortcuts::Shortcut &shortcut, std::function triggeredFunc) { @@ -177,7 +179,6 @@ void BreezyDesktopEffect::activate() // QuickSceneEffect grabs the keyboard and mouse input, which pulls focus away from the active window // and doesn't allow for interaction with anything on the desktop. These two calls fix that. - // TODO - move away from QuickSceneEffect effects->ungrabKeyboard(); effects->stopMouseInterception(this); @@ -205,6 +206,65 @@ void BreezyDesktopEffect::deactivate() m_shutdownTimer->start(250); } +void BreezyDesktopEffect::enableDriver() +{ + qCCritical(KWIN_XR) << "\t\t\tBreezy - enableDriver"; + QByteArray homeEnv = qgetenv("HOME"); + QString program = QString::fromUtf8(homeEnv) + QStringLiteral("/.local/bin/xr_driver_cli"); + + // Helper lambda to start the second call + auto setBreezyDesktopMode = [this, program]() { + QProcess *proc2 = new QProcess(this); + proc2->setProgram(program); + proc2->setArguments({QStringLiteral("-bd")}); // change the mode to Breezy Desktop + proc2->setProcessChannelMode(QProcess::MergedChannels); + + connect(proc2, &QProcess::readyReadStandardOutput, this, [proc2]() { + const QByteArray out = proc2->readAllStandardOutput(); + if (!out.isEmpty()) { + qCInfo(KWIN_XR) << "xr_driver_cli -bd:" << out; + } + }); + connect(proc2, &QProcess::errorOccurred, this, [proc2](QProcess::ProcessError err) { + qCCritical(KWIN_XR) << "xr_driver_cli -bd error" << err << proc2->errorString(); + }); + connect(proc2, QOverload::of(&QProcess::finished), + this, [this, proc2](int code, QProcess::ExitStatus status) { + qCInfo(KWIN_XR) << "xr_driver_cli -bd exited" << code << "status" << status; + proc2->deleteLater(); + }); + + proc2->start(); + }; + + QProcess *proc1 = new QProcess(this); + proc1->setProgram(program); + proc1->setArguments({QStringLiteral("-e")}); // enable flag + proc1->setProcessChannelMode(QProcess::MergedChannels); + + connect(proc1, &QProcess::readyReadStandardOutput, this, [proc1]() { + const QByteArray out = proc1->readAllStandardOutput(); + if (!out.isEmpty()) { + qCInfo(KWIN_XR) << "xr_driver_cli -e:" << out; + } + }); + connect(proc1, &QProcess::errorOccurred, this, [proc1](QProcess::ProcessError err) { + qCCritical(KWIN_XR) << "xr_driver_cli -e error" << err << proc1->errorString(); + }); + connect(proc1, QOverload::of(&QProcess::finished), + this, [proc1, setBreezyDesktopMode](int code, QProcess::ExitStatus status) { + qCInfo(KWIN_XR) << "xr_driver_cli -e exited" << code << "status" << status; + proc1->deleteLater(); + if (status == QProcess::NormalExit && code == 0) { + setBreezyDesktopMode(); + } else { + qCCritical(KWIN_XR) << "First call failed; not starting second."; + } + }); + + proc1->start(); +} + void BreezyDesktopEffect::realDeactivate() { qCCritical(KWIN_XR) << "\t\t\tBreezy - realDeactivate"; diff --git a/kwin/src/breezydesktopeffect.h b/kwin/src/breezydesktopeffect.h index 08c2e54..c9e438a 100644 --- a/kwin/src/breezydesktopeffect.h +++ b/kwin/src/breezydesktopeffect.h @@ -66,6 +66,7 @@ namespace KWin public Q_SLOTS: void activate(); void deactivate(); + void enableDriver(); void toggle(); void recenter(); void toggleZoomOnFocus();