Skip to content

Instantly share code, notes, and snippets.

@yucefsourani
Created March 14, 2018 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yucefsourani/50fb29d48f86455bec819459c5dce83f to your computer and use it in GitHub Desktop.
Save yucefsourani/50fb29d48f86455bec819459c5dce83f to your computer and use it in GitHub Desktop.
import dbus
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib
DBusGMainLoop(set_as_default=True)
def device_added(object_path):
print("Device Added")
print(object_path)
print(type(object_path))
def device_removed(object_path):
print("Device Removed")
print(object_path)
print(type(object_path))
bus = dbus.SystemBus()
obj = bus.get_object("org.freedesktop.NetworkManager","/org/freedesktop/NetworkManager")
interf = dbus.Interface(obj,"org.freedesktop.NetworkManager")
interf.connect_to_signal("DeviceAdded", device_added)
interf.connect_to_signal("DeviceRemoved", device_removed)
loop = GLib.MainLoop()
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment