diff options
Diffstat (limited to 'services')
| -rw-r--r-- | services/Network.qml | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/services/Network.qml b/services/Network.qml new file mode 100644 index 0000000..93c8d50 --- /dev/null +++ b/services/Network.qml @@ -0,0 +1,44 @@ +pragma Singleton + +import Quickshell +import Quickshell.Io +import QtQuick + +Singleton { + id: root + + readonly property AccessPoint active: AccessPoint { + active: true + } + + Process { + running: true + command: ["nmcli", "m"] + stdout: SplitParser { + onRead: getNetworks.running = true + } + } + + Process { + id: getNetworks + running: true + command: ["nmcli", "-g", "ACTIVE,SIGNAL,FREQ,SSID", "d", "w"] + stdout: SplitParser { + onRead: data => { + const [active, strength, frequency, ssid] = data.split(":"); + if (active === "yes") { + root.active.ssid = ssid; + root.active.strength = parseInt(strength); + root.active.frequency = parseInt(frequency); + } + } + } + } + + component AccessPoint: QtObject { + property string ssid + property int strength + property int frequency + property bool active + } +} |