added private ip on network view

This commit is contained in:
2026-08-10 20:12:04 +01:00
parent f246b7e658
commit 9baa312d0e
2 changed files with 26 additions and 2 deletions

View File

@@ -142,7 +142,8 @@ Container {
color: Colors.subtext1
fontSize: 12
fontWeight: 5
text: "Connected on: " + networkColumn.networkInfo["adapterName"]
text: networkColumn.networkInfo["ipAddress"] + " on "
+ networkColumn.networkInfo["adapterName"]
}
StyledText {

View File

@@ -1,6 +1,7 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Networking
Singleton {
@@ -9,6 +10,7 @@ Singleton {
property bool connectedWifi: root.defaultAdapter != null && root.defaultAdapter.connected
&& root.defaultAdapter.type == DeviceType.Wifi
property NetworkDevice defaultAdapter: Networking.devices.values[0] || null
property string ipAddress: "0.0.0.0"
function getConnectedNetworks(networksArr) {
let connectedNetworks = [];
@@ -61,7 +63,8 @@ Singleton {
"networkName": networkName,
"networkStrength": networkStrength,
"icon": networkIcon,
"saved": primaryNetwork.known
"saved": primaryNetwork.known,
"ipAddress": root.ipAddress
};
return outputDict;
}
@@ -96,4 +99,24 @@ Singleton {
return false;
}
}
function refreshIpAddress() {
ipProcess.running = true;
}
onDefaultAdapterChanged: {
refreshIpAddress();
}
Process {
id: ipProcess
command: ["sh", "-c", "ip -4 -o addr show dev " + root.defaultAdapter.name
+ " scope global | awk '{sub(\"/.*\", \"\", $4); printf $4}'"]
running: true
stdout: StdioCollector {
onStreamFinished: root.ipAddress = this.text
}
}
}