Making Network via singleton
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
singleton NetworkState NetworkState.qml
|
||||
Reference in New Issue
Block a user