diff --git a/settings/hyprland.nix b/settings/hyprland.nix index 7da3b7e..815ad6d 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -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; }