Commit 7768c59c authored by Yuri D'Elia's avatar Yuri D'Elia

Add first release.

connman-notify: desktop notification integration for connman
`connman-notify` generates desktop notifications for connman_ events, such as
interface connection/disconnection.
The generated notifications look like::
ethernet: online [IPv4:]
ethernet: disconnected
wifi/SSID: configuring ...
wifi/SSID: online [IPv4:]
Simply run `connman-notify` at the start of your session:
./connman-notify &
Use `connman-notify -h` to see a minimal help. The command line flags `-n` and
`-l` can be used to customize the detail level of the notification (to hide
IPv4/6 addresses or show long `connman` interface names).
You'll need `connman` to be running of course, and you'll also need a
notification daemon such as dunst_.
Why connman
I'm only interested in DE-agnostic network managers, and `connman` is one of
the few available along with `WICD`, `netcfg` and `dhcpcd`. If you're looking
for a zero-configuration manager, just use `WICD`. `connman` is not "user
friendly" yet.
connman_ however blows `WICD` out of the water in terms of speed. It can bring
my ethernet link up in 2 seconds (compared to ~10 of `WICD`) and perform an
ethernet<=>WiFi switch in generally less than 3 seconds (`WICD` would normally
just fail to reconnect!). Not to mention minimal CPU/memory usage, and good
support for IPv6.
`connman` has no graphical management interface yet. connman-ui_ runs in the
system tray (if you have one), but it's still far away to being complete.
connman_dmenu_ provides a simple dmenu-based WiFi network selector. For a tiled
window-manager setup, the combination of `connman-notify` and `connman_dmenu`
serves my current purposes nicely.
The following software is currently required for `facedetect`:
- Python
- Pynotify (``python-notify``)
- Python DBUS (``python-dbus``)
On Debian/Ubuntu, you can install all the required dependencies with::
sudo apt-get install python python-notify python-dbus
Authors and Copyright
| `connman-notify` is distributed under GPL2 (see COPYING) WITHOUT ANY WARRANTY.
| Copyright(c) 2014 by wave++ "Yuri D'Elia" <>.
.. _connman:
.. _connman-ui:
.. _dunst:
.. _connman_dmenu:
from __future__ import print_function
import argparse
import dbus
import dbus.mainloop.glib
import glib
import pynotify
APP_NAME = 'connman'
STATE_MAP = {'disconnect': 'disconnected',
'association': 'associating ...',
'configuration': 'configuring ...'}
def notify(subject, body):
ntf = pynotify.Notification(subject, body)
def property_changed(bus, manager, name, value, path):
# ignore global state changes
if path == '/': return
# shorten device names
srv_name = path[path.rfind("/") + 1:]
srv_name = srv_name[0:srv_name.find("_")]
# interface state changes
if name == 'State' and value not in ['ready', 'idle']:
state = STATE_MAP.get(value, value)
srv_obj = dbus.Interface(bus.get_object('net.connman', path), 'net.connman.Service')
srv_prop = None
srv_prop = srv_obj.GetProperties()
if 'Name' in srv_prop:
srv_name += "/" + srv_prop['Name']
if SHOW_ADDR and value == 'online':
addrs = []
for proto in ['IPv4', 'IPv6']:
if proto in srv_prop and 'Address' in srv_prop[proto]:
addrs.append("{}: {}".format(proto, str(srv_prop[proto]['Address'])))
if addrs:
state += " [" + ", ".join(addrs) + "]"
except dbus.DBusException:
notify(srv_name, state)
# IPv4/6 changes
if SHOW_ADDR and name in ['IPv4', 'IPv6'] and 'Address' in value:
srv_obj = dbus.Interface(bus.get_object('net.connman', path), 'net.connman.Service')
srv_prop = srv_obj.GetProperties()
# only report new addresses
if srv_prop['State'] == 'online':
if 'Name' in srv_prop:
srv_name += "/" + srv_prop['Name']
notify(srv_name, '{}: {}'.format(name, value['Address']))
if __name__ == '__main__':
ap = argparse.ArgumentParser(description='connman notification daemon')
ap.add_argument('-l', dest="long_dev", action="store_true",
help='Show long interface names')
ap.add_argument('-n', dest="hide_addr", action="store_true",
help='Hide assigned IPv4/6 addresses')
args = ap.parse_args()
if args.long_dev: SHORT_DEV = False
if args.hide_addr: SHOW_ADDR = False
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("net.connman", "/"), "net.connman.Manager")
bus.add_signal_receiver(lambda name, value, path: property_changed(bus, manager, name, value, path),
mainloop = glib.MainLoop()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment