mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
Merge branch 'master' of github.com:bbedward/DankMaterialShell
This commit is contained in:
@@ -22,6 +22,16 @@ Column {
|
|||||||
visible: NetworkService.wifiEnabled
|
visible: NetworkService.wifiEnabled
|
||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
|
// Compute icon name from a signal percentage (0-100)
|
||||||
|
function iconForSignal(pct) {
|
||||||
|
const s = Math.max(0, Math.min(100, pct | 0))
|
||||||
|
if (s >= 70) return "signal_wifi_4_bar"
|
||||||
|
if (s >= 50) return "network_wifi_3_bar"
|
||||||
|
if (s >= 25) return "network_wifi_2_bar"
|
||||||
|
if (s >= 10) return "network_wifi_1_bar"
|
||||||
|
return "signal_wifi_bad"
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
@@ -150,7 +160,7 @@ Column {
|
|||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
name: NetworkService.wifiSignalIcon
|
name: iconForSignal(modelData.signal)
|
||||||
size: Theme.iconSize - 2
|
size: Theme.iconSize - 2
|
||||||
color: modelData.connected ? Theme.primary : Theme.surfaceText
|
color: modelData.connected ? Theme.primary : Theme.surfaceText
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,30 @@ Singleton {
|
|||||||
signal networksUpdated
|
signal networksUpdated
|
||||||
signal connectionChanged
|
signal connectionChanged
|
||||||
|
|
||||||
|
// Helper: split nmcli -t output respecting escaped colons (\:)
|
||||||
|
function splitNmcliFields(line) {
|
||||||
|
let parts = []
|
||||||
|
let cur = ""
|
||||||
|
let escape = false
|
||||||
|
for (let i = 0; i < line.length; i++) {
|
||||||
|
const ch = line[i]
|
||||||
|
if (escape) {
|
||||||
|
// Keep literal for escaped colon and other sequences
|
||||||
|
cur += ch
|
||||||
|
escape = false
|
||||||
|
} else if (ch === '\\') {
|
||||||
|
escape = true
|
||||||
|
} else if (ch === ':') {
|
||||||
|
parts.push(cur)
|
||||||
|
cur = ""
|
||||||
|
} else {
|
||||||
|
cur += ch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parts.push(cur)
|
||||||
|
return parts
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
root.userPreference = SettingsData.networkPreference
|
root.userPreference = SettingsData.networkPreference
|
||||||
initializeDBusMonitors()
|
initializeDBusMonitors()
|
||||||
@@ -398,18 +422,33 @@ Singleton {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: getCurrentWifiInfo
|
id: getCurrentWifiInfo
|
||||||
command: root.wifiInterface ? ["nmcli", "-t", "-f", "ACTIVE,SSID,SIGNAL", "dev", "wifi", "list", "ifname", root.wifiInterface] : []
|
// Prefer IN-USE,SIGNAL,SSID, but we'll also parse legacy ACTIVE format
|
||||||
|
command: root.wifiInterface ? ["nmcli", "-t", "-f", "IN-USE,SIGNAL,SSID", "device", "wifi", "list", "ifname", root.wifiInterface] : []
|
||||||
running: false
|
running: false
|
||||||
|
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
splitMarker: "\n"
|
splitMarker: "\n"
|
||||||
onRead: line => {
|
onRead: line => {
|
||||||
|
// IN-USE format: "*:SIGNAL:SSID"
|
||||||
|
if (line.startsWith("*:")) {
|
||||||
|
const rest = line.substring(2)
|
||||||
|
const parts = root.splitNmcliFields(rest)
|
||||||
|
if (parts.length >= 2) {
|
||||||
|
const signal = parseInt(parts[0])
|
||||||
|
root.wifiSignalStrength = isNaN(signal) ? 0 : signal
|
||||||
|
root.currentWifiSSID = parts.slice(1).join(":")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
if (line.startsWith("yes:")) {
|
if (line.startsWith("yes:")) {
|
||||||
const parts = line.substring(4).split(":")
|
const rest = line.substring(4)
|
||||||
|
const parts = root.splitNmcliFields(rest)
|
||||||
if (parts.length >= 2) {
|
if (parts.length >= 2) {
|
||||||
root.currentWifiSSID = parts[0]
|
root.currentWifiSSID = parts[0]
|
||||||
root.wifiSignalStrength = parseInt(parts[1]) || 0
|
const signal = parseInt(parts[1])
|
||||||
|
root.wifiSignalStrength = isNaN(signal) ? 0 : signal
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -543,7 +582,7 @@ Singleton {
|
|||||||
const seen = new Set()
|
const seen = new Set()
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const parts = line.split(':')
|
const parts = root.splitNmcliFields(line)
|
||||||
if (parts.length >= 4 && parts[0]) {
|
if (parts.length >= 4 && parts[0]) {
|
||||||
const ssid = parts[0]
|
const ssid = parts[0]
|
||||||
if (!seen.has(ssid)) {
|
if (!seen.has(ssid)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user