예제 #1
0
파일: config.py 프로젝트: m-col/qtile
    def parse(self, spec):
        """
        Splits an emacs keydef into modifiers and keys. For example:
          "M-S-a"     -> ['mod4', 'shift'], 'a'
          "A-<minus>" -> ['mod1'], 'minus'
          "C-<Tab>"   -> ['control'], 'Tab'
        """
        mods = []
        keys = []

        for key in spec.split("-"):
            if not key:
                break
            if key in self.modifier_keys:
                if keys:
                    msg = "Modifiers must always come before key/btn: %s"
                    raise utils.QtileError(msg % spec)
                mods.append(self.modifier_keys[key])
                continue
            if len(key) == 1:
                keys.append(key)
                continue
            if len(key) > 3 and key[0] == "<" and key[-1] == ">":
                keys.append(key[1:-1])
                continue

        if not keys:
            msg = "Invalid key/btn specifier: %s"
            raise utils.QtileError(msg % spec)

        if len(keys) > 1:
            msg = "Key chains are not supported: %s" % spec
            raise utils.QtileError(msg)

        return mods, keys[0]
예제 #2
0
파일: xcore.py 프로젝트: mrbayati2002/qtile
    def grab_button(self, mouse: config.Mouse) -> None:
        """Grab the given mouse button for events"""
        try:
            modmask = xcbq.translate_masks(mouse.modifiers)
        except xcbq.XCBQError as err:
            raise utils.QtileError(err)

        if isinstance(mouse, config.Click) and mouse.focus:
            # Make a freezing grab on mouse button to gain focus
            # Event will propagate to target window
            grabmode = xcffib.xproto.GrabMode.Sync
        else:
            grabmode = xcffib.xproto.GrabMode.Async

        eventmask = xcffib.xproto.EventMask.ButtonPress
        if isinstance(mouse, config.Drag):
            eventmask |= xcffib.xproto.EventMask.ButtonRelease

        for amask in self._auto_modmasks():
            self._root.grab_button(
                mouse.button_code,
                modmask | amask,
                True,
                eventmask,
                grabmode,
                xcffib.xproto.GrabMode.Async,
            )
예제 #3
0
파일: hook.py 프로젝트: tinruufu/qtile
 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")
예제 #4
0
파일: config.py 프로젝트: m-col/qtile
    def __init__(
        self,
        title=None,
        wm_class=None,
        role=None,
        wm_type=None,
        wm_instance_class=None,
        net_wm_pid=None,
        func: Callable[[base.WindowType], bool] | None = None,
        wid=None,
    ):
        self._rules = {}

        if title is not None:
            self._rules["title"] = title
        if wm_class is not None:
            self._rules["wm_class"] = wm_class
        if wm_instance_class is not None:
            self._rules["wm_instance_class"] = wm_instance_class
        if wid is not None:
            self._rules["wid"] = wid
        if net_wm_pid is not None:
            try:
                self._rules["net_wm_pid"] = int(net_wm_pid)
            except ValueError:
                error = 'Invalid rule for net_wm_pid: "%s" only int allowed' % str(
                    net_wm_pid)
                raise utils.QtileError(error)
        if func is not None:
            self._rules["func"] = func

        if role is not None:
            self._rules["role"] = role
        if wm_type is not None:
            self._rules["wm_type"] = wm_type
예제 #5
0
파일: config.py 프로젝트: tych0/qtile
    def __init__(self,
                 title=None,
                 wm_class=None,
                 role=None,
                 wm_type=None,
                 wm_instance_class=None,
                 net_wm_pid=None):
        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 = list(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]
예제 #6
0
파일: config.py 프로젝트: timgates42/qtile
    def __init__(self,
                 title=None,
                 wm_class=None,
                 role=None,
                 wm_type=None,
                 wm_instance_class=None,
                 net_wm_pid=None):
        self._rules = {}

        if title is not None:
            self._rules["title"] = title
        if wm_class is not None:
            self._rules["wm_class"] = wm_class
        if role is not None:
            self._rules["role"] = role
        if wm_type is not None:
            self._rules["wm_type"] = wm_type
        if wm_instance_class is not None:
            self._rules["wm_instance_class"] = wm_instance_class
        if net_wm_pid is not None:
            try:
                self._rules["net_wm_pid"] = int(net_wm_pid)
            except ValueError:
                error = 'Invalid rule for net_wm_pid: "%s" only int allowed' % \
                        str(net_wm_pid)
                raise utils.QtileError(error)
예제 #7
0
파일: xcore.py 프로젝트: mrbayati2002/qtile
    def lookup_key(self, key: config.Key) -> Tuple[int, int, int]:
        """Find the keysym and the modifier mask for the given key"""
        try:
            keysym = xcbq.get_keysym(key.key)
            modmask = xcbq.translate_masks(key.modifiers)
        except xcbq.XCBQError as err:
            raise utils.QtileError(err)

        return keysym, modmask, modmask & self._valid_mask
예제 #8
0
def fire(event, *args, **kwargs):
    if event not in subscribe.hooks:
        raise utils.QtileError("Unknown event: %s" % event)
    if event not in SKIPLOG:
        logger.debug("Internal event: %s(%s, %s)", event, args, kwargs)
    for i in subscriptions.get(event, []):
        try:
            i(*args, **kwargs)
        except:  # noqa: E722
            logger.exception("Error in hook %s", event)