You are not logged in.

#1 2014-05-16 17:06:16

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

nmcli-dmenu: controlling NetworkManager via dmenu

Having recently switched to NetworkManager (connman was just too unstable for me on some connections), I was trying to avoid running nm-applet and stalonetray with my Monsterwm setup, so I came up with this script to manage NetworkManager via dmenu and nmcli. From the README:

Nmcli-dmenu
===============

Small script to manage NetworkManager connections with dmenu 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 connections 
- Enable/Disable networking
- Launch nm-connection-editor GUI

License
-------

- MIT

Requirements
------------

1. Python 2.7+ or 3.2+
2. NetworkManager
3. Dmenu

Installation
------------

- Edit dmenu parameters if desired
- Copy script somewhere in $PATH

Usage
--------

- Run script or bind to keystroke combination

Let me know if you have any suggestions for improvement!

Scott

Offline

#2 2014-05-16 21:38:56

sekret
Member
Registered: 2013-07-22
Posts: 285

Re: nmcli-dmenu: controlling NetworkManager via dmenu

You are awesome! I had plans to write a dmenu script for nmcli but never got myself to starting it. I also have issues with connman, so I'll now try your script and see how it goes.

Offline

#3 2014-05-16 22:09:59

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: nmcli-dmenu: controlling NetworkManager via dmenu

I love this, thank you very much --- I may even start using network manager now just because of this script smile

Offline

#4 2014-05-17 03:25:32

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: nmcli-dmenu: controlling NetworkManager via dmenu

Thanks for the kind words. Couple of minor upgrades since I first posted:

1. Wifi connections are sorted by signal strength
2. Active connection(s) (Wifi and VPN) are marked with a '**'

Scott

Offline

#5 2014-05-17 06:30:45

sekret
Member
Registered: 2013-07-22
Posts: 285

Re: nmcli-dmenu: controlling NetworkManager via dmenu

Ok, there's one thing I really don't like and it's the hardcoded colors and font for dmenu. I'd just use

DMENU = ("dmenu -l {} -p {} -i")

or give an opportunity to collect the colors and font from a config file, if existent. I compile mine directly into dmenu.

Btw, PKGBUILD

# Maintainer: sekret, mail=$(echo c2VrcmV0QHBvc3Rlby5zZQo= | base64 -d)
_pkgname=nmcli-dmenu
pkgname=$_pkgname-git
pkgver=r8.ca85698
pkgrel=1
pkgdesc="Control NetworkManager via dmenu"
arch=('any')
url="https://github.com/firecat53/nmcli-dmenu"
license=('MIT')
depends=('python' 'networkmanager' 'dmenu')
makedepends=('git')
optdepends=('network-manager-applet: for the nm-connection-editor GUI')
provides=("$_pkgname")
conflicts=("$_pkgname")
source=("$_pkgname::git+https://github.com/firecat53/$_pkgname.git")
md5sums=('SKIP')

pkgver() {
  cd "$_pkgname"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

package() {
  install -Dm755 "$srcdir/$_pkgname/nmcli_dmenu" "$pkgdir/usr/bin/nmcli_dmenu"
  install -Dm644 "$srcdir/$_pkgname/LICENSE.txt" "$pkgdir/usr/share/license/$pkgname/LICENSE"
}

# vim:set ts=2 sw=2 et:

Last edited by sekret (2014-05-17 06:32:53)

Offline

#6 2014-05-17 15:52:00

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: nmcli-dmenu: controlling NetworkManager via dmenu

@sekret - thanks for the PKGBUILD! I'll get that up in the AUR here in the next couple of days and look into using a small config file to set dmenu options.

Thanks,
Scott

Offline

#7 2014-05-18 05:09:50

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: nmcli-dmenu: controlling NetworkManager via dmenu

Ok, I've upload the script to the AUR and added a config file option for customizing dmenu.

Scott

Offline

#8 2017-06-14 20:12:32

sudo97
Member
Registered: 2017-06-14
Posts: 1

Re: nmcli-dmenu: controlling NetworkManager via dmenu

It would be great if I could pass agruments to your script. I made rough version of it, you might see it on github, I made a pullrequest for you. I wanted to pass -b to it, this was what I started from

Offline

#9 2017-06-14 22:20:31

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: nmcli-dmenu: controlling NetworkManager via dmenu

Commented on Github. You can set dmenu arguments inside the config file.

Offline

Board footer

Powered by FluxBB