예제 #1
0
파일: hook.py 프로젝트: stevenxing/qtile
def fire(event, *args, **kwargs):
    if event not in subscribe.hooks:
        raise utils.QtileError("Unknown event: %s" % event)
    if not event in SKIPLOG:
        qtile.log.info("Internal event: %s(%s, %s)" % (event, args, kwargs))
    for i in subscriptions.get(event, []):
        i(*args, **kwargs)
예제 #2
0
 def _subscribe(self, event, func):
     lst = subscriptions.setdefault(event, [])
     try:
         lst.remove(func)
     except ValueError:
         raise utils.QtileError("Tried to unsubscribe a hook that was not"
                                " currently subscribed")
예제 #3
0
파일: config.py 프로젝트: stevenxing/qtile
 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)
예제 #4
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)
예제 #5
0
파일: config.py 프로젝트: stevenxing/qtile
    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)
예제 #6
0
파일: config.py 프로젝트: stevenxing/qtile
 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)
예제 #7
0
    def __init__(self,
                 title=None,
                 wm_class=None,
                 role=None,
                 wm_type=None,
                 wm_instance_class=None,
                 net_wm_pid=None):
        """

        ``Match`` supports both regular expression objects (i.e. the result of
        ``re.compile()``) or strings (match as a "include" match). If a window
        matches any of the things in any of the lists, it is considered a
        match.

        :param title: things to match against the title (WM_NAME)
        :param wm_class: things to match against the second string in
                         WM_CLASS atom
        :param role: things to match against the WM_ROLE atom
        :param wm_type: things to match against the WM_TYPE atom
        :param wm_instance_class: things to match against the first string in
               WM_CLASS atom
        :param net_wm_pid: things to match against the _NET_WM_PID atom
              (only int allowed in this rule)
        """
        if not title:
            title = []
        if not wm_class:
            wm_class = []
        if not role:
            role = []
        if not wm_type:
            wm_type = []
        if not wm_instance_class:
            wm_instance_class = []
        if not net_wm_pid:
            net_wm_pid = []

        try:
            net_wm_pid = map(int, net_wm_pid)
        except ValueError:
            error = 'Invalid rule for net_wm_pid: "%s" '\
                    'only ints allowed' % str(net_wm_pid)
            raise utils.QtileError(error)

        self._rules = [('title', t) for t in title]
        self._rules += [('wm_class', w) for w in wm_class]
        self._rules += [('role', r) for r in role]
        self._rules += [('wm_type', r) for r in wm_type]
        self._rules += [('wm_instance_class', w) for w in wm_instance_class]
        self._rules += [('net_wm_pid', w) for w in net_wm_pid]