Skip to content

Instantly share code, notes, and snippets.

@meeuw
Last active September 13, 2019 07:01
Show Gist options
  • Save meeuw/31ae385cc67a8a94f29407355aad7c58 to your computer and use it in GitHub Desktop.
Save meeuw/31ae385cc67a8a94f29407355aad7c58 to your computer and use it in GitHub Desktop.
script to disconnect current wifi connection
#!/usr/bin/env python3
# https://w1.fi/wpa_supplicant/devel/dbus.html
import dbus
import sys
if len(sys.argv) > 1:
interface = sys.argv[1]
else:
interface = 'wlp0s20f0u2u2'
bus = dbus.SystemBus()
wpa_supplicant1 = bus.get_object('fi.w1.wpa_supplicant1', '/fi/w1/wpa_supplicant1')
path = wpa_supplicant1.GetInterface(interface, dbus_interface="fi.w1.wpa_supplicant1")
interface_obj = bus.get_object("fi.w1.wpa_supplicant1", path)
interface_obj.Reassociate(dbus_interface="fi.w1.wpa_supplicant1.Interface")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment