Repository navigation
Expand file tree
/
Copy pathUpdateChannelService.qml
More file actions
89 lines (76 loc) · 2.22 KB
/
Copy pathUpdateChannelService.qml
File metadata and controls
89 lines (76 loc) · 2.22 KB
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
import QtQuick
import Quickshell.Io
import "UpdateChannelModel.js" as Model
QtObject {
id: root
property bool updateAvailable: false
property string currentChannel: "unknown"
property string devBranch: ""
property string lastCheckMessage: "Not checked yet"
readonly property bool checking: _availabilityProcess.running
|| _statusProcess.running
signal availabilityFinished(bool available)
function _start(process) {
if (process.running) return false
process.running = true
return true
}
function refreshChannel() {
root._start(_channelProcess)
root._start(_devBranchProcess)
}
function refreshAvailability() {
return root._start(_availabilityProcess)
}
function refreshStatus() {
return root._start(_statusProcess)
}
function clearAvailability() {
root.updateAvailable = false
root.lastCheckMessage = "Omarchy is up to date"
}
property Process _channelProcess: Process {
command: ["omarchy", "channel", "current"]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: root.currentChannel = Model.normalizeChannel(text)
}
}
property Process _devBranchProcess: Process {
command: [
"bash",
"-lc",
"if [[ ${OMARCHY_PATH:-/usr/share/omarchy} != /usr/share/omarchy ]]; "
+ "then git -C \"$OMARCHY_PATH\" branch --show-current 2>/dev/null; fi"
]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: root.devBranch = String(text || "").trim()
}
}
property Process _availabilityProcess: Process {
command: ["omarchy", "update", "available"]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: {
var message = String(text || "").trim()
if (message !== "") root.lastCheckMessage = message
}
}
onExited: function(exitCode) {
root.updateAvailable = exitCode === 0
root.availabilityFinished(root.updateAvailable)
}
}
property Process _statusProcess: Process {
command: ["omarchy", "update", "status"]
onExited: root.refreshChannel()
}
property Timer _availabilityTimer: Timer {
interval: 21600000
running: true
repeat: true
triggeredOnStart: true
onTriggered: root.refreshAvailability()
}
}