firecat53 / networkmanager-dmenu Goto Github PK
View Code? Open in Web Editor NEWControl NetworkManager via dmenu
License: MIT License
Control NetworkManager via dmenu
License: MIT License
Hi Scott,
Hope this finds you well. I've been extremely happy using nmcli-dmenu over the last few month. A couple of weeks ago, I switched from dmenu to rofi:
https://davedavenport.github.io/rofi/
for its window switching ability (installed as rofi-git from AUR). Is there the possibility of extending nmcli-dmenu to support rofi?
Thanks in advance,
halocaridina
Hello,
Currently, '==' is used to show which connection is active. I don't know what the general opinion on this is, but I don't find it very appealing. I suggest using something like ∙ (U+2219) instead.
networkmanager-dmenu/networkmanager_dmenu
Line 424 in 96ea650
Thanks for your work.
Please include screenshots or asciinema videos for the layman. Please take note from the Wireguard install/quick start guide for how to do that. Also, please write down the exact step by step procedure in your GitHub front page.
So, the reason being, if you are not targeted a specific user group and make it available for everyone, make sure you expose enough details in clear form.
It is a free suggestion, you are free to ignore.
When I try to the run the script on debian stable I get the following error:
Traceback (most recent call last):
File "/home/fluf/.scripts/networkmanager-dmenu", line 707, in <module>
run()
File "/home/fluf/.scripts/networkmanager-dmenu", line 683, in run
wgs = [i for i in CONNS if i.is_type(NM.SETTING_WIREGUARD_SETTING_NAME)]
File "/home/fluf/.scripts/networkmanager-dmenu", line 683, in <listcomp>
wgs = [i for i in CONNS if i.is_type(NM.SETTING_WIREGUARD_SETTING_NAME)]
File "/usr/lib/python3/dist-packages/gi/module.py", line 132, in __getattr__
self.__name__, name))
AttributeError: 'gi.repository.NM' object has no attribute 'SETTING_WIREGUARD_SETTING_NAME'
Seems like it might be a problem with the gi library in python, but I'm not sure.
Arch
Linux-nvme 4.9-1
Networkmanager 1.4.4-1
Networkmanager-openvpn 1.2.6-1
Activating saved system connection for openvpn in nmtui I am prompted to enter a password. I type in password and it successfully connects.
Opening nmcli-dmenu, scroll down to select same system connection for openvpn results in nothing happening. There is no password prompt like nmtui. Password is saved in the system connection file under
[vpn-secrets]
password=mypassword
When I Launch connection manager, it detects last used by nmtui (based on time) but never indicates that nmcli-dmenu has used it.
This is my first attempt at openvpn so if I got something wrong I would greatly appreciate any feedback to the right direction. Thank you for sharing as well!
Hi there!
I'm not able to connect to an exsisting VPN connection without nm-applet launched. Once it is launched, networkmanager_dmenu becomes able to connect.
Traceback (most recent call last):
File "/usr/bin/networkmanager_dmenu", line 15, in
import configparser
ImportError: No module named configparser
Running networkmanager_dmenu gives me this error running debian
When I try to disconnect from the currently connected wifi, I get this:
File "./networkmanager_dmenu", line 690, in <module>
run()
File "./networkmanager_dmenu", line 686, in run
sel()
File "./networkmanager_dmenu", line 246, in __call__
self.func(*self.args)
File "./networkmanager_dmenu", line 252, in process_ap
CLIENT.deactivate_connection_async(nm_ap)
TypeError: Argument 1 does not allow None as a value
There are no problems when switching to a different wifi network
I'm trying to set this up with rofi, and see the following when I try to run nmcli_dmenu on Arch (installed from AUR):
Traceback (most recent call last):
File "/usr/bin/nmcli_dmenu", line 419, in <module>
run()
File "/usr/bin/nmcli_dmenu", line 377, in run
adapter = choose_adapter()
File "/usr/bin/nmcli_dmenu", line 85, in choose_adapter
return all_adps[0].strip()
IndexError: list index out of range
Here is my config.ini:
[dmenu]
#fn = -*-terminus-medium-*-*-*-16-*-*-*-*-*-*-*
dmenu_command = /usr/bin/rofi -i -m 0 -no-levenshtein-sort
# # Note that dmenu_command can contain arguments as well like `rofi -width 30`
# # Rofi and dmenu are set to case insensitive by default `-i`
# fn = font string
# nb = normal background (name, #RGB, or #RRGGBB)
# nf = normal foreground
# sb = selected background
# sf = selected foreground
# b = (just set to empty value and menu will appear at the bottom
# m = number of monitor to display on
# p = Custom Prompt for the networks menu
# pinentry = Pinentry command
[editor]
terminal = termite
gui_if_available = True
# terminal = <name of terminal program>
# gui_if_available = <True or False>
nmcli dev
shows the following devices:
nmcli dev
DEVICE TYPE STATE CONNECTION
eno1 ethernet connected Wired connection 2
virbr0 bridge disconnected --
lo loopback unmanaged --
virbr0-nic tun unmanaged --
Can we have please a git tag / release? (for packaging purposes)
It's be nice if we could configure what information is shown about WiFi networks. For example, I might not care about showing the strength, or I might want to hide security info as it will become somewhat evident once I'm prompted for a password.
Hi, recently I did some update to system and networkmanager-dmenu break without me knowing why
Try to invoke networkmanager-dmenu from CLI show some error as
(process:37988): GLib-GObject-CRITICAL **: 23:25:22.062: g_object_get_qdata: assertion 'G_IS_OBJECT (object)' failed
(process:37988): GLib-GObject-CRITICAL **: 23:25:22.062: g_object_set_qdata_full: assertion 'G_IS_OBJECT (object)' failed
(process:37988): GLib-GObject-CRITICAL **: 23:25:22.062: g_object_set_qdata_full: assertion 'G_IS_OBJECT (object)' failed
(process:37988): GLib-GObject-CRITICAL **: 23:25:22.062: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
Networkmanager-dmenu installed from master via AUR
python-gobject version is 3.36.1-1, installed from manjaro repository
Hope you can give me some clues. Tks in advance
I'm not sure if this has anything to do with the distro, but I was using networkmanager_dmenu on ElementaryOS with i3wm dual booted with macOS, recently changed to single boot Kubuntu with i3wm. I get this behavior where when trying to connect to a password-protected network with networkmanager_dmenu, i'm asked for a passphrase, but when connecting with nm-applet, it sort of just works. Any ideas?
Nothing of major consequence, it would just be nice to have another release for packaging purposes.
My shared workspace just upgraded their wifi to use 802.1x which now requires a username and password. It would be awesome if this project can support that. NetworkManager does support it, but you have to use nmcli to connect (nmtui doesn't even support it)
Nmcli has a different output format as of networkmanager 1.4. I'll probably have to parse the version and provide support for 1.2.x-1.4.x.
I set the same network name on two different wireless cards. After that, networkmanager-dmenu refuses to start:
$ ./networkmanager_dmenu
Traceback (most recent call last):
File "./networkmanager_dmenu", line 539, in <module>
run()
File "./networkmanager_dmenu", line 522, in run
ap_actions = create_ap_actions(*create_ap_list(adapter))
File "./networkmanager_dmenu", line 504, in create_ap_list
raise ValueError("Multiple connection profiles match"
ValueError: Multiple connection profiles match the wireless AP
The last update broke usage without a config file. Unindent once at https://github.com/firecat53/nmcli-dmenu/blob/8616eb3cb1cf80b886a5fd08c498b845b8db8b4b/nmcli_dmenu#L60 and everything should be fine. I would make a pull request, but I'm lazy and this is a trivial fix.
One feature from nm-applet
that I miss in networkmanager-dmenu
are "exit status" notifications. Especially because dmenu itself provides no indication of wether your action was (un)succesfull, and, optionally, why something failed. I therefore often have to rerun networkmanager-dmenu
in order to know wether an action has succeeded, sometimes multiple times.
Adding notifications when an action is completed (or failed) would remedy the need to run this program multiple times to know what's going on. For example, nm-applet
uses notifications to let the user know wether the device is in the process of connecting, and, when it finishes, wether the connection attempt was succesfull. It's likely that not everyone needs this (extra) reassurance, so I suppose showing notifications would be made optional. (In a more minimal/unix-y fashion, it could also be an idea to only show failures to the user)
This seems easy enough, so I could implement this myself, if/when I find time.
I have this error when try to connect new wifi
arkhan@Pantheon ~ % /usr/bin/nmcli_dmenu
/usr/bin/nmcli_dmenuTraceback (most recent call last):
File "/usr/lib/python3.5/configparser.py", line 1135, in _unify_values
sectiondict = self._sections[section]
KeyError: 'dmenu'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/nmcli_dmenu", line 370, in <module>
run()
File "/usr/bin/nmcli_dmenu", line 363, in run
pw = get_passphrase()
File "/usr/bin/nmcli_dmenu", line 295, in get_passphrase
pinentry = conf.get("dmenu", "pinentry")
File "/usr/lib/python3.5/configparser.py", line 778, in get
d = self._unify_values(section, vars)
File "/usr/lib/python3.5/configparser.py", line 1138, in _unify_values
raise NoSectionError(section)
configparser.NoSectionError: No section: 'dmenu'
Thanks
Is there a reason not to list saved connections.
Use case is for me at least very common.
For examble, I open my phone hotspot. Laptop always delays to show. But I know it is now open. I force it to connect and it always works with nm-applet. But for now, since nm-dmenu doesnt list it, I cant do it and have to reach to my mouse.
I get the following error, when selecting my active wifi connection:
File "./networkmanager_dmenu", line 547, in <module>
run()
File "./networkmanager_dmenu", line 543, in run
sel()
File "./networkmanager_dmenu", line 188, in __call__
self.f(*self.args)
File "./networkmanager_dmenu", line 193, in process_ap
client.deactivate_connection_async(ap)
TypeError: argument active: Expected NM.ActiveConnection, but got gi.repository.NM.RemoteConnection
git bisect identifies the following commit as the one introducing the error: 8d7e80a
I will have a look at it now.
I'm getting this error when trying to run the script:
Traceback (most recent call last):
File "./networkmanager_dmenu", line 25, in <module>
gi.require_version('NM', '1.0')
File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 102, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace NM not available
Unsure what it's about?
Hi firecat53,
Thank you for creating and supporting nmcli-dmenu (currently using r9.0a6fa27-4 from AUR).
Is there the possibility of adding support for dmenu variants? Specifically:
aur/dmenu2 0.2-1 (22) [installed]
Fork of dmenu with many useful patches applied and additional options like screen select, dim or opacity change
Example config from ~/.config/i3/config:
bindsym $mod+d exec --no-startup-id dmenu_run -i -fn "Arimo-10" -h 20 -p FIND: -w 900 -x 500 -y 400 -l 8 -o 0.90 -dim .70
Thanks in advance for considering this and thank you again for the nice work.
With dmenu_command = "rofi -dmenu"
(otherwise I get rofi daemon mode is now removed), I get the following error:
Traceback (most recent call last):
File "./networkmanager_dmenu", line 547, in <module>
run()
File "./networkmanager_dmenu", line 542, in run
gsm_actions, other_actions)
File "./networkmanager_dmenu", line 306, in get_selection
env=ENV).communicate(input=inp_bytes)[0].decode(ENC)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
As I said in the other issue, however, it does work with dmenu_command = "dmenu"
. Any ideas?
When trying to run "Delete a connection" and/or "Rescan Wi-Fi networks", I get the following errors, respectively:
/usr/bin/networkmanager_dmenu:177: DeprecationWarning: NM.DeviceWifi.request_scan is deprecated
dev.request_scan()
/usr/bin/networkmanager_dmenu:238: DeprecationWarning: NM.RemoteConnection.delete is deprecated
self.func()
This might be an issue for other commands too
EDIT: "Enable/Disable Wifi/Networking" (Wifi = line 466, Networking = line 457) works, but still gives a deprecation warning:
/usr/bin/networkmanager_dmenu:466: DeprecationWarning: NM.Client.wireless_set_enabled is deprecated
CLIENT.wireless_set_enabled(enable)
It's posible to make rofi variant...?
https://davedavenport.github.io/rofi/
How do I connect to a network with a hidden ssid? Is there a way with this?
I remember that my wifi signal strength used to show in bars but now all I get is the stars. I like the look of the bars allot better but cannot find out how to make them appear. I have looked around and connot find info on it.
Hi firecat53,
Hope this finds you well. Found the following issue with nmcli-dmenu:
Currently using openconnect for VPN:
extra/networkmanager-openconnect 0.9.10.0-1 [installed]
NetworkManager VPN integration for openconnect
extra/openconnect 1:6.00-1 [installed]
Open client for Cisco AnyConnect VPN
The entry comes up as:
Work_VPN:VPN
in the nmcli-dmenu list. Selecting the entry results in no response (i.e., no Openconnect window opens) when nm-applet IS NOT running.
However, if nm-applet IS running, Openconnect window opens, password can be entered and connection is sucessful.
Perhaps a parsing error in nmcli-dmenu?
Cheers and thanks again for the useful software.
Hi,
I see that multiple adapters are managed: https://github.com/firecat53/networkmanager-dmenu/blob/master/networkmanager_dmenu#L121
But when I connect my external USB adapter, I'm not asked which one to choose.
So I only see one adapter scan result.
I'm using the AUR package.
I tried both with rofi
and dmenu
.
Would it be possible to support rofi's custom modes? In rofi man page it says:
Custom modes can be added using the internal 'script' mode. Each mode has two parameters:
<name>:<script>
Example: Have a mode 'Workspaces' using the i3_switch_workspaces.sh script:
rofi -modi "window,run,ssh,Workspaces:i3_switch_workspaces.sh" -show Workspaces
So I tried the following:
rofi -modi NetworkManager:`which networkmanager_dmenu` -show NetworkManager
But rofi is entirely empty. So this doesn't seem to work. networkmanager-dmenu only works if I run it as a stand-alone script by itself. But then I cannot combine it with other modes. Would it be possible to add support for this? Then, networkmanager-dmenu
could be used as one mode alongside with other modes. For instance, as:
rofi -modi run,ssh,NetworkManager:`which networkmanager_dmenu` -show run
Only the connected WiFI displayed, if i click nm-applet
to show all WiFIs
first, then run networkmanager-dmenu
, all WiFIs will show normally.
It looks like must first call nm_device_wifi_request_scan
and wait for scan result
ready, the scan result will cache in fewer seconds. If you watch nm-applet
it
show connected WiFi first, one second later it will show other WiFIs, maybe it
did a scan.
For now we can run nmcli
to do scan before run networkmanager-dmenu
:
nmcli d wifi >/dev/null 2>&1 && networkmanager_dmenu
I'm um ubuntu 18.04, when I try to launch with python2.7 I get this error:
Traceback (most recent call last):
File "/usr/local/bin/networkmanager_dmenu", line 689, in <module>
run()
File "/usr/local/bin/networkmanager_dmenu", line 662, in run
ap_actions = create_ap_actions(*create_ap_list(adapter, active))
File "/usr/local/bin/networkmanager_dmenu", line 295, in create_ap_actions
max_len_sec, bars)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)
I'm changing python version by symlinking /usr/bin/python to 2.7 or 3.6
Traceback_ (most recent call last):
File "/usr/bin/networkmanager_dmenu", line 598, in <module> run()
File "/usr/bin/networkmanager_dmenu", line 593, in run gsm_actions, other_actions)
File "/usr/bin/networkmanager_dmenu", line 334, in get_selection
inp_bytes = "\n".join([str(i) for i in inp]).encode(ENC)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 152: ordinal not in range(128)
when trying to launch it.
So it looks like it finds this character "â" somewhere and poops out. Obviously, it shouldn't be able to find this character anywhere in networkmanager's menus, so it should be somewhere that allows for other input (Access point names perhaps). And indeed, after disabling WiFi, it managed to launch just fine. Looking at nm_applet, I can't find â in any of the AP names, but maybe networkmanager handles this by showing a different character? (a for example).
Edit: @xnick - (if this is the same one that opened the Arch AUR issue), any chance you can insert a debugging stop around line 325 and post the 'inp' variable with the failing value?
Hi,
When networkmanager-dmenu is lanched the second or the third time, the WiFI list is stale. I've to toggle WiFI off/on in order to get latest SSIDs. Is there a way to configure networkmanager-dmenu so it'll have the latest SSID list each time it's launched.
Thank you!
When trying to connect to a already configured connection, the networkmanager-dmenu asks for a passphrase as if the connection was totally new.
On Debian sid, since nm-util-dev 1.8.4-2, networkmanager-dmenu stopped working. The reason is it switched from gir1.2-nm-1.0 to gir1.2-networkmanager-1.0. Should we convert "NM" to "NetworkManager"? Or just (temporary) add gir1.2-nm-1.0 to the requirements?
Thank you for the cool tool!
I was wondering how to replace the *** with bars instead that represent the strength of the signal?
Hi,
First, thank you for that great tool. I appreciate your effort!
My issue here is two-fold:
The OpenVPN connection uses a certificate and stores already the username. So, it should ask for the password, which it does with nmtui. However, after hitting enter in dmenu, nothing happens. So far, I understood within the code, it should ask for a prompt, right?
OpenConnect is a bit different, and it may never work with my configuration. It's the VPN to my university network, so besides needing a certificate, it asks for username and password—no option to store the credentials in the config, as far as I know. Maybe you have an idea here, which would be great. However, the same goes here as well: Hitting enter closes the menu, and nothing happens.
The prompt works for WiFi passphrases. The VPNs work either with
nmcli connection up openvpnconnection
and
nmcli connection up ciscoopenconnectconnection --ask
nmtui freezes with the ciscoopenconnectconnection.
Thanks,
Sandro
With gui_if_available = False
,
Start a vpn shows GUI password prompt.
Thanks
wofi has slightly different arguments to rofi, so unfortunately not just a drop in replacement
I get the following error when wifi is disabled in NetworkManager
Traceback (most recent call last):
File "/usr/bin/networkmanager_dmenu", line 517, in
run()
File "/usr/bin/networkmanager_dmenu", line 500, in run
ap_actions = create_ap_actions(*create_ap_list(adapter))
File "/usr/bin/networkmanager_dmenu", line 479, in create_ap_list
active_ap_con = active_ap.filter_connections(conns)
AttributeError: 'NoneType' object has no attribute 'filter_connections'
Look at using nmtui as default when nm-applet isn't installed. The only option I see missing (that is immediately obvious to me) in nmtui is the ability to use a VPN with a connection by default
For the packagers! :)
networkmanager-dmenu fails to start if the "wifi_chars" option is enabled, because it is being sent to the dmenu command as an argument. Fixed by PR #78.
Hi!
From nmtui
is possible to activate/edit a bluetooth connection like as the others but from networkmanager_dmenu
those connections are not shown.
In this example bluetooth connections are listed:
=== OnePlus X Network : /org/freedesktop/NetworkManager/Settings/10 ===
connection.id: OnePlus X Network
connection.uuid: 000000000-0000-0000-EDITED
connection.type: bluetooth
connection.auth-retries: -1
connection.autoconnect: False
connection.autoconnect-priority: 0
connection.autoconnect-retries: -1
connection.autoconnect-slaves: <enum NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT of type NM.SettingConnectionAutoconnectSlaves>
connection.gateway-ping-timeout: 0
connection.interface-name: None
connection.lldp: -1
connection.master: None
connection.mdns: -1
connection.metered: <enum NM_METERED_UNKNOWN of type NM.Metered>
connection.name: connection
connection.permissions: []
connection.read-only: False
connection.secondaries: []
connection.slave-type: None
connection.stable-id: None
connection.timestamp: 2125389310
connection.zone: None
bluetooth.bdaddr: ED:IT:ED:AA:AA:AA
bluetooth.name: bluetooth
bluetooth.type: panu
ipv4.addresses: <GLib.PtrArray object at 0x7f0071e38948 (GPtrArray at 0x558804cda380)>
ipv4.dad-timeout: -1
ipv4.dhcp-client-id: None
ipv4.dhcp-fqdn: None
ipv4.dhcp-hostname: None
ipv4.dhcp-send-hostname: True
ipv4.dhcp-timeout: 0
ipv4.dns: []
ipv4.dns-options: []
ipv4.dns-priority: 0
ipv4.dns-search: []
ipv4.gateway: None
ipv4.ignore-auto-dns: False
ipv4.ignore-auto-routes: False
ipv4.may-fail: False
ipv4.method: auto
ipv4.name: ipv4
ipv4.never-default: False
ipv4.route-metric: -1
ipv4.route-table: 0
ipv4.routes: <GLib.PtrArray object at 0x7f0071e38948 (GPtrArray at 0x558804cda360)>
ipv6.addr-gen-mode: 1
ipv6.addresses: <GLib.PtrArray object at 0x7f0071e38948 (GPtrArray at 0x558804cda340)>
ipv6.dad-timeout: -1
ipv6.dhcp-duid: None
ipv6.dhcp-hostname: None
ipv6.dhcp-send-hostname: True
ipv6.dhcp-timeout: 0
ipv6.dns: []
ipv6.dns-options: []
ipv6.dns-priority: 0
ipv6.dns-search: []
ipv6.gateway: None
ipv6.ignore-auto-dns: False
ipv6.ignore-auto-routes: False
ipv6.ip6-privacy: <enum NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN of type NM.SettingIP6ConfigPrivacy>
ipv6.may-fail: True
ipv6.method: auto
ipv6.name: ipv6
ipv6.never-default: False
ipv6.route-metric: -1
ipv6.route-table: 0
ipv6.routes: <GLib.PtrArray object at 0x7f0071e38948 (GPtrArray at 0x558804cda220)>
ipv6.token: None
proxy.browser-only: False
proxy.method: 0
proxy.name: proxy
proxy.pac-script: None
proxy.pac-url: None
Add options to enable/disable networking or wifi like in nm-applet
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.