diff --git a/wayland_server.cpp b/wayland_server.cpp
index 7ddb93927c..90db349f74 100644
--- a/wayland_server.cpp
+++ b/wayland_server.cpp
@@ -63,6 +63,8 @@ along with this program. If not, see .
// Qt
+#include
+#include
#include
#include
@@ -590,7 +592,13 @@ void WaylandServer::setupX11ClipboardSync()
}
);
m_xclipbaordSync.process->setProcessEnvironment(environment);
- m_xclipbaordSync.process->start(QStringLiteral(KWIN_XCLIPBOARD_SYNC_BIN));
+ // start from build directory if executable is available there (e.g. autotests), otherwise start libexec executable
+ const QFileInfo clipboardSync{QDir{QCoreApplication::applicationDirPath()}, QStringLiteral("org_kde_kwin_xclipboard_syncer")};
+ if (clipboardSync.exists()) {
+ m_xclipbaordSync.process->start(clipboardSync.absoluteFilePath());
+ } else {
+ m_xclipbaordSync.process->start(QStringLiteral(KWIN_XCLIPBOARD_SYNC_BIN));
+ }
}
}