feat: show ethernet icon if ethernet is connected
Closes https://github.com/noctalia-dev/noctalia-shell/issues/115
This commit is contained in:
parent
8f951946ea
commit
cd102d894e
2 changed files with 22 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ NIconButton {
|
|||
colorBorderHover: Color.transparent
|
||||
|
||||
icon: {
|
||||
if (NetworkService.ethernet) return "lan"
|
||||
let connected = false
|
||||
let signalStrength = 0
|
||||
for (const net in NetworkService.networks) {
|
||||
|
|
@ -30,7 +31,7 @@ NIconButton {
|
|||
break
|
||||
}
|
||||
}
|
||||
return connected ? NetworkService.signalIcon(signalStrength) : "wifi"
|
||||
return connected ? NetworkService.signalIcon(signalStrength) : "wifi_find"
|
||||
}
|
||||
tooltipText: "WiFi Networks"
|
||||
onClicked: {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ Singleton {
|
|||
property string detectedInterface: ""
|
||||
property string lastConnectedNetwork: ""
|
||||
property bool isLoading: false
|
||||
property bool ethernet: false
|
||||
|
||||
Component.onCompleted: {
|
||||
Logger.log("Network", "Service started")
|
||||
|
|
@ -43,6 +44,7 @@ Singleton {
|
|||
|
||||
function refreshNetworks() {
|
||||
isLoading = true
|
||||
checkEthernet.running = true
|
||||
existingNetwork.running = true
|
||||
}
|
||||
|
||||
|
|
@ -415,6 +417,24 @@ Singleton {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Process checkEthernet: Process {
|
||||
id: checkEthernet
|
||||
running: false
|
||||
command: ["nmcli", "-t", "-f", "DEVICE,TYPE,STATE", "device"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
var lines = text.split("\n")
|
||||
for (var i = 0; i < lines.length; ++i) {
|
||||
var parts = lines[i].split(":")
|
||||
if (parts[1] === "ethernet" && parts[2] === "connected") {
|
||||
root.ethernet = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Process addConnectionProcess: Process {
|
||||
id: addConnectionProcess
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue