Created
March 14, 2018 20:49
-
-
Save yucefsourani/50fb29d48f86455bec819459c5dce83f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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