Skip to content

Instantly share code, notes, and snippets.

@GabrielL
Created March 27, 2019 16:34
Show Gist options
  • Save GabrielL/975198e81b0d908eda80eafbf52098d5 to your computer and use it in GitHub Desktop.
Save GabrielL/975198e81b0d908eda80eafbf52098d5 to your computer and use it in GitHub Desktop.
import dbus
def iwd_stations(obj):
for k, v in obj.items():
if 'net.connman.iwd.Station' in v:
yield k, v
system_bus = dbus.SystemBus()
o = system_bus.get_object('net.connman.iwd', '/')
objs = o.GetManagedObjects(dbus_interface='org.freedesktop.DBus.ObjectManager')
try:
for name, station in iwd_stations(objs):
print(objs[station['net.connman.iwd.Station']['ConnectedNetwork']]['net.connman.iwd.Network']['Name'])
except Exception:
print("unknown")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment