Exemple #1
0
def deviceAdded(udi):
    ''' DeviceAdded callback function '''
    if not allDevices.__contains__(udi):
        allDevices[udi] = genericDevice(udi, systemBus)

    allDevices[udi].deviceAdded()
Exemple #2
0
    app.setMainWidget(trayWindow)

    # Create D-Bus mainloop
    dbus.mainloop.qt3.DBusQtMainLoop(set_as_default=True)

    serviceName = 'org.freedesktop.Hal'
    interfaceName =  '/org/freedesktop/Hal/Manager'
    managerName = 'org.freedesktop.Hal.Manager'

    # Connect to SystemBus
    systemBus = dbus.SystemBus()
    dbusService = systemBus.get_object(serviceName, interfaceName)
    halInterface = dbus.Interface(dbusService, managerName)

    # Set icon finder from KDE
    setIconFinder(lambda icon: str(trayWindow.icons.iconPath(icon, KIcon.Desktop)))

    # Generate Global Device List
    allDevices = {}
    for device in halInterface.GetAllDevices():
        allDevices[device] = genericDevice(device, systemBus)

    # Connect to Device{Added/Removed} signals
    systemBus.add_signal_receiver(deviceAdded, 'DeviceAdded',  managerName, serviceName, interfaceName)
    systemBus.add_signal_receiver(deviceRemoved, 'DeviceRemoved',  managerName, serviceName, interfaceName)

    ''' Enter main loop '''
    sys.exit(app.exec_loop())