From 1dbc0e3c88ba271ba35bc3f82e7864c4f35e1236 Mon Sep 17 00:00:00 2001 From: Fabien Proriol Date: Sun, 25 May 2025 12:13:31 +0200 Subject: Initial Commit --- src/lib/xdgautostart.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/lib/xdgautostart.cpp (limited to 'src/lib/xdgautostart.cpp') diff --git a/src/lib/xdgautostart.cpp b/src/lib/xdgautostart.cpp new file mode 100644 index 0000000..bd71261 --- /dev/null +++ b/src/lib/xdgautostart.cpp @@ -0,0 +1,38 @@ +#include "xdgautostart.h" +#include "xdgbasedir.h" +#include "xdgentry.h" +#include "debug.h" + +xdg::AutoStart::AutoStart(QObject *parent) + : QObject{parent} +{ + qCDebug(AUTO_START) << "Create Auto start"; + QStringList configdirs = xdg::configDirs(); + for (auto dir = configdirs.rbegin(); dir != configdirs.rend(); ++dir) + { + m_entries.addDirectory(*dir + "/autostart"); + } + m_entries.addDirectory(xdg::configHome() + "/autostart"); +} + +void xdg::AutoStart::start(QString key, QString value) +{ + qCDebug(AUTO_START) << "Start " << key << value; + for(xdg::Entry *entry: m_entries.getEntries()) + { + if((!value.isNull()) && (!key.isNull())) + { + QString c = entry->data(key); + if(c.trimmed().toLower() == value.trimmed().toLower()) + { + qCDebug(AUTO_START) << "Start app " << entry->appId() << "with" << key << value; + entry->start(QStringList()); + } + } + else + { + qCDebug(AUTO_START) << "Start app " << entry->appId(); + entry->start(QStringList()); + } + } +} -- cgit v1.2.3