blob: 8b7acd362f4ddd97f7fd5f59f2cc547c03cb87a8 (
plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
pragma Singleton
pragma ComponentBehavior: Bound
import QtCore
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Common
Singleton {
id: root
readonly property string configDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation)) + "/DankMaterialShell"
readonly property string settingsPath: configDir + "/settings.json"
readonly property string firstLaunchMarkerPath: configDir + "/.firstlaunch"
property bool isFirstLaunch: false
property bool checkComplete: false
property bool greeterDismissed: false
property int requestedStartPage: 0
readonly property bool shouldShowGreeter: checkComplete && isFirstLaunch && !greeterDismissed
signal greeterRequested
signal greeterCompleted
function showGreeter(startPage) {
requestedStartPage = startPage || 0;
greeterRequested();
}
function showWelcome() {
showGreeter(0);
}
function showDoctor() {
showGreeter(1);
}
Component.onCompleted: {
checkFirstLaunch();
}
function checkFirstLaunch() {
firstLaunchCheckProcess.running = true;
}
function markFirstLaunchComplete() {
greeterDismissed = true;
touchMarkerProcess.running = true;
greeterCompleted();
}
function dismissGreeter() {
greeterDismissed = true;
}
Process {
id: firstLaunchCheckProcess
command: ["sh", "-c", `
SETTINGS='` + settingsPath + `'
MARKER='` + firstLaunchMarkerPath + `'
if [ -f "$MARKER" ]; then
echo 'skip'
elif [ -f "$SETTINGS" ]; then
echo 'existing_user'
else
echo 'first'
fi
`]
running: false
stdout: SplitParser {
onRead: data => {
const result = data.trim();
if (result === "first") {
root.isFirstLaunch = true;
console.info("FirstLaunchService: First launch detected, greeter will be shown");
} else if (result === "existing_user") {
root.isFirstLaunch = false;
console.info("FirstLaunchService: Existing user detected, silently creating marker");
touchMarkerProcess.running = true;
} else {
root.isFirstLaunch = false;
}
root.checkComplete = true;
if (root.isFirstLaunch)
root.greeterRequested();
}
}
}
Process {
id: touchMarkerProcess
command: ["sh", "-c", "mkdir -p '" + configDir + "' && touch '" + firstLaunchMarkerPath + "'"]
running: false
onExited: exitCode => {
if (exitCode === 0) {
console.info("FirstLaunchService: First launch marker created");
} else {
console.warn("FirstLaunchService: Failed to create first launch marker");
}
}
}
}
|