Making Network via singleton

This commit is contained in:
Hannes
2026-03-26 19:43:42 +01:00
parent 3cda978d7f
commit bc698a1d01
3 changed files with 59 additions and 18 deletions
@@ -0,0 +1,37 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
QtObject {
id: root
property string status: "..."
property bool running: false
// Timer property
property Timer networkTimer: Timer {
interval: 10000
repeat: true
running: true
onTriggered: networkScript.running = true
}
// Process property
property Process networkScript: Process {
running: true
command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Network.sh"]
stdout: StdioCollector {
onStreamFinished: {
root.status = this.text.trim()
console.log("Network status:", root.status)
}
}
}
Component.onCompleted: {
networkScript.start()
networkTimer.start()
}
}
+1
View File
@@ -0,0 +1 @@
singleton NetworkState NetworkState.qml