quickshell: fix wifi dropdown disconnect, connect, password prompt
- Track actual wifi device name instead of hardcoded wlan0 - Use writeShellScript for wifi-connect with zenity password fallback - Fix wifiNetworks array mutation for proper QML reactivity - Add zenity to system packages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4a0399c6d3
commit
24b27d02fc
1 changed files with 16 additions and 4 deletions
|
|
@ -62,6 +62,7 @@ in
|
||||||
polkit_gnome
|
polkit_gnome
|
||||||
quickshell
|
quickshell
|
||||||
qt6.qt5compat
|
qt6.qt5compat
|
||||||
|
zenity
|
||||||
];
|
];
|
||||||
|
|
||||||
# Use upstream anyrun flake's HM module instead of the built-in one
|
# Use upstream anyrun flake's HM module instead of the built-in one
|
||||||
|
|
@ -572,6 +573,9 @@ in
|
||||||
let state = fields[2];
|
let state = fields[2];
|
||||||
let conn = fields[3];
|
let conn = fields[3];
|
||||||
if (type !== "ethernet" && type !== "wifi") return;
|
if (type !== "ethernet" && type !== "wifi") return;
|
||||||
|
if (type === "wifi") {
|
||||||
|
netWidget.netDevice = fields[0];
|
||||||
|
}
|
||||||
if (state === "connected") {
|
if (state === "connected") {
|
||||||
netWidget.netState = "connected";
|
netWidget.netState = "connected";
|
||||||
netWidget.netConn = conn;
|
netWidget.netConn = conn;
|
||||||
|
|
@ -596,6 +600,7 @@ in
|
||||||
}
|
}
|
||||||
|
|
||||||
property var wifiNetworks: []
|
property var wifiNetworks: []
|
||||||
|
property string netDevice: ""
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: wifiScanProc
|
id: wifiScanProc
|
||||||
|
|
@ -604,8 +609,7 @@ in
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
let fields = data.split(":");
|
let fields = data.split(":");
|
||||||
if (fields.length < 4 || fields[0] === "") return;
|
if (fields.length < 4 || fields[0] === "") return;
|
||||||
let nets = netWidget.wifiNetworks;
|
let nets = netWidget.wifiNetworks.slice();
|
||||||
// Avoid duplicates
|
|
||||||
for (let i = 0; i < nets.length; i++) {
|
for (let i = 0; i < nets.length; i++) {
|
||||||
if (nets[i].ssid === fields[0]) return;
|
if (nets[i].ssid === fields[0]) return;
|
||||||
}
|
}
|
||||||
|
|
@ -623,14 +627,21 @@ in
|
||||||
Process {
|
Process {
|
||||||
id: wifiConnectProc
|
id: wifiConnectProc
|
||||||
property string targetSsid: ""
|
property string targetSsid: ""
|
||||||
command: ["${pkgs.networkmanager}/bin/nmcli", "device", "wifi", "connect", targetSsid]
|
command: ["${pkgs.writeShellScript "wifi-connect" ''
|
||||||
|
ssid="$1"
|
||||||
|
${pkgs.networkmanager}/bin/nmcli device wifi connect "$ssid" 2>/dev/null && exit 0
|
||||||
|
pw=$(${pkgs.zenity}/bin/zenity --password --title="WiFi Password" 2>/dev/null)
|
||||||
|
[ -n "$pw" ] && ${pkgs.networkmanager}/bin/nmcli device wifi connect "$ssid" password "$pw"
|
||||||
|
''}", targetSsid]
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: netDisconnectProc
|
id: netDisconnectProc
|
||||||
command: ["${pkgs.networkmanager}/bin/nmcli", "device", "disconnect", "wlan0"]
|
property string targetDevice: ""
|
||||||
|
command: ["${pkgs.networkmanager}/bin/nmcli", "device", "disconnect", targetDevice]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|
@ -1007,6 +1018,7 @@ in
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
netDisconnectProc.targetDevice = netWidget.netDevice;
|
||||||
netDisconnectProc.running = true;
|
netDisconnectProc.running = true;
|
||||||
netDropdown.visible = false;
|
netDropdown.visible = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue