[GH-ISSUE #148] Network Manager module #4293

Open
opened 2026-05-23 00:52:31 +01:00 by JakeStanger · 23 comments
Owner

Originally created by @JakeStanger on GitHub (May 9, 2023).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/148

Originally assigned to: @Zedfrigg on GitHub.

Is your feature request related to a problem? Please describe.
Currently this is missing functionality that has to be scripted.

Describe the solution you'd like
A new module for managing network connections that connects to the NetworkManager service. This should primarily focus on WiFi connections, but Ethernet and VPN connections are also on the table.

Describe alternatives you've considered
The custom module can currently be used to achieve basic functionality but this is sub-par.

Additional context
Crate that looks hopeful for this: https://crates.io/crates/network-manager

Originally created by @JakeStanger on GitHub (May 9, 2023). Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/148 Originally assigned to: @Zedfrigg on GitHub. **Is your feature request related to a problem? Please describe.** Currently this is missing functionality that has to be scripted. **Describe the solution you'd like** A new module for managing network connections that connects to the `NetworkManager` service. This should primarily focus on WiFi connections, but Ethernet and VPN connections are also on the table. **Describe alternatives you've considered** The custom module can currently be used to achieve basic functionality but this is sub-par. **Additional context** Crate that looks hopeful for this: https://crates.io/crates/network-manager
Author
Owner

@yavko commented on GitHub (Jun 22, 2023):

Problem is all the network manager bindings I could find use the dbus crate, and not zbus :/

<!-- gh-comment-id:1603036540 --> @yavko commented on GitHub (Jun 22, 2023): Problem is all the network manager bindings I could find use the `dbus` crate, and not `zbus` :/
Author
Owner

@JakeStanger commented on GitHub (Jun 22, 2023):

How much of a problem is that? Obviously pure rust is better and I'd rather avoid bringing even more deps into the mix, but if it works it works right?

<!-- gh-comment-id:1603038853 --> @JakeStanger commented on GitHub (Jun 22, 2023): How much of a problem is that? Obviously pure rust is better and I'd rather avoid bringing *even more* deps into the mix, but if it works it works right?
Author
Owner

@yavko commented on GitHub (Jun 22, 2023):

How much of a problem is that? Obviously pure rust is better and I'd rather avoid bringing even more deps into the mix, but if it works it works right?

I'm pretty sure the dbus crate doesn't support async

<!-- gh-comment-id:1603040775 --> @yavko commented on GitHub (Jun 22, 2023): > How much of a problem is that? Obviously pure rust is better and I'd rather avoid bringing _even more_ deps into the mix, but if it works it works right? I'm pretty sure the `dbus` crate doesn't support async
Author
Owner

@JakeStanger commented on GitHub (Jun 22, 2023):

Not ideal, but that's okay - you can use tokio's spawn_blocking to delegate it to its own task and avoid blocking the main thread

<!-- gh-comment-id:1603042712 --> @JakeStanger commented on GitHub (Jun 22, 2023): Not ideal, but that's okay - you can use tokio's `spawn_blocking` to delegate it to its own task and avoid blocking the main thread
Author
Owner

@yavko commented on GitHub (Jun 22, 2023):

Thats true, also seems https://crates.io/crates/network-manager is only updated on the github, and not on crates.io

<!-- gh-comment-id:1603047842 --> @yavko commented on GitHub (Jun 22, 2023): Thats true, also seems https://crates.io/crates/network-manager is only updated on the github, and not on crates.io
Author
Owner

@JakeStanger commented on GitHub (Jun 22, 2023):

Mm yeah didn't spot that. Looks like they've been working towards libnm-rs which suffers from the same thing, and has a lot of git dependencies.

I guess that isn't a complete blocker, but I'd like to try and resolve that before this can be called complete.

<!-- gh-comment-id:1603056434 --> @JakeStanger commented on GitHub (Jun 22, 2023): Mm yeah didn't spot that. Looks like they've been working towards [libnm-rs](https://github.com/balena-io-modules/libnm-rs) which suffers from the same thing, and has a lot of git dependencies. I guess that isn't a complete blocker, but I'd like to try and resolve that before this can be called complete.
Author
Owner

@yavko commented on GitHub (Jun 22, 2023):

Is using zbus on its own hard?

<!-- gh-comment-id:1603060337 --> @yavko commented on GitHub (Jun 22, 2023): Is using zbus on its own hard?
Author
Owner

@yavko commented on GitHub (Jun 22, 2023):

Forking libnm is also a possibility, seems to only use git deps because of glib, maybe a libnm-ironbar package could be published

<!-- gh-comment-id:1603067093 --> @yavko commented on GitHub (Jun 22, 2023): Forking libnm is also a possibility, seems to only use git deps because of glib, maybe a libnm-ironbar package could be published
Author
Owner

@JakeStanger commented on GitHub (Jun 22, 2023):

Is using zbus on its own hard?

From my (little) experience, it's not easy but it's not too bad. It depends a bit on the interface, but is certainly nicer than working with Wayland protocols.

Forking libnm is also a possibility

Not against it. I'd rather not have to maintain another library myself if I don't have to but as a last resort, sure.

<!-- gh-comment-id:1603070598 --> @JakeStanger commented on GitHub (Jun 22, 2023): > Is using zbus on its own hard? From my (little) experience, it's not *easy* but it's not too bad. It depends a bit on the interface, but is certainly nicer than working with Wayland protocols. > Forking libnm is also a possibility Not against it. I'd rather not have to maintain another library myself if I don't have to but as a last resort, sure.
Author
Owner

@madushan1000 commented on GitHub (Oct 13, 2023):

I noticed that you're already using Gio, Gio also has decent dbus support with async if you want to write something from scratch.

<!-- gh-comment-id:1761726229 --> @madushan1000 commented on GitHub (Oct 13, 2023): I noticed that you're already using Gio, Gio also has decent dbus support with async if you want to write something from scratch.
Author
Owner

@JakeStanger commented on GitHub (Oct 13, 2023):

That's good to know, cheers :)

<!-- gh-comment-id:1762251811 --> @JakeStanger commented on GitHub (Oct 13, 2023): That's good to know, cheers :)
Author
Owner

@JakeStanger commented on GitHub (Mar 3, 2024):

Hey @zedfrigg I've seen you've been working on a NM module in your own fork. Do you have plans to merge that into the upstream? If not, can I take that as the basis for the upstream implementation? Cheers

<!-- gh-comment-id:1975204842 --> @JakeStanger commented on GitHub (Mar 3, 2024): Hey @zedfrigg I've seen you've been working on a NM module in [your own fork](https://github.com/Zedfrigg/ironbar/tree/feat/networkmanager). Do you have plans to merge that into the upstream? If not, can I take that as the basis for the upstream implementation? Cheers
Author
Owner

@Zedfrigg commented on GitHub (Mar 6, 2024):

Yes I am planning to upstream it! It does need some more work first as it doesn't handle all connection types well (e.g. VPNs), but I will continue working on it when I have the time.

<!-- gh-comment-id:1979878021 --> @Zedfrigg commented on GitHub (Mar 6, 2024): Yes I am planning to upstream it! It does need some more work first as it doesn't handle all connection types well (e.g. VPNs), but I will continue working on it when I have the time.
Author
Owner

@JakeStanger commented on GitHub (Mar 6, 2024):

Awesome! In that case I'll assign this issue to you. That's a big undertaking so I really appreciate it. Let me know if you need a hand, or if you're tight on time and want me to take over.

<!-- gh-comment-id:1980493153 --> @JakeStanger commented on GitHub (Mar 6, 2024): Awesome! In that case I'll assign this issue to you. That's a big undertaking so I really appreciate it. Let me know if you need a hand, or if you're tight on time and want me to take over.
Author
Owner

@Zedfrigg commented on GitHub (Mar 7, 2024):

Will do if needed, thanks!

<!-- gh-comment-id:1982090867 --> @Zedfrigg commented on GitHub (Mar 7, 2024): Will do if needed, thanks!
Author
Owner

@nyadiia commented on GitHub (Mar 26, 2024):

not to bump issues but what's the status on this?

<!-- gh-comment-id:2020719410 --> @nyadiia commented on GitHub (Mar 26, 2024): not to bump issues but what's the status on this?
Author
Owner

@Zedfrigg commented on GitHub (Mar 27, 2024):

I unfortunately have not had the time yet to work on this further. What may be a good idea however is to upstream what I have now, and then an improved version later.

The module is functional in its current state, the icon displayed directly corresponds to the PrimaryConnectionType property of the NetworkManager DBus API. The drawback of this is that for example if you have an active VPN connection, it is reported as the primary connection, and you have no way of knowing whether you're for example connected to a wifi network. Because of this I'm planning to rewrite this module to look at the different active connections directly, and display multiple icons for wifi, cellular, VPNs, etcetera (like e.g. Gnome or Android). Unfortunately the logic for this is non-trivial, so it will take some more time.

All this brings me to a question for @JakeStanger: would you be okay with me upstreaming this over multiple PRs, one now for the minimal functionality, and more later?

<!-- gh-comment-id:2023186227 --> @Zedfrigg commented on GitHub (Mar 27, 2024): I unfortunately have not had the time yet to work on this further. What may be a good idea however is to upstream what I have now, and then an improved version later. The module is functional in its current state, the icon displayed directly corresponds to the `PrimaryConnectionType` property of the NetworkManager DBus API. The drawback of this is that for example if you have an active VPN connection, it is reported as the primary connection, and you have no way of knowing whether you're for example connected to a wifi network. Because of this I'm planning to rewrite this module to look at the different active connections directly, and display multiple icons for wifi, cellular, VPNs, etcetera (like e.g. Gnome or Android). Unfortunately the logic for this is non-trivial, so it will take some more time. All this brings me to a question for @JakeStanger: would you be okay with me upstreaming this over multiple PRs, one now for the minimal functionality, and more later?
Author
Owner

@JakeStanger commented on GitHub (Mar 27, 2024):

Yes, it sounds like it's in a good enough state that we can look into merging what's there and then work on improvements. We can just open an issue for the VPN bits or leave this open, and/or a note in the docs.

It'll be a while before the next release goes out so we'll have time to test, fix, tweak etc before I'd consider it stable anyway.

The module just displays connection state at the moment and doesn't provide control (ie ability to connect to network etc) right?

<!-- gh-comment-id:2023325047 --> @JakeStanger commented on GitHub (Mar 27, 2024): Yes, it sounds like it's in a good enough state that we can look into merging what's there and then work on improvements. We can just open an issue for the VPN bits or leave this open, and/or a note in the docs. It'll be a while before the next release goes out so we'll have time to test, fix, tweak etc before I'd consider it stable anyway. The module just displays connection state at the moment and doesn't provide control (ie ability to connect to network etc) right?
Author
Owner

@Zedfrigg commented on GitHub (Mar 30, 2024):

Great, I added a note in the module docs explaining this.

And yeah, that's correct. It's pretty bare bones at the moment, it's literally just an icon for the network state, it can't even tell you what what SSID you're connected to for example. I looked into adding this, but until the aforementioned refactor is done it'd just be a hack (see here for the details) and I'd rather not invent a square wheel first and then a round one later.

Let me know if that's acceptable. In the meantime I've opened a PR for merging what we have now.

<!-- gh-comment-id:2028217220 --> @Zedfrigg commented on GitHub (Mar 30, 2024): Great, I added a note in the module docs explaining this. And yeah, that's correct. It's pretty bare bones at the moment, it's literally just an icon for the network state, it can't even tell you what what SSID you're connected to for example. I looked into adding this, but until the aforementioned refactor is done it'd just be a hack (see [here](https://github.com/Zedfrigg/ironbar/blob/ed9332d854169bb99f3efb14f67b3d8a8a2710c4/src/modules/networkmanager.rs#L58) for the details) and I'd rather not invent a square wheel first and then a round one later. Let me know if that's acceptable. In the meantime I've opened a PR for merging what we have now.
Author
Owner

@JakeStanger commented on GitHub (Mar 30, 2024):

I think something is better than nothing at this stage, so long as it works reliably.

It will be worth brainstorming a roadmap of sorts for this to make sure further updates stay on track and there's a finished module in site. Let me know your thoughts on that.

<!-- gh-comment-id:2028280255 --> @JakeStanger commented on GitHub (Mar 30, 2024): I think something is better than nothing at this stage, so long as it works reliably. It will be worth brainstorming a roadmap of sorts for this to make sure further updates stay on track and there's a finished module in site. Let me know your thoughts on that.
Author
Owner

@Zedfrigg commented on GitHub (Aug 4, 2024):

@JakeStanger should this issue be closed now, or will we use it to track enhancements to the NM module?

<!-- gh-comment-id:2267665148 --> @Zedfrigg commented on GitHub (Aug 4, 2024): @JakeStanger should this issue be closed now, or will we use it to track enhancements to the NM module?
Author
Owner

@JakeStanger commented on GitHub (Aug 4, 2024):

I think we use it to track progress, as this isn't where I'd want it to be to consider it a complete module.

I'd like to see the module make nm-applet redundant, but I'd consider the following must-haves above all else:

  • Better network connectivity status info (wifi strength etc)
  • Ability to connect to WiFi networks
<!-- gh-comment-id:2267705294 --> @JakeStanger commented on GitHub (Aug 4, 2024): I think we use it to track progress, as this isn't where I'd want it to be to consider it a complete module. I'd like to see the module make nm-applet redundant, but I'd consider the following must-haves above all else: - Better network connectivity status info (wifi strength etc) - Ability to connect to WiFi networks
Author
Owner

@Rodrigodd commented on GitHub (Aug 4, 2024):

For the record, I have at least implemented WiFi Strength and icon configuration on this PR https://github.com/Zedfrigg/ironbar/pull/1, on top of another branch by @JakeStanger.

<!-- gh-comment-id:2267860088 --> @Rodrigodd commented on GitHub (Aug 4, 2024): For the record, I have at least implemented WiFi Strength and icon configuration on this PR https://github.com/Zedfrigg/ironbar/pull/1, on top of another branch by @JakeStanger.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/ironbar#4293
No description provided.