This repository has been archived on 2026-07-13. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
nova-shell/shell/services/SystemdService.qml

53 lines
1.6 KiB
QML

pragma Singleton
import QtQuick
import NovaStats as NS
// Thin wrapper around NS.SystemdService: drives the poll Timer and parses the
// JSON-encoded list properties into JS arrays for QML consumers. Restart helper
// proxies through to the Rust singleton.
QtObject {
id: root
readonly property string hostname: NS.SystemdService.hostname
readonly property string systemState: NS.SystemdService.systemState
readonly property string userState: NS.SystemdService.userState
readonly property int failedCount: NS.SystemdService.failedCount
// Parsed [{ name, description, subState, scope, machine }, ...]
readonly property var failedUnits: {
try {
return JSON.parse(NS.SystemdService.failedUnitsJson);
} catch (e) {
return [];
}
}
// Parsed [{ name, class, service, systemState, failedUnits: [...] }, ...]
readonly property var containers: {
try {
return JSON.parse(NS.SystemdService.containersJson);
} catch (e) {
return [];
}
}
function restartUnit(name, scope, machine) {
NS.SystemdService.restartUnit(name, scope ?? "system", machine ?? "");
}
function refresh() {
NS.SystemdService.poll();
}
property Timer _pollTimer: Timer {
interval: {
const ms = NS.ModulesService.systemdInterval;
return ms > 0 ? ms : 15000;
}
running: NS.ModulesService.systemdEnable
repeat: true
triggeredOnStart: false
onTriggered: NS.SystemdService.poll()
}
}