diff options
author | Fabien Proriol <fabien.proriol@kazoe.org> | 2025-05-25 12:13:31 +0200 |
---|---|---|
committer | Fabien Proriol <fabien.proriol@kazoe.org> | 2025-05-25 12:13:31 +0200 |
commit | 1dbc0e3c88ba271ba35bc3f82e7864c4f35e1236 (patch) | |
tree | 8c491cd196e2eff4c59f8c23f566f7ff26981586 /src/lib/xdgautostart.cpp |
Initial Commit
Diffstat (limited to 'src/lib/xdgautostart.cpp')
-rw-r--r-- | src/lib/xdgautostart.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
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()); + } + } +} |