Skip to content
Snippets Groups Projects
Commit c8d6e8bd authored by akiraohgaki's avatar akiraohgaki
Browse files

Add function to set property with xfconf

parent 8ca4d230
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <QProcess> #include <QProcess>
#include <QDBusMessage> #include <QDBusMessage>
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusVariant>
#include <QDebug> #include <QDebug>
#endif #endif
...@@ -297,15 +296,10 @@ bool SystemHandler::applyGnomeGnomeShellTheme(const QString &path) const ...@@ -297,15 +296,10 @@ bool SystemHandler::applyGnomeGnomeShellTheme(const QString &path) const
return QProcess::startDetached("gsettings", arguments); return QProcess::startDetached("gsettings", arguments);
} }
bool SystemHandler::applyXfceWallpaper(const QString &path) const bool SystemHandler::setPropertyWithXfconf(const QString &channel, const QString &property, const QDBusVariant &value) const
{ {
QString channelValue = "xfce4-desktop";
//QString propertyValue = "/backdrop/screen0/monitor0/image-path";
QString propertyValue = "/backdrop/screen0/monitor0/workspace0/last-image";
QDBusVariant valueValue(path);
auto message = QDBusMessage::createMethodCall("org.xfce.Xfconf", "/org/xfce/Xfconf", "org.xfce.Xfconf", "SetProperty"); auto message = QDBusMessage::createMethodCall("org.xfce.Xfconf", "/org/xfce/Xfconf", "org.xfce.Xfconf", "SetProperty");
message.setArguments(QVariantList() << QVariant(channelValue) << QVariant(propertyValue) << QVariant::fromValue(valueValue)); message.setArguments(QVariantList() << QVariant(channel) << QVariant(property) << QVariant::fromValue(value));
auto reply = QDBusConnection::sessionBus().call(message); auto reply = QDBusConnection::sessionBus().call(message);
if (reply.type() == QDBusMessage::ErrorMessage) { if (reply.type() == QDBusMessage::ErrorMessage) {
...@@ -314,4 +308,9 @@ bool SystemHandler::applyXfceWallpaper(const QString &path) const ...@@ -314,4 +308,9 @@ bool SystemHandler::applyXfceWallpaper(const QString &path) const
} }
return true; return true;
} }
bool SystemHandler::applyXfceWallpaper(const QString &path) const
{
return setPropertyWithXfconf("xfce4-desktop", "/backdrop/screen0/monitor0/workspace0/last-image", QDBusVariant(path));
}
#endif #endif
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include <QObject> #include <QObject>
#ifdef QTLIB_UNIX
#include <QDBusVariant>
#endif
class SystemHandler : public QObject class SystemHandler : public QObject
{ {
Q_OBJECT Q_OBJECT
...@@ -36,6 +40,7 @@ private: ...@@ -36,6 +40,7 @@ private:
bool applyGnomeGtk3Theme(const QString &path) const; bool applyGnomeGtk3Theme(const QString &path) const;
bool applyGnomeGnomeShellTheme(const QString &path) const; bool applyGnomeGnomeShellTheme(const QString &path) const;
bool setPropertyWithXfconf(const QString &channel, const QString &property, const QDBusVariant &value) const;
bool applyXfceWallpaper(const QString &path) const; bool applyXfceWallpaper(const QString &path) const;
#endif #endif
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment