• Stars
    star
    810
  • Rank 56,306 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 10 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Control NetworkManager via dmenu

Networkmanager-dmenu

Manage NetworkManager connections with dmenu, Rofi, Bemenu, Wofi or fuzzel instead of nm-applet

Features

  • Connect to existing NetworkManager wifi or wired connections
  • Connect to new wifi connections. Requests passphrase if required
  • Connect to existing VPN, Wireguard, GSM/WWAN and Bluetooth connections
  • Enable/Disable wifi, WWAN, bluetooth and networking
  • Launch nm-connection-editor GUI
  • Support for multiple wifi adapters
  • Optional Pinentry support for secure passphrase entry
  • Delete existing connections
  • Rescan wifi networks
  • Uses notify-send for notifications if available

Screencast

Installation

Requirements

  1. Python 3.7+
  2. NetworkManager
  3. Dmenu (X), Rofi (X or XWayland), Wofi (Wayland) or Bemenu (X or Wayland)
  4. Python gobject (PyGObject, python-gobject, etc.)
  5. (Debian/Ubuntu based distros) libnm-util-dev and gir1.2-nm-1.0 (you have to explicitly install the latter on Debian Sid)
  6. (optional) The network-manager-applet package (in order to launch the GUI connection editor, if desired. The nm-applet does not need to be started.)
  7. (optional) Pinentry. Make sure to set which flavor of pinentry command to use in the config file.
  8. (optional) ModemManager for WWAN support.
  9. (optional) notify-send for notifications (connected, disconnected, etc.)

Configuration

  • To customize behavior, copy config.ini.example to ~/.config/networkmanager-dmenu/config.ini and edit.
  • All theming is done through the respective menu programs. Set dmenu_command with the desired options, including things like -i for case insensitivity. See config.ini.example for examples.
  • If using dmenu for passphrase entry (pinentry not set), dmenu options in the [dmenu_passphrase] section of config.ini will set the normal foreground and background colors to be the same to obscure the passphrase. The Suckless password patch -P option is supported if that patch is installed. Rofi, Wofi and Bemenu will use their respective flags for passphrase entry.
  • Set default terminal (xterm, urxvtc, etc.) command in config.ini if desired.
  • Saved connections can be listed if desired. Set list_saved = True under [dmenu] in config.ini. If set to False, saved connections are still accessible under a "Saved connections" sub-menu.
  • If desired, copy the networkmanager_dmenu.desktop to /usr/share/applications or ~/.local/share/applications.
  • If you want to run the script as $USER instead of ROOT
    1. Set PolicyKit permissions. The script is usable for connecting to pre-existing connections without setting these, but you won't be able to enable/disable networking or add new connections.

    2. For bluetooth control, the user needs to have access to /dev/rfkill. On some distros (e.g. Archlinux), /dev/rfkill belongs to a group such as rfkill. In this case, ensure $USER belongs to that group. For other distros (e.g. Fedora), you can use udev to ensure /dev/rfkill belongs to a group. For example, create /etc/udev/rules.d/10-rfkill.rules:

           KERNEL=="rfkill", GROUP="wheel", MODE="0664"
      

      and then ensure $USER belongs to the wheel group.

Config.ini values

Section Key Default Notes
[dmenu] compact False
dmenu_command dmenu Command can include arguments
list_saved False
pinentry None
rofi_highlight False
wifi_chars None String of 4 unicode characters
[dmenu_passphrase] obscure False
obscure_color #222222 Only applicable to dmenu
[editor] gui_if_available True
terminal xterm
[nmdm] rescan_delay 5 Adjust delay in re-opening nmdm following rescan

Usage

networkmanager_dmenu [-h] <menu args>

  • Run script or bind to keystroke combination
  • If desired, menu options can be passed on the command line instead of or in addition to the config file. These will override options in the config file.

MIT License