Ejemplo n.º 1
0
    def cmd_simulate_keypress(self, modifiers, key):
        """
            Simulates a keypress on the focused window.

            :modifiers A list of modifier specification strings. Modifiers can
            be one of "shift", "lock", "control" and "mod1" - "mod5".
            :key Key specification.

            Examples:

                simulate_keypress(["control", "mod2"], "k")
        """
        # FIXME: This needs to be done with sendevent, once we have that fixed.
        keysym = xcbq.keysyms.get(key)
        if keysym is None:
            raise command.CommandError("Unknown key: %s"%key)
        keycode = self.conn.first_sym_to_code[keysym]
        class DummyEv:
            pass

        d = DummyEv()
        d.detail = keycode
        try:
            d.state = utils.translateMasks(modifiers)
        except KeyError, v:
            return v.args[0]
Ejemplo n.º 2
0
    def cmd_simulate_keypress(self, modifiers, key):
        """
            Simulates a keypress on the focused window.

            :modifiers A list of modifier specification strings. Modifiers can
            be one of "shift", "lock", "control" and "mod1" - "mod5".
            :key Key specification.

            Examples:

                simulate_keypress(["control", "mod2"], "k")
        """
        # FIXME: This needs to be done with sendevent, once we have that fixed.
        keysym = xcbq.keysyms.get(key)
        if keysym is None:
            raise command.CommandError("Unknown key: %s" % key)
        keycode = self.conn.first_sym_to_code[keysym]

        class DummyEv:
            pass

        d = DummyEv()
        d.detail = keycode
        try:
            d.state = utils.translateMasks(modifiers)
        except KeyError, v:
            return v.args[0]
Ejemplo n.º 3
0
 def __init__(self, modifiers, key, action, *args, **kwargs):
     self.modifiers, self.key = modifiers, key
     self.action, self.args, self.kwargs = action, args, kwargs
     self.keysym = XK.string_to_keysym(key)
     if self.keysym == 0:
         raise QTileError("Unknown key: %s" % key)
     self.modmask = utils.translateMasks(self.modifiers)
Ejemplo n.º 4
0
 def __init__(self, modifiers, button, *commands):
     self.modifiers = modifiers
     self.button = button
     self.commands = commands
     try:
         self.button_code = int(self.button.replace('Button', ''))
         self.modmask = utils.translateMasks(self.modifiers)
     except KeyError, v:
         raise utils.QtileError(v)
Ejemplo n.º 5
0
 def __init__(self, modifiers, button, *commands):
     self.modifiers = modifiers
     self.button = button
     self.commands = commands
     if button not in xcbq.ButtonCodes:
         raise QtileError("Unknown button: %s" % button)
     self.button_code = xcbq.ButtonCodes[self.button]
     try:
         self.modmask = utils.translateMasks(self.modifiers)
     except KeyError, v:
         raise QtileError(v)
Ejemplo n.º 6
0
 def __init__(self, modifiers, button, *commands, **kwargs):
     self.start = kwargs.get("start", None)
     self.focus = kwargs.get("focus", "before")
     self.modifiers = modifiers
     self.button = button
     self.commands = commands
     try:
         self.button_code = int(self.button.replace('Button', ''))
         self.modmask = utils.translateMasks(self.modifiers)
     except KeyError, v:
         raise utils.QtileError(v)
Ejemplo n.º 7
0
 def __init__(self, modifiers, button, *commands, **kwargs):
     self.start = kwargs.get("start", None)
     self.focus = kwargs.get("focus", "before")
     self.modifiers = modifiers
     self.button = button
     self.commands = commands
     try:
         self.button_code = int(self.button.replace('Button', ''))
         self.modmask = utils.translateMasks(self.modifiers)
     except KeyError, v:
         raise utils.QtileError(v)
Ejemplo n.º 8
0
 def cmd_simulate_keypress(self, qtile, modifiers, key):
     """
         Simulates a keypress on the focused window.
     """
     keysym = XK.string_to_keysym(key)
     if keysym == 0:
         return "Unknown key: %s" % key
     keycode = qtile.display.keysym_to_keycode(keysym)
     try:
         mask = utils.translateMasks(modifiers)
     except manager.QTileError, v:
         return str(v)
