eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

list-known-networks (961B)


      1 #!/usr/bin/python3
      2 
      3 import sys
      4 import dbus
      5 
      6 bus = dbus.SystemBus()
      7 
      8 manager = dbus.Interface(bus.get_object('net.connman.iwd', '/'),
      9                          'org.freedesktop.DBus.ObjectManager')
     10 
     11 forget = None
     12 if len(sys.argv) >= 4 and sys.argv[1] == 'forget':
     13     forget = (sys.argv[2], sys.argv[3])
     14 
     15 print('Known Networks:')
     16 
     17 for path, interfaces in manager.GetManagedObjects().items():
     18     if 'net.connman.iwd.KnownNetwork' not in interfaces:
     19         continue
     20 
     21     network = interfaces['net.connman.iwd.KnownNetwork']
     22 
     23     if (network['Name'], network['Type']) == forget:
     24         obj = dbus.Interface(bus.get_object('net.connman.iwd', path),
     25                              'net.connman.iwd.KnownNetwork')
     26         obj.Forget()
     27         continue
     28 
     29     print("[ %s ]" % network['Name'])
     30 
     31     for key in network:
     32         val = network[key]
     33         if type(val) == dbus.Boolean:
     34             val = 'True' if val else 'False'
     35         print("    %s = %s" % (key, val))