-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathautostartscriptdesktopfile.cpp
34 lines (29 loc) · 1.21 KB
/
autostartscriptdesktopfile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
SPDX-FileCopyrightText: 2021 Henri Chain <[email protected]>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "autostartscriptdesktopfile.h"
#include <KConfigGroup>
#include <KDesktopFile>
#include <QDir>
#include <QStandardPaths>
static const auto autostartScriptKey = QStringLiteral("X-KDE-AutostartScript");
QDir AutostartScriptDesktopFile::autostartLocation()
{
return QDir(QDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)).filePath(QStringLiteral("autostart")));
}
AutostartScriptDesktopFile::AutostartScriptDesktopFile(const QString &name, const QString &execPath)
: KDesktopFile(autostartLocation().absoluteFilePath(name + QStringLiteral(".desktop")))
{
KConfigGroup kcg = desktopGroup();
kcg.writeEntry(QStringLiteral("Type"), "Application");
kcg.writeEntry(QStringLiteral("Name"), name);
kcg.writeEntry(QStringLiteral("Exec"), execPath);
kcg.writeEntry(QStringLiteral("Icon"), "dialog-scripts");
kcg.writeEntry(autostartScriptKey, "true");
kcg.writeEntry(QStringLiteral("Path"), "");
}
bool AutostartScriptDesktopFile::isAutostartScript(const KDesktopFile &file)
{
return file.desktopGroup().readEntry<bool>(autostartScriptKey, false);
}