Пример #1
0
def init_layouts():
    return [
        Columns(**l, num_stacks=2),
        # Bsp(**l),
        # Matrix(**l),
        RatioTile(**l, ratio_increment=1, fancy=True),
        Stack(**l),
        # Tile(**l),
        # TreeTab(**l),
        # VerticalTile(**l),
        MonadTall(**l),
        MonadWide(**l),
        Max(**l)
    ]
Пример #2
0
    def max(self, name=None):
        if name is None:
            return Max(**self.theme)

        return Max(name=name, **self.theme)
Пример #3
0
        group: str = qtile.screens[i + 1].group.name
        qtile.current_window.togroup(group)


# Layouts
layout_theme: dict[str, int | str] = {
    "border_width": 2,
    "border_focus": colors["primary"],
    "border_normal": colors["secondary"],
}

layout_names: dict[str, str] = {"monadtall": "tall~", "max": "max~", "treetab": "tree~"}

layouts = [
    MonadTall(**layout_theme, single_border_width=0, name=layout_names["monadtall"]),
    Max(name=layout_names["max"]),
    TreeTab(
        name=layout_names["treetab"],
        font=font_setting[0],
        fontsize=font_setting[1],
        active_fg=colors["background"],
        active_bg=colors["primary"],
        bg_color=colors["background"],
        border_width=5,
        inactive_bg=colors["secondary"],
        inactive_fg=colors["text"],
        previous_on_rm=True,
        urgent_fg=colors["urgent"],
        urgent_bg=colors["secondary"],
        sections=[""],
        section_fg=colors["background"],
Пример #4
0
class Slice(Delegate):
    """Slice layout

    This layout cuts piece of screen_rect and places a single window on that
    piece, and delegates other window placement to other layout
    """

    defaults = [
        ("width", 256, "Slice width"),
        ("side", "left", "Side of the slice (left, right, top, bottom)"),
        ("name", "slice", "Name of this layout."),
        ("wname", None, "WM_NAME to match"),
        ("wmclass", None, "WM_CLASS to match"),
        ("role", None, "WM_WINDOW_ROLE to match"),
        ("fallback", Max(), "Fallback layout"),
    ]

    def __init__(self, **config):
        Delegate.__init__(self, **config)
        self.add_defaults(Slice.defaults)
        self.match = {
            'wname': self.wname,
            'wmclass': self.wmclass,
            'role': self.role,
        }
        self._slice = Single()

    def clone(self, group):
        res = Layout.clone(self, group)
        res._slice = self._slice.clone(group)
        res.fallback = self.fallback.clone(group)
        return res

    def layout(self, windows, screen_rect):
        win, sub = self._get_screen_rects(screen_rect)
        self.delegate_layout(windows, {
            self._slice: win,
            self.fallback: sub,
        })

    def show(self, screen_rect):
        win, sub = self._get_screen_rects(screen_rect)
        self._slice.show(win)
        self.fallback.show(sub)

    def configure(self, win, screen_rect):
        raise NotImplementedError("Should not be called")

    def _get_layouts(self):
        return (self._slice, self.fallback)

    def _get_active_layout(self):
        return self.fallback  # always

    def _get_screen_rects(self, screen):
        if self.side == 'left':
            win, sub = screen.hsplit(self.width)
        elif self.side == 'right':
            sub, win = screen.hsplit(screen.width - self.width)
        elif self.side == 'top':
            win, sub = screen.vsplit(self.width)
        elif self.side == 'bottom':
            sub, win = screen.vsplit(screen.height - self.width)
        else:
            raise NotImplementedError(self.side)
        return (win, sub)

    def add(self, win):
        if self._slice.empty() and win.match(**self.match):
            self._slice.add(win)
            self.layouts[win] = self._slice
        else:
            self.fallback.add(win)
            self.layouts[win] = self.fallback

    def cmd_next(self):
        self.fallback.cmd_next()

    def cmd_previous(self):
        self.fallback.cmd_previous()
Пример #5
0
class Slice(Layout):
    """Slice layout

    This layout cuts piece of screen_rect and places a single window on that
    piece, and delegates other window placement to other layout
    """

    defaults = [
        ("width", 256, "Slice width."),
        ("side", "left", "Position of the slice (left, right, top, bottom)."),
        ("name", "slice", "Name of this layout."),
        ("match", None,
         "Match-object describing which window(s) to move to the slice."),
        ("fallback", Max(), "Layout to be used for the non-slice area."),
    ]

    def __init__(self, **config):
        self.layouts = {}
        Layout.__init__(self, **config)
        self.add_defaults(Slice.defaults)
        self._slice = Single()

    def clone(self, group):
        res = Layout.clone(self, group)
        res._slice = self._slice.clone(group)
        res.fallback = self.fallback.clone(group)
        return res

    def delegate_layout(self, windows, mapping):
        """Delegates layouting actual windows

        Parameters
        ===========
        windows:
            windows to layout
        mapping:
            mapping from layout to ScreenRect for each layout
        """
        grouped = {}
        for w in windows:
            lay = self.layouts[w]
            if lay in grouped:
                grouped[lay].append(w)
            else:
                grouped[lay] = [w]
        for lay, wins in grouped.items():
            lay.layout(wins, mapping[lay])

    def layout(self, windows, screen_rect):
        win, sub = self._get_screen_rects(screen_rect)
        self.delegate_layout(windows, {
            self._slice: win,
            self.fallback: sub,
        })

    def show(self, screen_rect):
        win, sub = self._get_screen_rects(screen_rect)
        self._slice.show(win)
        self.fallback.show(sub)

    def configure(self, win, screen_rect):
        raise NotImplementedError("Should not be called")

    def _get_layouts(self):
        return (self._slice, self.fallback)

    def _get_active_layout(self):
        return self.fallback  # always

    def _get_screen_rects(self, screen):
        if self.side == 'left':
            win, sub = screen.hsplit(self.width)
        elif self.side == 'right':
            sub, win = screen.hsplit(screen.width - self.width)
        elif self.side == 'top':
            win, sub = screen.vsplit(self.width)
        elif self.side == 'bottom':
            sub, win = screen.vsplit(screen.height - self.width)
        else:
            raise NotImplementedError(self.side)
        return (win, sub)

    def add(self, win):
        if self._slice.empty() and self.match and self.match.compare(win):
            self._slice.add(win)
            self.layouts[win] = self._slice
        else:
            self.fallback.add(win)
            self.layouts[win] = self.fallback

    def remove(self, win):
        lay = self.layouts.pop(win)
        focus = lay.remove(win)
        if not focus:
            layouts = self._get_layouts()
            idx = layouts.index(lay)
            while idx < len(layouts) - 1 and not focus:
                idx += 1
                focus = layouts[idx].focus_first()
        return focus

    def hide(self):
        for lay in self._get_layouts():
            lay.hide()

    def focus(self, win):
        self.layouts[win].focus(win)

    def blur(self):
        for lay in self._get_layouts():
            lay.blur()

    def focus_first(self):
        layouts = self._get_layouts()
        for lay in layouts:
            win = lay.focus_first()
            if win:
                return win

    def focus_last(self):
        layouts = self._get_layouts()
        for lay in reversed(layouts):
            win = lay.focus_last()
            if win:
                return win

    def focus_next(self, win):
        layouts = self._get_layouts()
        cur = self.layouts[win]
        focus = cur.focus_next(win)
        if not focus:
            idx = layouts.index(cur)
            while idx < len(layouts) - 1 and not focus:
                idx += 1
                focus = layouts[idx].focus_first()
        return focus

    def focus_previous(self, win):
        layouts = self._get_layouts()
        cur = self.layouts[win]
        focus = cur.focus_previous(win)
        if not focus:
            idx = layouts.index(cur)
            while idx > 0 and not focus:
                idx -= 1
                focus = layouts[idx].focus_last()
        return focus

    def __getattr__(self, name):
        """Delegate unimplemented command calls to active layout.

        For ``cmd_``-methods that don't exist on the Slice class, this looks
        for an implementation on the active layout.
        """
        if name.startswith('cmd_'):
            return getattr(self._get_active_layout(), name)
        return super().__getattr__(name)

    def cmd_next(self):
        self.fallback.cmd_next()

    def cmd_previous(self):
        self.fallback.cmd_previous()

    @property
    def commands(self):
        return self._get_active_layout().commands

    def info(self):
        d = Layout.info(self)
        for layout in self._get_layouts():
            d[layout.name] = layout.info()
        return d
Пример #6
0
def init_groups():
    return [
            Group("!nfo",
                layout='columns',
                layouts=[
                    Columns(**l),
                    Stack(**l),
                ],
                label='!'),
            Group(">kek",
                layout='max',
                layouts=[
                    Max(**l),
                    MonadWide(**l),
                ],
                matches=[
                    Match(title='weechat'),
                ],
                label="@"),
            Group("H4XX",
                layout='max',
                layouts=[
                    Max(**l),
                    Columns(**l),
                    MonadWide(**l),
                ],
                matches=[
                    Match(wm_class='sublime_text'),
                ],
                label="#"),
            Group("$RIPTZ",
                layout='columns',
                layouts=[
                    Columns(**l),
                    RatioTile(**l, ratio_increment=1, fancy=True),
                    Stack(**l),
                    ],
                label="$"),
            Group(".conf",
                layout='columns',
                layouts=[
                    Columns(**l),
                    RatioTile(**l, ratio_increment=1, fancy=True),
                    Stack(**l),
                    ],
                label="%"),
            Group("X_x",
                layout='max',
                layouts=[
                    Max(**l),
                    ],
                label="🖻🖻^"),
            Group("browse",
                layout='monadtall',
                layouts=[
                    MonadTall(**l),
                    MonadWide(**l),
                    ],
                matches=[
                    Match(wm_class='qutebrowser'),
                ],
                label="ð‘™©ð‘™©ð‘™©ð‘™©&"),
            Group(':D',
                layout='columns',
                layouts=[
                    Columns(**l),
                ],
                label='*'),
            Group('/3/',
                layout='max',
                layouts=[
                    Max(**l)
                    ],
                matches=[
                    Match(wm_class='Blender'),
                ],
                label='9'),
            Group('/gd/',
                layout='max',
                layouts=[
                    Max(**l)
                    ],
                matches=[
                    Match(wm_class=[
                        'gimp',
                        'krita',
                        'mypaint',
                        ])
                ],
                label='0'),
            ScratchPad('scratch', [
                    DropDown('term', TERMUX),
                ]),
    ]
Пример #7
0
class Slice(Delegate):
    """Slice layout

    This layout cuts piece of screen_rect and places a single window on that
    piece, and delegates other window placement to other layout
    """

    defaults = [
        ("width", 256, "Slice width."),
        ("side", "left", "Position of the slice (left, right, top, bottom)."),
        ("name", "slice", "Name of this layout."),
        ("match", None,
         "Match-object describing which window(s) to move to the slice."),
        ("fallback", Max(), "Layout to be used for the non-slice area."),
    ]

    def __init__(self, **config):
        Delegate.__init__(self, **config)
        self.add_defaults(Slice.defaults)
        self._slice = Single()

    def clone(self, group):
        res = Layout.clone(self, group)
        res._slice = self._slice.clone(group)
        res.fallback = self.fallback.clone(group)
        return res

    def layout(self, windows, screen_rect):
        win, sub = self._get_screen_rects(screen_rect)
        self.delegate_layout(windows, {
            self._slice: win,
            self.fallback: sub,
        })

    def show(self, screen_rect):
        win, sub = self._get_screen_rects(screen_rect)
        self._slice.show(win)
        self.fallback.show(sub)

    def configure(self, win, screen_rect):
        raise NotImplementedError("Should not be called")

    def _get_layouts(self):
        return (self._slice, self.fallback)

    def _get_active_layout(self):
        return self.fallback  # always

    def _get_screen_rects(self, screen):
        if self.side == 'left':
            win, sub = screen.hsplit(self.width)
        elif self.side == 'right':
            sub, win = screen.hsplit(screen.width - self.width)
        elif self.side == 'top':
            win, sub = screen.vsplit(self.width)
        elif self.side == 'bottom':
            sub, win = screen.vsplit(screen.height - self.width)
        else:
            raise NotImplementedError(self.side)
        return (win, sub)

    def add(self, win):
        if self._slice.empty() and self.match and self.match.compare(win):
            self._slice.add(win)
            self.layouts[win] = self._slice
        else:
            self.fallback.add(win)
            self.layouts[win] = self.fallback

    def cmd_next(self):
        self.fallback.cmd_next()

    def cmd_previous(self):
        self.fallback.cmd_previous()