Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  13] [ 0]  / answers: 1 / hits: 13721  / 2 Years ago, thu, december 16, 2021, 12:20:13

I'm writing a small little app that I want to submit to the Ubuntu App Review board, and one thing I'd like to do is for it to show the names of the detected Wireless SSIDs in a combo box. It's a PyGI app.



Has anyone got any pointers on how I can get those SSIDs from the system, preferably through a Python API? From dbus? From NetworkManager?


More From » wireless

 Answers
1

You can do this easily from NetworkManager's pygi bindings:



from gi.repository import NetworkManager, NMClient

nmc = NMClient.Client.new()
devs = nmc.get_devices()

for dev in devs:
if dev.get_device_type() == NetworkManager.DeviceType.WIFI:
for ap in dev.get_access_points():
print ap.get_ssid()


Or from DBus directly, see
http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/show-bssids.py



If you're inclined to just quickly script this in shell; an easy way to ask NetworkManager for this is to use:



nmcli dev wifi list


Or use iwlist scan, or better: iw dev wlan0 scan (or ... scan dump), after installing the iw Install iw package.


[#38378] Friday, December 17, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ravturtl

Total Points: 335
Total Questions: 132
Total Answers: 110

Location: Tanzania
Member since Wed, Feb 24, 2021
3 Years ago
;