nova-shell/modules/Network.qml
2026-04-10 10:49:48 +02:00

51 lines
1.4 KiB
QML

import QtQuick
import Quickshell.Io
import "." as M
Row {
id: root
spacing: 4
property string ifname: ""
property string essid: ""
property string state: "disconnected"
Process {
id: proc
running: true
command: ["sh", "-c", "nmcli -t -f NAME,TYPE,DEVICE connection show --active | head -1"]
stdout: StdioCollector {
onStreamFinished: {
const line = text.trim();
if (!line) {
root.state = "disconnected";
root.essid = "";
root.ifname = "";
return;
}
const parts = line.split(":");
root.essid = parts[0] || "";
root.ifname = parts[2] || "";
root.state = (parts[1] || "").includes("wireless") ? "wifi" : "eth";
}
}
}
Timer {
interval: 5000
running: true
repeat: true
onTriggered: proc.running = true
}
Text {
text: {
if (root.state === "wifi") return " " + root.essid;
if (root.state === "eth") return "󰈀";
return "󰣽";
}
color: M.Theme.base05
font.pixelSize: M.Theme.fontSize + 1
font.family: M.Theme.fontFamily
anchors.verticalCenter: parent.verticalCenter
}
}