diff --git a/modules/system.nix b/modules/system.nix index 43821ef..787c2a3 100644 --- a/modules/system.nix +++ b/modules/system.nix @@ -32,6 +32,7 @@ networkmanager = { enable = true; dns = lib.mkForce "systemd-resolved"; + settings.connectivity.uri = "http://nmcheck.gnome.org/check_network_status.txt"; }; nameservers = [ "9.9.9.9" ]; diff --git a/modules/user/default.nix b/modules/user/default.nix index 2c45caa..fbb17a0 100644 --- a/modules/user/default.nix +++ b/modules/user/default.nix @@ -17,7 +17,7 @@ in { users.users.${username} = { isNormalUser = true; uid = 1000; - extraGroups = [ "wheel" ]; + extraGroups = [ "wheel" "networkmanager" ]; initialPassword = "test"; }; diff --git a/modules/user/modules/quickshell/shell/bar/BarContainment.qml b/modules/user/modules/quickshell/shell/bar/BarContainment.qml index 23e36cd..8643fae 100644 --- a/modules/user/modules/quickshell/shell/bar/BarContainment.qml +++ b/modules/user/modules/quickshell/shell/bar/BarContainment.qml @@ -29,6 +29,7 @@ PanelWindow { color: "transparent" WlrLayershell.namespace: "shell:bar" + focusable: tooltip.activeItem != null readonly property Tooltip tooltip: tooltip; Tooltip { diff --git a/modules/user/modules/quickshell/shell/bar/connections/Network.qml b/modules/user/modules/quickshell/shell/bar/connections/Network.qml index 51fa325..6b6143f 100644 --- a/modules/user/modules/quickshell/shell/bar/connections/Network.qml +++ b/modules/user/modules/quickshell/shell/bar/connections/Network.qml @@ -11,7 +11,7 @@ import qs.bar ClickableIcon { id: root required property var bar; - readonly property NetworkDevice adapter: Networking.devices.values[0] + readonly property WifiDevice adapter: Networking.devices.values[0] ?? null readonly property bool connected: adapter.connected readonly property WifiNetwork activeNetwork: adapter.networks.values.find(network => network.connected) @@ -124,6 +124,7 @@ ClickableIcon { device: root.adapter network: modelData width: parent.width + onConnectionAttempted: root.adapter.scannerEnabled = false } } } diff --git a/modules/user/modules/quickshell/shell/bar/connections/NetworkDelegate.qml b/modules/user/modules/quickshell/shell/bar/connections/NetworkDelegate.qml index 896b896..c48089f 100644 --- a/modules/user/modules/quickshell/shell/bar/connections/NetworkDelegate.qml +++ b/modules/user/modules/quickshell/shell/bar/connections/NetworkDelegate.qml @@ -12,17 +12,45 @@ WrapperMouseArea { required property NetworkDevice device required property WifiNetwork network property bool menuOpen: false - readonly property bool showBg: false + property bool passwordRequired: false + readonly property bool showBg: root.passwordRequired hoverEnabled: true + signal connectionAttempted(); + + function tryConnect() { + const connecting = root.network.connected || root.network.state == ConnectionState.Connecting; + if (connecting) root.device.disconnect(); + else { + root.connectionAttempted(); + if (pwField.text != "") root.network.connectWithPsk(pwField.text); + else root.network.connect(); + } + } + onClicked: menuOpen = !menuOpen + Connections { + target: root.network + function onConnectionFailed(reason) { + console.log(reason, reason == ConnectionFailReason.NoSecrets); + pwField.text = ""; + root.passwordRequired = reason == ConnectionFailReason.NoSecrets; + } + + function onStateChanged() { + if (root.network.state == ConnectionState.Connected) { + root.passwordRequired = false; + pwField.text = ""; + } + } + } + WrapperRectangle { - color: root.showBg ? ShellGlobals.colors.widget : "transparent" + color: root.showBg ? ShellGlobals.colors.widget : "transparent" border.width: 1 border.color: root.showBg ? ShellGlobals.colors.widgetOutline : "transparent" radius: 4 - rightMargin: 2 ColumnLayout { RowLayout { @@ -43,11 +71,7 @@ WrapperMouseArea { implicitHeight: 24 implicitWidth: height showAction: root.network.stateChanging - onClicked: { - if (showAction) return; - else if (root.network.connected) root.device.disconnect(); - else root.network.connect(); - } + onClicked: tryConnect() } ClickableIcon { @@ -56,6 +80,25 @@ WrapperMouseArea { implicitWidth: height visible: root.network.known onClicked: root.network.forget() + Layout.rightMargin: 2 + } + } + + TextField { + id: pwField + visible: root.passwordRequired + Layout.fillWidth: true + Layout.margins: 4 + placeholderText: "Password" + echoMode: TextInput.Password + enabled: !(root.network.stateChanging || root.network.connected) + onAccepted: tryConnect() + + background: Rectangle { + //color: "transparent" // ShellGlobals.colors.widget + color: pwField.enabled ? "transparent" : ShellGlobals.colors.widgetActive + border.color: ShellGlobals.colors.widgetOutline + radius: 4 } } }