Skip to content

Conversation

@cpwrs
Copy link

@cpwrs cpwrs commented Jul 6, 2025

Adds basic support for listing wifi devices and networks and attempting a connection. Missing support for connections that require an agent.

Closes #74.

@outfoxxed
Copy link
Member

Why are we linking nm? Should be entirely over dbus

cpwrs added 7 commits July 9, 2025 14:57
NMWireless will be a property of Device (if DeviceType==Wifi). In the
future if many org.freedesktop.networkmanager.Device.* are implemented,
we can use the factory pattern to create an NMDevice with its subdevice
properties and methods.
@outfoxxed
Copy link
Member

I'm not sure what stage of development you're at here and haven't checked code yet, but just so we're clear I'd like to expose this under Quickshell.Network and keep the API clean of NM specific things (an IWD backend has been requested as well).

I don't think I've made that clear so far. (If you've got any questions, @ me here or in the matrix/discord)

@outfoxxed outfoxxed force-pushed the master branch 2 times, most recently from 9d41148 to 4b35d7b Compare July 10, 2025 08:51
@cpwrs cpwrs changed the title NetworkManager Service Quickshell.Network NetworkManager backend Jul 11, 2025
@outfoxxed outfoxxed force-pushed the master branch 2 times, most recently from 525a933 to bb206e3 Compare July 13, 2025 05:02
- Prefer bindables over connections for synced properties
- Remove lambdas from ready and disappeared signal connections
- Add namespaces to Q_PROPERTY definitions
- Remove Network.wifi.defaultDevice (easy to add in userspace)
- Add all devices to a ListView in network.qml
@cpwrs
Copy link
Author

cpwrs commented Sep 5, 2025

@outfoxxed Thanks for the feedback! I think this is ready for another review.

There are a couple bits in here that look completely insane, but judging by the fact that they're on the NM api surface I'm going to assume it's NM's fault.

Yep. Unfortunately the api doesn't have any concept of wifi networks. Had to grab access points from one interface, "active" and "saved" connections from another, and then group them by SSID. It also doesn't give any useful security info, hence the copied code from nmcli.

Other clients do something similar:
https://invent.kde.org/plasma/plasma-nm/-/blob/master/libs/models/networkmodel.cpp?ref_type=heads
https://invent.kde.org/frameworks/networkmanager-qt/-/blob/master/src/wirelessnetwork.cpp?ref_type=heads

@cpwrs cpwrs requested a review from outfoxxed September 5, 2025 18:58
@cpwrs cpwrs changed the title Quickshell.Network NetworkManager backend network: network integration with NetworkManager backend Sep 25, 2025
@cpwrs cpwrs changed the title network: network integration with NetworkManager backend network: add network integration with NetworkManager backend Sep 25, 2025
@outfoxxed outfoxxed force-pushed the master branch 3 times, most recently from a92879d to 9bb2c04 Compare October 4, 2025 20:00
@cpwrs
Copy link
Author

cpwrs commented Oct 8, 2025

@bbedward Would love your feedback on this API. Besides the obvious missing features, does the design make anything difficult for DMS?

@bbedward
Copy link
Contributor

bbedward commented Oct 8, 2025

@bbedward Would love your feedback on this API. Besides the obvious missing features, does the design make anything difficult for DMS?

It looks pretty consistent with quickshell conventions to me. I'd like to see the agent/connection manager, but it's not necessary for the initial integration IMO (the bluez implementation doesn't have an agent either)

Copy link
Member

@outfoxxed outfoxxed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I wasn't able to do a full review today, but I think I got most of the interface. These changes don't necessarily have to be made if you've got a good reason not to though.

@cpwrs
Copy link
Author

cpwrs commented Oct 16, 2025

Resolved all but scan

A few changes to the frontend Network API:
- Expose all devices at the toplevel
- Move wifi rfkill options to the toplevel
- Add WifiSecurityType (backend agnostic)
- Move WifiNetwork signal strength to a qreal from 0.0 to 1.0
- Add extensible BaseNetwork class
@cpwrs
Copy link
Author

cpwrs commented Oct 22, 2025

Made an attempt at WifiScanner following the KDE implementation. Requires deprecated header <time.h> for CLOCK_BOOTTIME -> QDateTime. I like the scanner but the conditional network visibility is inherently hacky because NM. Kept it in one list, networks are visible if scanning or connected or known.

- Add WifiScanner to replace requestScan in API
- Implement NM scanner that avoids rate limit
- Add conditional visibility to networks based on scanner state
- Add gates to backend-specific props in the manual test
- Add WifiDeviceMode and WifiDevice.mode
- Add module.md
- Reimplement NMWirelessNetwork
- Fix mode checking for NMWirelessDevice
onConnectionLoaded/onAccessPointLoaded
- Move security type to bindings in NMAccessPoint and
NMConnectionSettings
@outfoxxed
Copy link
Member

Sorry I haven't looked at this recently, is it ready for review again?

@cpwrs
Copy link
Author

cpwrs commented Nov 24, 2025

@outfoxxed Yep!

I decided to keep WifiNetwork as a group of all access points and connection settings for a given SSID. KDE shows a network item PER conn settings, which makes sense because its only backend (NM) is connection centric. But I think 99% of use is connecting to a network which only has one conn settings. IWD doesn't even allow multiple. Right now, if theres multiple it attempts a connection using the best settings (highest security).

Eventually we'd want to expose the AccessPoint(s) and ConnSetting(s) (only one for IWD) under these networks and expand the connect() function to optionally take a specific AP or settings. This gives feature parity with the NM API for the 1% who actually use multiple settings.

A connection editor and these extensions to WifiNetwork would be a large feature so I was hoping to get the basics merged before that. The biggest issue with not including ConnSetting initially is losing a forget() function that removes the setting. Does a forget() at the WifiNetwork level that deletes ALL its associated settings suffice for now?

Comment on lines +92 to +116
///! Scans for available wifi networks.
/// When enabled, the scanner populates its respective WifiDevice with an active list of available WifiNetworks.
class WifiScanner: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_UNCREATABLE("Scanner can only be acquired through WifiDevice");

// clang-format off
/// True when currently scanning for networks.
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged BINDABLE bindableEnabled);
// clang-format on

public:
explicit WifiScanner(QObject* parent = nullptr);

QBindable<bool> bindableEnabled() { return &this->bEnabled; };
[[nodiscard]] bool enabled() const { return this->bEnabled; };
void setEnabled(bool enabled);

signals:
void enabledChanged(bool enabled);

private:
Q_OBJECT_BINDABLE_PROPERTY(WifiScanner, bool, bEnabled, &WifiScanner::enabledChanged);
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can reduce to a bool property unless there's more functionality to add?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NetworkManager service

4 participants