Adaptitions for kWin support on Flatpak

This commit is contained in:
WarmUpTill
2026-08-17 19:31:03 +02:00
parent e11499c308
commit bc17f0c708
4 changed files with 124 additions and 20 deletions

View File

@@ -5,6 +5,7 @@
#include <QDir>
#include <QFile>
#include <QFileDevice>
#include <QStandardPaths>
#include <QTextStream>
#include <QtDBus/QDBusConnectionInterface>
#include <QtDBus/QDBusInterface>
@@ -96,12 +97,16 @@ bool isKWinAvailable()
bool startKWinScript(QString &scriptObjectPath)
{
// Not RuntimeLocation: under Flatpak, $XDG_RUNTIME_DIR is private to
// the sandbox, so the unsandboxed KWin process can't read it back.
const QString scriptPath =
"/tmp/AdvancedSceneSwitcher/KWinFocusNotifier.js";
QStandardPaths::writableLocation(
QStandardPaths::CacheLocation) +
"/AdvancedSceneSwitcher/KWinFocusNotifier.js";
const QString script =
R"(var adss = "com.github.AdvancedSceneSwitcher";
var adssPath = "/com/github/AdvancedSceneSwitcher";
R"(var adss = "com.obsproject.Studio.Plugin.SceneSwitcher";
var adssPath = "/com/obsproject/Studio/Plugin/SceneSwitcher";
function trackWindow(window) {
var id = window.internalId.toString();
@@ -129,7 +134,8 @@ workspace.windowActivated.connect(function(client) {
}))";
if (const QDir dir; !dir.mkpath(QFileInfo(scriptPath).absolutePath())) {
blog(LOG_ERROR, "error creating /tmp/AdvancedSceneSwitcher");
blog(LOG_ERROR,
"error creating KWinFocusNotifier script directory");
return false;
}
@@ -198,8 +204,10 @@ bool stopKWinScript(const QString &scriptObjectPath)
bool registerKWinDBusListener(FocusNotifier *notifier)
{
static const QString serviceName = "com.github.AdvancedSceneSwitcher";
static const QString objectPath = "/com/github/AdvancedSceneSwitcher";
static const QString serviceName =
"com.obsproject.Studio.Plugin.SceneSwitcher";
static const QString objectPath =
"/com/obsproject/Studio/Plugin/SceneSwitcher";
auto bus = QDBusConnection::sessionBus();
if (bus.objectRegisteredAt(objectPath)) {