1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/python import dbus bus = dbus.SystemBus() manager = dbus.Interface(bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager'), 'org.freedesktop.NetworkManager') states = [ "unknown", "asleep", "connecting", "connected", "disconnected" ] state = manager.state() print "System is %s" % (states[state])