Ejemplo n.º 9
0
 def __init__(self, modifiers, button, *commands, **kw):
     self.start = kw.pop('start', None)
     if kw:
         raise TypeError("Unexpected arguments: %s" % ', '.join(kw))
     self.modifiers = modifiers
     self.button = button
     self.commands = commands
     try:
         self.button_code = int(self.button.replace('Button', ''))
         self.modmask = utils.translateMasks(self.modifiers)
     except KeyError, v:
         raise utils.QtileError(v)
Ejemplo n.º 10
0
 def __init__(self, modifiers, button, *commands, **kw):
     self.start = kw.pop('start', None)
     if kw:
         raise TypeError("Unexpected arguments: %s" % ', '.join(kw))
     self.modifiers = modifiers
     self.button = button
     self.commands = commands
     if button not in xcbq.ButtonCodes:
         raise QtileError("Unknown button: %s" % button)
     self.button_code = xcbq.ButtonCodes[self.button]
     try:
         self.modmask = utils.translateMasks(self.modifiers)
     except KeyError, v:
         raise QtileError(v)
Ejemplo n.º 11
0
 def __init__(self, modifiers, key, *commands):
     """
         :modifiers A list of modifier specifications. Modifier
         specifications are one of: "shift", "lock", "control", "mod1",
         "mod2", "mod3", "mod4", "mod5".
         :key A key specification, e.g. "a", "Tab", "Return", "space".
         :*commands A list of lazy command objects generated with the
         command.lazy helper. If multiple Call objects are specified, they
         are run in sequence.
     """
     self.modifiers, self.key, self.commands = modifiers, key, commands
     self.keysym = XK.string_to_keysym(key)
     if self.keysym == 0:
         raise QtileError("Unknown key: %s"%key)
     try:
         self.modmask = utils.translateMasks(self.modifiers)
     except KeyError, v:
         raise QtileError(v)
Ejemplo n.º 12
0
    def __init__(self, modifiers, key, *commands):
        """
            - modifiers: A list of modifier specifications. Modifier
            specifications are one of: "shift", "lock", "control", "mod1",
            "mod2", "mod3", "mod4", "mod5".

            - key: A key specification, e.g. "a", "Tab", "Return", "space".

            - *commands: A list of lazy command objects generated with the
            command.lazy helper. If multiple Call objects are specified, they
            are run in sequence.
        """
        self.modifiers, self.key, self.commands = modifiers, key, commands
        if key not in xcbq.keysyms:
            raise QtileError("Unknown key: %s"%key)
        self.keysym = xcbq.keysyms[key]
        try:
            self.modmask = utils.translateMasks(self.modifiers)
        except KeyError, v:
            raise QtileError(v)
Ejemplo n.º 13
0
    def cmd_simulate_keypress(self, modifiers, key):
        """
            Simulates a keypress on the focused window. 
            
            :modifiers A list of modifier specification strings. Modifiers can
            be one of "shift", "lock", "control" and "mod1" - "mod5".
            :key Key specification.  

            Examples:

                simulate_keypress(["control", "mod2"], "k")
        """
        keysym = XK.string_to_keysym(key)
        if keysym == 0:
            raise command.CommandError("Unknown key: %s"%key)
        keycode = self.display.keysym_to_keycode(keysym)
        try:
            mask = utils.translateMasks(modifiers)
        except KeyError, v:
            return v.args[0]
Ejemplo n.º 14
0
    def __init__(self, modifiers, key, *commands):
        """
            - modifiers: A list of modifier specifications. Modifier
            specifications are one of: "shift", "lock", "control", "mod1",
            "mod2", "mod3", "mod4", "mod5".

            - key: A key specification, e.g. "a", "Tab", "Return", "space".

            - *commands: A list of lazy command objects generated with the
            command.lazy helper. If multiple Call objects are specified, they
            are run in sequence.
        """
        self.modifiers, self.key, self.commands = modifiers, key, commands
        if key not in xcbq.keysyms:
            raise utils.QtileError("Unknown key: %s" % key)
        self.keysym = xcbq.keysyms[key]
        try:
            self.modmask = utils.translateMasks(self.modifiers)
        except KeyError, v:
            raise utils.QtileError(v)