feat: remove quickshell prefix for profilename
This commit is contained in:
parent
90e3deb589
commit
a2b4f4b6b6
1 changed files with 69 additions and 4 deletions
|
|
@ -56,7 +56,7 @@ Item {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ssid = parts[0];
|
const ssid = wifiLogic.replaceQuickshell(parts[0]);
|
||||||
const type = parts[1];
|
const type = parts[1];
|
||||||
|
|
||||||
if (ssid) {
|
if (ssid) {
|
||||||
|
|
@ -120,6 +120,8 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wifiLogic.networks = networksMap;
|
wifiLogic.networks = networksMap;
|
||||||
scanProcess.existingNetwork = {};
|
scanProcess.existingNetwork = {};
|
||||||
refreshIndicator.running = false;
|
refreshIndicator.running = false;
|
||||||
|
|
@ -130,7 +132,7 @@ Item {
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: wifiLogic
|
id: wifiLogic
|
||||||
property var networks: []
|
property var networks: {}
|
||||||
property var anchorItem: null
|
property var anchorItem: null
|
||||||
property real anchorX
|
property real anchorX
|
||||||
property real anchorY
|
property real anchorY
|
||||||
|
|
@ -146,6 +148,28 @@ Item {
|
||||||
property string detectedInterface: ""
|
property string detectedInterface: ""
|
||||||
property string actionPanelSsid: ""
|
property string actionPanelSsid: ""
|
||||||
|
|
||||||
|
function replaceQuickshell(ssid: string): string {
|
||||||
|
const newName = ssid.replace("quickshell-", "");
|
||||||
|
|
||||||
|
if (!ssid.startsWith("quickshell-")){
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newName in wifiLogic.networks){
|
||||||
|
console.log(`Quickshell ${newName} already exists, deleting old profile`)
|
||||||
|
deleteProfileProcess.connName = ssid;
|
||||||
|
deleteProfileProcess.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
console.log(`Changing from ${ssid} to ${newName}`)
|
||||||
|
renameConnectionProcess.oldName = ssid;
|
||||||
|
renameConnectionProcess.newName = newName;
|
||||||
|
renameConnectionProcess.running = true;
|
||||||
|
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
|
|
||||||
function disconnectNetwork(ssid) {
|
function disconnectNetwork(ssid) {
|
||||||
const profileName = ssid;
|
const profileName = ssid;
|
||||||
disconnectProfileProcess.connectionName = profileName;
|
disconnectProfileProcess.connectionName = profileName;
|
||||||
|
|
@ -222,6 +246,47 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process to rename a connection
|
||||||
|
Process {
|
||||||
|
id: renameConnectionProcess
|
||||||
|
running: false
|
||||||
|
property string oldName: ""
|
||||||
|
property string newName: ""
|
||||||
|
command: ["nmcli", "connection", "modify", oldName, "connection.id", newName]
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
console.log("Renamed connection '" + renameConnectionProcess.oldName + "' to '" + renameConnectionProcess.newName + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stderr: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
console.error("Error renaming connection '" + renameConnectionProcess.oldName + "':", text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Process to rename a connection
|
||||||
|
Process {
|
||||||
|
id: deleteProfileProcess
|
||||||
|
running: false
|
||||||
|
property string connName: ""
|
||||||
|
command: ["nmcli", "connection", "delete", `'${connName}'`]
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
console.log("Deleted connection '" + deleteProfileProcess.connName + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stderr: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
console.error("Error deleting connection '" + deleteProfileProcess.connName + "':", text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Handles connecting to a Wi-Fi network, with or without password
|
// Handles connecting to a Wi-Fi network, with or without password
|
||||||
Process {
|
Process {
|
||||||
id: connectProcess
|
id: connectProcess
|
||||||
|
|
@ -237,9 +302,9 @@ Item {
|
||||||
}
|
}
|
||||||
command: {
|
command: {
|
||||||
if (password) {
|
if (password) {
|
||||||
return ["nmcli", "device", "wifi", "connect", ssid, "password", password];
|
return ["nmcli", "device", "wifi", "connect", `'${ssid}'`, "password", password];
|
||||||
} else {
|
} else {
|
||||||
return ["nmcli", "device", "wifi", "connect", ssid];
|
return ["nmcli", "device", "wifi", "connect", `'${ssid}'`];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue