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
|
||||
quickshell
|
||||
qt6.qt5compat
|
||||
zenity
|
||||
];
|
||||
|
||||
# Use upstream anyrun flake's HM module instead of the built-in one
|
||||
|
|
@ -572,6 +573,9 @@ in
|
|||
let state = fields[2];
|
||||
let conn = fields[3];
|
||||
if (type !== "ethernet" && type !== "wifi") return;
|
||||
if (type === "wifi") {
|
||||
netWidget.netDevice = fields[0];
|
||||
}
|
||||
if (state === "connected") {
|
||||
netWidget.netState = "connected";
|
||||
netWidget.netConn = conn;
|
||||
|
|
@ -596,6 +600,7 @@ in
|
|||
}
|
||||
|
||||
property var wifiNetworks: []
|
||||
property string netDevice: ""
|
||||
|
||||
Process {
|
||||
id: wifiScanProc
|
||||
|
|
@ -604,8 +609,7 @@ in
|
|||
onRead: data => {
|
||||
let fields = data.split(":");
|
||||
if (fields.length < 4 || fields[0] === "") return;
|
||||
let nets = netWidget.wifiNetworks;
|
||||
// Avoid duplicates
|
||||
let nets = netWidget.wifiNetworks.slice();
|
||||
for (let i = 0; i < nets.length; i++) {
|
||||
if (nets[i].ssid === fields[0]) return;
|
||||
}
|
||||
|
|
@ -623,14 +627,21 @@ in
|
|||
Process {
|
||||
id: wifiConnectProc
|
||||
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 {
|
||||
id: netDisconnectProc
|
||||
command: ["${pkgs.networkmanager}/bin/nmcli", "device", "disconnect", "wlan0"]
|
||||
property string targetDevice: ""
|
||||
command: ["${pkgs.networkmanager}/bin/nmcli", "device", "disconnect", targetDevice]
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
|
|
@ -1007,6 +1018,7 @@ in
|
|||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
netDisconnectProc.targetDevice = netWidget.netDevice;
|
||||
netDisconnectProc.running = true;
|
||||
netDropdown.visible = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue