mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-11 07:52:50 -05:00
Add bluetooth codec switching, via @Vantesh
This commit is contained in:
@@ -156,4 +156,70 @@ Singleton {
|
||||
device.trusted = true
|
||||
device.connect()
|
||||
}
|
||||
|
||||
function getCardName(device) {
|
||||
if (!device)
|
||||
return ""
|
||||
return "bluez_card." + device.address.replace(/:/g, "_")
|
||||
}
|
||||
|
||||
function isAudioDevice(device) {
|
||||
if (!device)
|
||||
return false
|
||||
let icon = getDeviceIcon(device)
|
||||
return icon === "headset" || icon === "speaker"
|
||||
}
|
||||
|
||||
function getCodecInfo(codecName) {
|
||||
let codec = codecName.replace(/-/g, "_").toUpperCase()
|
||||
|
||||
let codecMap = {
|
||||
"LDAC": {
|
||||
name: "LDAC",
|
||||
description: "Highest quality • Higher battery usage",
|
||||
qualityColor: "#4CAF50"
|
||||
},
|
||||
"APTX_HD": {
|
||||
name: "aptX HD",
|
||||
description: "High quality • Balanced battery",
|
||||
qualityColor: "#FF9800"
|
||||
},
|
||||
"APTX": {
|
||||
name: "aptX",
|
||||
description: "Good quality • Low latency",
|
||||
qualityColor: "#FF9800"
|
||||
},
|
||||
"AAC": {
|
||||
name: "AAC",
|
||||
description: "Balanced quality and battery",
|
||||
qualityColor: "#2196F3"
|
||||
},
|
||||
"SBC_XQ": {
|
||||
name: "SBC-XQ",
|
||||
description: "Enhanced SBC • Better compatibility",
|
||||
qualityColor: "#2196F3"
|
||||
},
|
||||
"SBC": {
|
||||
name: "SBC",
|
||||
description: "Basic quality • Universal compatibility",
|
||||
qualityColor: "#9E9E9E"
|
||||
},
|
||||
"MSBC": {
|
||||
name: "mSBC",
|
||||
description: "Modified SBC • Optimized for speech",
|
||||
qualityColor: "#9E9E9E"
|
||||
},
|
||||
"CVSD": {
|
||||
name: "CVSD",
|
||||
description: "Basic speech codec • Legacy compatibility",
|
||||
qualityColor: "#9E9E9E"
|
||||
}
|
||||
}
|
||||
|
||||
return codecMap[codec] || {
|
||||
name: codecName,
|
||||
description: "Unknown codec",
|
||||
qualityColor: "#9E9E9E"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ Singleton {
|
||||
// WiFi details
|
||||
property string currentWifiSSID: ""
|
||||
property int wifiSignalStrength: 0
|
||||
property int wifiRSSI: -100 // dBm value, -100 = no signal
|
||||
property var wifiNetworks: []
|
||||
property var savedConnections: []
|
||||
property var wifiSignalIcon: {
|
||||
@@ -39,21 +38,7 @@ Singleton {
|
||||
return "wifi_off"
|
||||
}
|
||||
|
||||
// Use RSSI if available
|
||||
if (wifiRSSI > -100) {
|
||||
// Use RSSI-based thresholds (dBm values)
|
||||
if (wifiRSSI >= -50) {
|
||||
return "wifi" // Excellent: -50 dBm and better
|
||||
}
|
||||
if (wifiRSSI >= -65) {
|
||||
return "wifi_2_bar" // Good: -65 to -50 dBm
|
||||
}
|
||||
if (wifiRSSI >= -80) {
|
||||
return "wifi_1_bar" // Fair: -80 to -65 dBm
|
||||
}
|
||||
return "signal_wifi_0_bar" // Poor: worse than -80 dBm
|
||||
}
|
||||
// Fall back to nmcli signal strength percentage
|
||||
// Use nmcli signal strength percentage
|
||||
if (wifiSignalStrength >= 75) {
|
||||
return "wifi"
|
||||
}
|
||||
@@ -333,8 +318,6 @@ Singleton {
|
||||
|
||||
if (wifiInterface) {
|
||||
root.wifiInterface = wifiInterface
|
||||
// Try to parse RSSI now that we have the interface
|
||||
wirelessFileView.parseWifiRSSI()
|
||||
getWifiDevicePath.command = ["gdbus", "call", "--system", "--dest", "org.freedesktop.NetworkManager", "--object-path", "/org/freedesktop/NetworkManager", "--method", "org.freedesktop.NetworkManager.GetDeviceByIpIface", wifiInterface]
|
||||
getWifiDevicePath.running = true
|
||||
} else {
|
||||
@@ -380,8 +363,6 @@ Singleton {
|
||||
if (root.wifiConnected) {
|
||||
getWifiIP.running = true
|
||||
getCurrentWifiInfo.running = true
|
||||
// Parse RSSI now that we're connected
|
||||
wirelessFileView.parseWifiRSSI()
|
||||
// Ensure SSID is resolved even if scan output lacks ACTIVE marker
|
||||
if (root.currentWifiSSID === "") {
|
||||
if (root.wifiConnectionUuid) {
|
||||
@@ -395,7 +376,6 @@ Singleton {
|
||||
root.wifiIP = ""
|
||||
root.currentWifiSSID = ""
|
||||
root.wifiSignalStrength = 0
|
||||
root.wifiRSSI = -100
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -434,59 +414,6 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: wirelessFileView
|
||||
path: "/proc/net/wireless"
|
||||
watchChanges: wifiConnected && wifiInterface !== ""
|
||||
|
||||
function parseWifiRSSI() {
|
||||
if (!root.wifiInterface || !wifiConnected) {
|
||||
root.wifiRSSI = -100
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const content = wirelessFileView.text()
|
||||
if (!content) {
|
||||
root.wifiRSSI = -100
|
||||
return
|
||||
}
|
||||
|
||||
const lines = content.trim().split('\n')
|
||||
for (const line of lines) {
|
||||
if (line.includes(root.wifiInterface + ":")) {
|
||||
const parts = line.trim().split(/\s+/)
|
||||
if (parts.length >= 4) {
|
||||
// Level is the 4th column (signal strength in dBm)
|
||||
const level = parseFloat(parts[3])
|
||||
if (!isNaN(level)) {
|
||||
root.wifiRSSI = Math.round(level)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
root.wifiRSSI = -100 // Interface not found
|
||||
} catch (e) {
|
||||
console.warn("Failed to parse /proc/net/wireless:", e)
|
||||
root.wifiRSSI = -100
|
||||
}
|
||||
}
|
||||
|
||||
onLoaded: {
|
||||
parseWifiRSSI()
|
||||
}
|
||||
|
||||
onFileChanged: {
|
||||
console.log("FILE CHANGE")
|
||||
wirelessFileView.reload()
|
||||
}
|
||||
|
||||
onLoadFailed: function(error) {
|
||||
console.warn("Failed to read /proc/net/wireless:", error)
|
||||
root.wifiRSSI = -100
|
||||
}
|
||||
}
|
||||
|
||||
function updateActiveConnections() {
|
||||
getActiveConnections.running = true
|
||||
|
||||
Reference in New Issue
Block a user