added adaptive quickshell
This commit is contained in:
1 parent
6eb56d2065
commit
5b33a73fd8
189 files changed
+8678
-15
No files matched your search
@@ -0,0 +1,59 @@
|
||||
pragma Singleton
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
property string backend: "unknown"
|
||||
property var devices: []
|
||||
property string error: ""
|
||||
readonly property bool present: devices.length > 0
|
||||
property bool busy: false
|
||||
property bool actionBusy: false
|
||||
property string actionError: ""
|
||||
property string pendingId: ""
|
||||
property string pendingAction: ""
|
||||
function setEnabled(modemId, enabled) {
|
||||
if (actionBusy || !/^[0-9]{1,5}$/.test(String(modemId))) return;
|
||||
pendingId = String(modemId);
|
||||
pendingAction = enabled ? "enable" : "disable";
|
||||
actionError = "";
|
||||
actionBusy = true;
|
||||
actionProcess.running = true;
|
||||
}
|
||||
Process {
|
||||
id: actionProcess
|
||||
command: ["python3", Qt.resolvedUrl("../backend/modem_control.py").toString().replace(/^file:\/\//, ""), root.pendingId, root.pendingAction]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
try {
|
||||
const response = JSON.parse(text);
|
||||
root.actionError = response.ok ? "" : response.error;
|
||||
} catch (e) { root.actionError = String(e); }
|
||||
}
|
||||
}
|
||||
onExited: { root.actionBusy = false; root.refresh(); }
|
||||
}
|
||||
function refresh() {
|
||||
if (!busy) { busy = true; probe.running = true; }
|
||||
}
|
||||
Process {
|
||||
id: probe
|
||||
command: ["python3", Qt.resolvedUrl("../backend/modems.py").toString().replace(/^file:\/\//, "")]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
try {
|
||||
const result = JSON.parse(text);
|
||||
root.backend = result.backend;
|
||||
root.devices = result.modems || [];
|
||||
root.error = result.error || "";
|
||||
} catch (e) { root.backend = "error"; root.error = String(e); }
|
||||
}
|
||||
}
|
||||
onExited: root.busy = false
|
||||
}
|
||||
// ModemManager can appear after boot or USB hotplug. A modest interval
|
||||
// avoids a permanent high-frequency poll on battery-powered devices.
|
||||
Timer { interval: 15000; repeat: true; running: true; triggeredOnStart: true; onTriggered: root.refresh() }
|
||||
}
|
||||
Reference in new issue
Block a user