summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorATMDA <atdma2600@gmail.com>2025-11-11 16:18:32 -0500
committerATMDA <atdma2600@gmail.com>2025-11-11 16:18:32 -0500
commit5af1e9222e2f15c84102dc1ffb46e8643959e74a (patch)
tree5f6d811062b320b94171fe591a96892a0fb71c7b /services
parentcontrolcenter: truncating interface names if too long (diff)
downloadcaelestia-shell-5af1e9222e2f15c84102dc1ffb46e8643959e74a.tar.gz
caelestia-shell-5af1e9222e2f15c84102dc1ffb46e8643959e74a.tar.bz2
caelestia-shell-5af1e9222e2f15c84102dc1ffb46e8643959e74a.zip
controlcenter: added connection information to wireless to match ethernet panel
Diffstat (limited to 'services')
-rw-r--r--services/Network.qml114
1 files changed, 113 insertions, 1 deletions
diff --git a/services/Network.qml b/services/Network.qml
index acd4bcb..c8ab264 100644
--- a/services/Network.qml
+++ b/services/Network.qml
@@ -25,6 +25,7 @@ Singleton {
property string ethernetDebugInfo: ""
property bool ethernetProcessRunning: false
property var ethernetDeviceDetails: null
+ property var wirelessDeviceDetails: null
function enableWifi(enabled: bool): void {
const cmd = enabled ? "on" : "off";
@@ -111,6 +112,11 @@ Singleton {
}
}
+ function updateWirelessDeviceDetails(): void {
+ // Find the wireless interface by looking for wifi devices
+ findWirelessInterfaceProc.exec(["nmcli", "device", "status"]);
+ }
+
function cidrToSubnetMask(cidr: string): string {
// Convert CIDR notation (e.g., "24") to subnet mask (e.g., "255.255.255.0")
const cidrNum = parseInt(cidr);
@@ -587,7 +593,7 @@ Singleton {
};
for (let i = 0; i < lines.length; i++) {
- const line = lines[i];
+const line = lines[i];
const parts = line.split(":");
if (parts.length >= 2) {
const key = parts[0].trim();
@@ -625,6 +631,112 @@ Singleton {
}
}
+ Process {
+ id: findWirelessInterfaceProc
+
+ environment: ({
+ LANG: "C.UTF-8",
+ LC_ALL: "C.UTF-8"
+ })
+ stdout: StdioCollector {
+ onStreamFinished: {
+ const output = text.trim();
+ if (!output || output.length === 0) {
+ root.wirelessDeviceDetails = null;
+ return;
+ }
+
+ // Find the connected wifi interface from device status
+ const lines = output.split("\n");
+ let wifiInterface = "";
+
+ for (let i = 0; i < lines.length; i++) {
+ const line = lines[i];
+ const parts = line.split(/\s+/);
+ // Format: DEVICE TYPE STATE CONNECTION
+ // Look for wifi devices that are connected
+ if (parts.length >= 3 && parts[1] === "wifi" && parts[2] === "connected") {
+ wifiInterface = parts[0];
+ break;
+ }
+ }
+
+ if (wifiInterface && wifiInterface.length > 0) {
+ getWirelessDetailsProc.exec(["nmcli", "device", "show", wifiInterface]);
+ } else {
+ root.wirelessDeviceDetails = null;
+ }
+ }
+ }
+ onExited: {
+ if (exitCode !== 0) {
+ root.wirelessDeviceDetails = null;
+ }
+ }
+ }
+
+ Process {
+ id: getWirelessDetailsProc
+
+ environment: ({
+ LANG: "C.UTF-8",
+ LC_ALL: "C.UTF-8"
+ })
+ stdout: StdioCollector {
+ onStreamFinished: {
+ const output = text.trim();
+ if (!output || output.length === 0) {
+ root.wirelessDeviceDetails = null;
+ return;
+ }
+
+ const lines = output.split("\n");
+ const details = {
+ ipAddress: "",
+ gateway: "",
+ dns: [],
+ subnet: "",
+ macAddress: "",
+ speed: ""
+ };
+
+ for (let i = 0; i < lines.length; i++) {
+ const line = lines[i];
+ const parts = line.split(":");
+ if (parts.length >= 2) {
+ const key = parts[0].trim();
+ const value = parts.slice(1).join(":").trim();
+
+ if (key.startsWith("IP4.ADDRESS")) {
+ // Extract IP and subnet from format like "10.13.1.45/24"
+ const ipParts = value.split("/");
+ details.ipAddress = ipParts[0] || "";
+ if (ipParts[1]) {
+ // Convert CIDR notation to subnet mask
+ details.subnet = root.cidrToSubnetMask(ipParts[1]);
+ } else {
+ details.subnet = "";
+ }
+ } else if (key === "IP4.GATEWAY") {
+ details.gateway = value;
+ } else if (key.startsWith("IP4.DNS")) {
+ details.dns.push(value);
+ } else if (key === "GENERAL.HWADDR") {
+ details.macAddress = value;
+ }
+ }
+ }
+
+ root.wirelessDeviceDetails = details;
+ }
+ }
+ onExited: {
+ if (exitCode !== 0) {
+ root.wirelessDeviceDetails = null;
+ }
+ }
+ }
+
component AccessPoint: QtObject {
required property var lastIpcObject
readonly property string ssid: lastIpcObject.ssid