Sitelet https://web.archive.org/web/20220409161858/https://github.com/polybar/polybar/issues/2551
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for regex or globs in interface name (Network module) #2551

Open
mil-ad opened this issue Nov 11, 2021 · 7 comments
Open

Support for regex or globs in interface name (Network module) #2551

mil-ad opened this issue Nov 11, 2021 · 7 comments
Assignees

Comments

@mil-ad
Copy link

@mil-ad mil-ad commented Nov 11, 2021

It'd be nice if we could use globs for interface names in the network module. My network link has different names on different machines but ideally I'd like to use the same config file. It'd be nice if I could use something like interface = en*

@patrick96
Copy link
Member

@patrick96 patrick96 commented Nov 11, 2021

There is already a new interface-type setting coming in the next release, where you can select either wired or wireless. Would that address your use-case?

@mil-ad
Copy link
Author

@mil-ad mil-ad commented Nov 11, 2021

so does that pick up the first wired interface? What happens if there multiple links? I normally just have one wired interface but its name is different based on computer or the ethernet dongle I use.

@patrick96
Copy link
Member

@patrick96 patrick96 commented Nov 11, 2021

It will choose the first one it finds. If you have multiple wired interfaces, your glob en* will probably match all of them as well.

@mil-ad
Copy link
Author

@mil-ad mil-ad commented Nov 11, 2021

True. As long as this new interface-type does not require explicit interface name I think I'll be fine but globs are probably more flexible? They also match how systemd-network deals with the same issue. An example of /etc/systemd/network/20-wired.network:

[Match]
Name=en*

[Network]
DHCP=ipv4

@patrick96
Copy link
Member

@patrick96 patrick96 commented Jan 17, 2022

Yeah, globs or regexes are definitely more flexible. If anyone wants to implement this, PRs are welcome. Make sure to also comment here, so that we know you are working on it.

Either globs or regex are fine. Using glob (man 3 glob) is more user-friendly but is tied to the filesystem (cannot write tests for it) and I'm not sure how safe it is to pass user-supplied data to it (can it crash the process?). Regex is more flexible and is directly supplied in the standard library.

@mil-ad
Copy link
Author

@mil-ad mil-ad commented Jan 17, 2022

Great, I'll have a go at this weekend

@patrick96
Copy link
Member

@patrick96 patrick96 commented Jan 17, 2022

Perfect 👍

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

No branches or pull requests

2 participants