import QtQuick import Quickshell.Io import "." as M M.BarSection { id: root spacing: 4 tooltip: { if (root.state === "wifi") return "WiFi: " + root.essid + (root.ifname ? "\nInterface: " + root.ifname : ""); if (root.state === "eth") return "Ethernet: " + root.ifname; if (root.state === "linked") return "Linked: " + root.ifname; return "Disconnected"; } property string ifname: "" property string essid: "" property string state: "disconnected" Process { id: proc running: true command: ["sh", "-c", "line=$(nmcli -t -f NAME,TYPE,DEVICE connection show --active 2>/dev/null | head -1); if [ -n \"$line\" ]; then echo \"$line\"; else dev=$(nmcli -t -f DEVICE,STATE device 2>/dev/null | grep ':connected' | grep -v ':unmanaged\\|:unavailable\\|:disconnected\\|:connecting' | head -1 | cut -d: -f1); if [ -n \"$dev\" ]; then echo \"linked:linked:$dev\"; fi; fi"] 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] || ""; if ((parts[1] || "").includes("wireless")) root.state = "wifi"; else if (parts[0] === "linked") root.state = "linked"; else root.state = "eth"; } } } Timer { interval: 5000 running: true repeat: true onTriggered: proc.running = true } M.BarIcon { icon: { if (root.state === "wifi") return "\uF1EB"; if (root.state === "eth") return "\uDB80\uDE00"; if (root.state === "linked") return "\uDB85\uDE16"; return "\uDB82\uDCFD"; } anchors.verticalCenter: parent.verticalCenter } Text { visible: root.state === "wifi" text: root.essid color: M.Theme.base05 font.pixelSize: M.Theme.fontSize + 1 font.family: M.Theme.fontFamily anchors.verticalCenter: parent.verticalCenter } }