Krolyxon
Commit 2e919c3

Branches

Refs →

aurora2e919c3

aurora: add wired connections handling in NetPage

Author
krolyxon
Date
2026-10-13 22:58 +0530
Parent
5515e5c
Commit
2e919c366f1cd8b6f4ef9bbfbb3d48b3c9a20b26

+61 −17

3 files changed

  1. M .config/quickshell/aurora/Bar.qml +1 −1
  2. M .config/quickshell/aurora/Net.qml +34 −14
  3. M .config/quickshell/aurora/NetPage.qml +26 −2
M .config/quickshell/aurora/Bar.qml View
@@ -111,7 +111,7 @@ PanelWindow {
111111 }
112112
113113 BarPill {
114− icon: Net.wired && !(Net.wifiEnabled && Net.connected !== "") ? Theme.iEthernet
114+ icon: Net.wired && !(Net.wifiEnabled && Net.connected !== "") ? Net.wiredIcon
115115 : (Net.wifiEnabled ? Theme.wifiIcon(Net.connected !== "" ? Net.activeSignal : 0) : Theme.iWifiOff)
116116 tint: (Net.wired || (Net.wifiEnabled && Net.connected !== "")) ? Theme.fg : Theme.dim
117117 onActivated: bar.togglePanel("net", bar.modelData)
M .config/quickshell/aurora/Net.qml View
@@ -8,7 +8,9 @@ Singleton {
88 id: root
99
1010 property bool active: false // NetPage sets this while visible (faster polling + rescan)
11− property bool wired: false
11+ property var wiredDevs: [] // [{dev, name, ip, usb}] connected ethernet-type devices (incl. USB tethering)
12+ readonly property bool wired: wiredDevs.length > 0
13+ readonly property string wiredIcon: wiredDevs.length > 0 && wiredDevs[0].usb ? Theme.iPhone : Theme.iEthernet
1214 property bool wifiEnabled: true
1315 property string wifiDevice: ""
1416 property var raw: [] // [{inUse, ssid, signal, security}]
@@ -46,6 +48,34 @@ Singleton {
4648 return out
4749 }
4850
51+ // `nmcli device show` output (terse): one block per device, blank line between.
52+ // Android USB tethering (and USB ethernet dongles) show up as type "ethernet".
53+ function parseShow(text) {
54+ var devs = [], cur = null, lines = text.split("\n")
55+ for (var i = 0; i < lines.length; i++) {
56+ if (lines[i] === "") continue
57+ var f = parseTerse(lines[i]), key = f[0], val = f.slice(1).join(":")
58+ if (key === "GENERAL.DEVICE") { cur = { dev: val, type: "", state: "", name: "", ip: "" }; devs.push(cur) }
59+ else if (cur === null) continue
60+ else if (key === "GENERAL.TYPE") cur.type = val
61+ else if (key === "GENERAL.STATE") cur.state = val
62+ else if (key === "GENERAL.CONNECTION") cur.name = val
63+ else if (key.indexOf("IP4.ADDRESS") === 0 && cur.ip === "") cur.ip = val
64+ }
65+ var wired = []
66+ for (var j = 0; j < devs.length; j++) {
67+ var d = devs[j]
68+ if (d.type === "wifi") wifiDevice = d.dev
69+ var up = d.state.indexOf("connected") >= 0 && d.state.indexOf("disconnected") < 0
70+ if (d.type === "ethernet" && up)
71+ wired.push({
72+ dev: d.dev, name: d.name !== "" ? d.name : d.dev, ip: d.ip,
73+ usb: /^usb|^enx|u\d+(c\d+)?(i\d+)?$/.test(d.dev)
74+ })
75+ }
76+ wiredDevs = wired
77+ }
78+
4979 function build(list, saved) {
5080 var out = []
5181 for (var i = 0; i < list.length; i++) {
@@ -123,6 +153,7 @@ Singleton {
123153 }
124154 }
125155
156+ function disconnectDev(dev) { run(["device", "disconnect", dev]) }
126157 function disconnect() { if (wifiDevice !== "") run(["device", "disconnect", wifiDevice]) }
127158 function forget(ssid) { run(["connection", "delete", "id", ssid]) }
128159 function setWifi(on) { run(["radio", "wifi", on ? "on" : "off"]) }
@@ -156,19 +187,8 @@ Singleton {
156187
157188 Process {
158189 id: devProc
159− command: ["nmcli", "-t", "-f", "DEVICE,TYPE,STATE", "device"]
160− stdout: StdioCollector {
161− onStreamFinished: {
162− var lines = text.split("\n"), wired = false
163− for (var i = 0; i < lines.length; i++) {
164− var f = root.parseTerse(lines[i])
165− if (f.length < 3) continue
166− if (f[1] === "wifi") root.wifiDevice = f[0]
167− if (f[1] === "ethernet" && f[2] === "connected") wired = true
168− }
169− root.wired = wired
170− }
171− }
190+ command: ["nmcli", "-t", "-f", "GENERAL.DEVICE,GENERAL.TYPE,GENERAL.STATE,GENERAL.CONNECTION,IP4.ADDRESS", "device", "show"]
191+ stdout: StdioCollector { onStreamFinished: root.parseShow(text) }
172192 }
173193
174194 Process {
M .config/quickshell/aurora/NetPage.qml View
@@ -7,14 +7,38 @@ ColumnLayout {
77 onActiveChanged: Net.active = active
88 spacing: 8
99
10+ // wired / usb tethering (read-only status, plus a disconnect button)
11+ ColumnLayout {
12+ visible: Net.wiredDevs.length > 0
13+ Layout.fillWidth: true
14+ spacing: 2
15+ SectionLabel { text: "wired" }
16+ Repeater {
17+ model: Net.wiredDevs
18+ delegate: ListRow {
19+ required property var modelData
20+ icon: modelData.usb ? Theme.iPhone : Theme.iEthernet
21+ title: modelData.name
22+ subtitle: modelData.dev + (modelData.ip !== "" ? " · " + modelData.ip : "")
23+ trailing: modelData.usb ? "usb" : ""
24+ current: true
25+ IconBtn {
26+ icon: Theme.iClose
27+ height: 26
28+ onClicked: Net.disconnectDev(modelData.dev)
29+ }
30+ }
31+ }
32+ }
33+
1034 RowLayout {
1135 Layout.fillWidth: true
1236 spacing: 6
1337 Text {
1438 Layout.fillWidth: true
1539 elide: Text.ElideRight
16− text: !Net.wifiEnabled ? "wi-fi is off"
17− : (Net.connected !== "" ? "connected · " + Net.connected : "not connected")
40+ text: !Net.wifiEnabled ? "wi-fi off"
41+ : (Net.connected !== "" ? "wi-fi · " + Net.connected : "wi-fi not connected")
1842 color: Net.connected !== "" && Net.wifiEnabled ? Theme.accent : Theme.dim
1943 font.family: Theme.font
2044 font.pixelSize: Theme.fontSize