Ejemplo n.º 1
0
    def execute(self):
        print " * PyUDev\n"
        print "\n\tInput devices:\n\t=============="
        devices = pyudev.Context().list_devices(subsystem="input")
        for device in devices:
            if device.sys_name.startswith("event"):
                print "\t\t", device.sys_name, device.parent["NAME"][1:-1]

        print "\n\tInput devices keys:\n\t=============="
        for device in devices:
            device_keys = ""
            if device.sys_name.startswith("event"):
                if device.parent.keys():
                    for key in device.parent.keys():
                        device_keys += "{%s: %s}," % (key, device.parent[key])
                    print "%s => %s" % (device.sys_name, device_keys)

        print "\n\n * XinputWarper\n"
        print "\t- First XID: %s\n" % XinputWarper().first_xid()

        print "\t- Devices:\n\t=========="
        devices = UDevObservator().gather_devices()
        print "\n\t%d device(s) found\n" % len(devices)
        for device in devices:
            print '\t\tDevice "%s" has XID %s' % (device.values()[0], device.keys()[0])

        print "\n\t- Xinput list:\n\t=========="
        for xinput in XinputWarper().xinput_list.split("\n"):
            print "\t\t", xinput

        print "\n\n * GConfSettings\n"
        print "\t- All Keys:\n\t==========="
        for entry in GConfSettings().keys():
            gconf_key = GConfKey(entry.key, entry.value.type)
            print '\t\tKey "%s" has value "%s"' % (gconf_key.name, gconf_key.get_value())
Ejemplo n.º 2
0
 def activated_devices_xids(self):
     """
     Return a list of all XIDs of devices where naturalscrolling was
     registered as activated.
     """
     activated_devices_xids = []
     for entry in self.server().entries():
         try:
             gconf_key = GConfKey(entry.key)
             if gconf_key.get_value():
                 activated_devices_xids.append(gconf_key.name)
         except GConfKey.KeyDoesntExits:
             # Pass the removed key
             pass
     return activated_devices_xids
Ejemplo n.º 3
0
    def initialize(self, devices):
        """
        Check if all keys exists
        Create missing keys
        """
        for device in devices:
            if not device.keys()[0]:
                print (_("Warning: The XID of the device with name %s " "wasn't found") % device.values()[0])
            else:
                gconf_key = GConfKey(device.keys()[0], gconf.VALUE_BOOL)
                gconf_key.find_or_create()

                # As you're in the initializing step, if there is at least one
                # observator, then fire it with all the actual configuration
                self.server().execute_callback_on_observers(device.keys()[0], gconf_key)
Ejemplo n.º 4
0
 def activated_devices_xids(self):
     """
     Return a list of all XIDs of devices where naturalscrolling was
     registered as activated.
     """
     activated_devices_xids = []
     for entry in self.server().entries():
         try:
             gconf_key = GConfKey(entry.key)
             if gconf_key.get_value():
                 activated_devices_xids.append(gconf_key.name)
         except GConfKey.KeyDoesntExits:
             # Pass the removed key
             pass
     return activated_devices_xids
Ejemplo n.º 5
0
 def key(self, key, type=None):
     """
     Ruby styled method to define which is the key to check
     This method return an instance of the GConfKey class
     otherwise raise a InvalidKey or InvalidKeyType
     """
     return GConfKey(key, self.python_type_to_gconf_type(type))
Ejemplo n.º 6
0
    def initialize(self, devices):
        """
        Check if all keys exists
        Create missing keys
        """
        for device in devices:
            if not device.keys()[0]:
                print(
                    _("Warning: The XID of the device with name %s "
                      "wasn't found") % device.values()[0])
            else:
                gconf_key = GConfKey(device.keys()[0], gconf.VALUE_BOOL)
                gconf_key.find_or_create()

                # As you're in the initializing step, if there is at least one
                # observator, then fire it with all the actual configuration
                self.server().execute_callback_on_observers(
                    device.keys()[0], gconf_key)
Ejemplo n.º 7
0
    def on_settings_changed(self, client, timestamp, entry, *extra):
        """
        This is the callback function that is called when the keys in our
        namespace change (such as editing them with gconf-editor).
        """
        # Do nothing when the key has been removed
        if not entry.value:
            return

        key = entry.key
        gconf_key = GConfKey(key, entry.value.type)
        self.execute_callback_on_observers(key, gconf_key)
Ejemplo n.º 8
0
    def execute(self):
        print " * PyUDev\n"
        print "\n\tInput devices:\n\t=============="
        devices = pyudev.Context().list_devices(subsystem="input")
        for device in devices:
            if device.sys_name.startswith("event"):
                print "\t\t", device.sys_name, device.parent["NAME"][1:-1]

        print "\n\tInput devices keys:\n\t=============="
        for device in devices:
            device_keys = ""
            if device.sys_name.startswith("event"):
                if device.parent.keys():
                    for key in device.parent.keys():
                        device_keys += "{%s: %s}," % (key, device.parent[key])
                    print "%s => %s" % (device.sys_name, device_keys)

        print "\n\n * XinputWarper\n"
        print "\t- First XID: %s\n" % XinputWarper().first_xid()

        print "\t- Devices:\n\t=========="
        devices = UDevObservator().gather_devices()
        print "\n\t%d device(s) found\n" % len(devices)
        for device in devices:
            print "\t\tDevice \"%s\" has XID %s" % (device.values()[0],
                                                    device.keys()[0])

        print "\n\t- Xinput list:\n\t=========="
        for xinput in XinputWarper().xinput_list.split("\n"):
            print "\t\t", xinput

        print "\n\n * GConfSettings\n"
        print "\t- All Keys:\n\t==========="
        for entry in GConfSettings().keys():
            gconf_key = GConfKey(entry.key, entry.value.type)
            print "\t\tKey \"%s\" has value \"%s\"" % (gconf_key.name,
                                                       gconf_key.get_value())
Ejemplo n.º 9
0
    def __init__(self, key, type=None):
        self.__gconf = GConfServer().client
        self.__value = None

        if key.startswith(GCONF_ROOT_DIR):
            self.__key = key
            self.__name = self._without_root_path(key)
        else:
            self.__key = self._with_root_path(key)
            self.__name = key

        if type:
            self.__type = type
        else:
            try:
                self.__type = self.__gconf.get(self.__key).type
            except AttributeError:
                raise GConfKey.KeyDoesntExits(
                    _("Can't find the key '%s'") % self.__key)