--- /dev/null
+project(plasma-wallpaper-xwallpaper)
+
+if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
+ include(FeatureSummary)
+
+ find_package(KDELibs4 4.23.0 REQUIRED)
+
+ include_directories(${KDE4_INCLUDES})
+ add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
+endif()
+
+set(xwallpaper_SRCS
+ xwallpaper.cpp
+)
+
+kde4_add_plugin(plasma_wallpaper_xwallpaper ${xwallpaper_SRCS})
+target_link_libraries(plasma_wallpaper_xwallpaper KDE4::plasma KDE4::kdeui)
+
+install(
+ TARGETS plasma_wallpaper_xwallpaper
+ DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
+)
+install(
+ FILES plasma-wallpaper-xwallpaper.desktop
+ DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
+)
--- /dev/null
+[Desktop Entry]
+Name=XScreensaver as wallpaper
+Comment=XScreensaver as wallpaper
+Type=Service
+Icon=xorg
+ServiceTypes=Plasma/Wallpaper
+
+X-KDE-Library=plasma_wallpaper_xwallpaper
+X-KDE-PluginInfo-Author=Ivailo Monev
+X-KDE-PluginInfo-Email=xakepa10@gmail.com
+X-KDE-PluginInfo-Name=org.kde.xwallpaper
+X-KDE-PluginInfo-Version=0.1
+X-KDE-PluginInfo-Website=
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
+
--- /dev/null
+/* This file is part of the KDE project
+ Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2, as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "xwallpaper.h"
+
+#include <QX11Info>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <KDebug>
+
+static const QString s_xscreensaver = QString::fromLatin1("/usr/libexec/xscreensaver/binaryring");
+static const int s_updateinterval = 100; // increase to decrease CPU usage
+
+XWallpaper::XWallpaper(QObject *parent, const QVariantList &args)
+ : Plasma::Wallpaper(parent, args),
+ m_widget(nullptr),
+ m_proc(nullptr),
+ m_timer(nullptr)
+{
+ m_widget = new QWidget(nullptr, Qt::X11BypassWindowManagerHint);
+ // move it outside the screen space, should the resolution change the widget may be visible but
+ // neither rendering nor grabbing the window works without the winodow being visible
+ const QRect trect = QApplication::desktop()->geometry();
+ m_widget->move(trect.bottom(), trect.right());
+ m_widget->show();
+
+ m_proc = new QProcess(this);
+ m_proc->start(
+ s_xscreensaver,
+ QStringList() << "--window-id" << QString::number(qlonglong(m_widget->winId()))
+ );
+ if (!m_proc->waitForStarted()) {
+ kWarning() << "Could not start" << s_xscreensaver;
+ return;
+ } else {
+ kDebug() << "Started" << s_xscreensaver << QString::number(qlonglong(m_widget->winId()));
+ }
+
+ m_timer = new QTimer(this);
+ m_timer->setInterval(s_updateinterval);
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
+ m_timer->start();
+}
+
+XWallpaper::~XWallpaper()
+{
+ m_timer->stop();
+ m_proc->terminate();
+ m_proc->waitForFinished();
+ delete m_widget;
+}
+
+void XWallpaper::paint(QPainter *painter, const QRectF &exposedRect)
+{
+ kDebug() << "Rendering" << s_xscreensaver << targetSizeHint().toSize();
+ const QSize tsize = targetSizeHint().toSize();
+ m_widget->resize(tsize.width(), tsize.height());
+ painter->drawPixmap(QPoint(), QPixmap::grabWindow(m_widget->winId()));
+}
+
+void XWallpaper::slotTimeout()
+{
+ emit update(QRectF());
+}
+
+#include "moc_xwallpaper.cpp"
--- /dev/null
+/* This file is part of the KDE project
+ Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2, as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef XWALLPAPER_H
+#define XWALLPAPER_H
+
+#include <QWidget>
+#include <QProcess>
+#include <QTimer>
+#include <Plasma/Wallpaper>
+#include <Plasma/DataEngine>
+
+class XWallpaper : public Plasma::Wallpaper
+{
+ Q_OBJECT
+
+public:
+ XWallpaper(QObject* parent, const QVariantList& args);
+ ~XWallpaper();
+
+ void paint(QPainter* painter, const QRectF &exposedRect);
+
+private Q_SLOTS:
+ void slotTimeout();
+
+private:
+ QWidget* m_widget;
+ QProcess* m_proc;
+ QTimer* m_timer;
+};
+
+K_EXPORT_PLASMA_WALLPAPER(xwallpaper, XWallpaper)
+
+#endif // XWALLPAPER_H