import Quickshell import Quickshell.Io import QtQuick import "../components" Item { id: root implicitWidth: row.implicitWidth + 10 implicitHeight: 24 property string connType: "none" // "wifi", "ethernet", "none" property string connName: "" // \uf1eb = FA wifi, \uf0e8 = FA sitemap (wired proxy), \uf127 = FA chain-broken readonly property string netIcon: connType === "wifi" ? "\uf1eb" : connType === "ethernet" ? "\uf0e8" : "\uf127" function parseLine(line) { const idx1 = line.indexOf(":") if (idx1 < 0) return const idx2 = line.indexOf(":", idx1 + 1) if (idx2 < 0) return const type = line.substring(0, idx1) const state = line.substring(idx1 + 1, idx2) const conn = line.substring(idx2 + 1).trim() if (state === "connected" && (type === "wifi" || type === "ethernet")) { if (root.connType === "none" || type === "wifi") { root.connType = type root.connName = conn } } } Timer { interval: 5000 running: true repeat: true triggeredOnStart: true onTriggered: { root.connType = "none" root.connName = "" netProc.running = true } } Process { id: netProc command: ["nmcli", "-t", "-f", "TYPE,STATE,CONNECTION", "dev"] stdout: SplitParser { splitMarker: "\n" onRead: data => root.parseLine(data) } onExited: running = false } Row { id: row anchors.centerIn: parent spacing: 5 Text { anchors.verticalCenter: parent.verticalCenter text: root.netIcon font.family: "JetBrainsMono Nerd Font Mono" font.pixelSize: 14 color: root.connType !== "none" ? Theme.text : Theme.textDim } Text { anchors.verticalCenter: parent.verticalCenter text: root.connName.length > 16 ? root.connName.substring(0, 15) + "…" : root.connName font.pixelSize: 11 color: Theme.textDim visible: root.connName !== "" } } }