コード例 #1
0
def test_widgetbox_widget(manager):
    manager.conn = xcbq.Connection(manager.display)

    # We need to trick the widgets into thinking this is libqtile.qtile so
    # we add some methods that are called when the widgets are configured
    manager.call_soon = no_op
    manager.register_widget = no_op

    tb_one = TextBox(name="tb_one", text="TB ONE")
    tb_two = TextBox(name="tb_two", text="TB TWO")

    # Give widgetbox invalid value for button location
    widget_box = WidgetBox([tb_one, tb_two],
                           close_button_location="middle",
                           fontsize=10)

    # Create a bar and set attributes needed to run widget
    fakebar = Bar([widget_box], 24)
    fakebar.window = FakeWindow()
    fakebar.width = 10
    fakebar.height = 10
    fakebar.draw = no_op

    # Configure the widget box
    widget_box._configure(manager, fakebar)

    # Invalid value should be corrected to default
    assert widget_box.close_button_location == "left"

    # Check only widget in bar is widgetbox
    assert fakebar.widgets == [widget_box]

    # Open box
    widget_box.cmd_toggle()

    # Check it's open
    assert widget_box.box_is_open

    # Default text position is left
    assert fakebar.widgets == [widget_box, tb_one, tb_two]

    # Close box
    widget_box.cmd_toggle()

    # Check it's closed
    assert not widget_box.box_is_open

    # Check widgets have been removed
    assert fakebar.widgets == [widget_box]

    # Move button to right-hand side
    widget_box.close_button_location = "right"

    # Re-open box with new layout
    widget_box.cmd_toggle()

    # Now widgetbox is on the right
    assert fakebar.widgets == [tb_one, tb_two, widget_box]
コード例 #2
0
def test_widgetbox_widget(fake_qtile, fake_window):

    tb_one = TextBox(name="tb_one", text="TB ONE")
    tb_two = TextBox(name="tb_two", text="TB TWO")

    # Give widgetbox invalid value for button location
    widget_box = WidgetBox([tb_one, tb_two],
                           close_button_location="middle",
                           fontsize=10)

    # Create a bar and set attributes needed to run widget
    fakebar = Bar([widget_box], 24)
    fakebar.window = fake_window
    fakebar.width = 10
    fakebar.height = 10
    fakebar.draw = no_op

    # Configure the widget box
    widget_box._configure(fake_qtile, fakebar)

    # Invalid value should be corrected to default
    assert widget_box.close_button_location == "left"

    # Check only widget in bar is widgetbox
    assert fakebar.widgets == [widget_box]

    # Open box
    widget_box.cmd_toggle()

    # Check it's open
    assert widget_box.box_is_open

    # Default text position is left
    assert fakebar.widgets == [widget_box, tb_one, tb_two]

    # Close box
    widget_box.cmd_toggle()

    # Check it's closed
    assert not widget_box.box_is_open

    # Check widgets have been removed
    assert fakebar.widgets == [widget_box]

    # Move button to right-hand side
    widget_box.close_button_location = "right"

    # Re-open box with new layout
    widget_box.cmd_toggle()

    # Now widgetbox is on the right
    assert fakebar.widgets == [tb_one, tb_two, widget_box]
コード例 #3
0
ファイル: config.py プロジェクト: scullyware/qtile_config
def init_widgets():
    prompt = "{0}@{1}: ".format(os.environ["USER"], hostname)
    widgets = [
        Prompt(prompt=prompt,
               font="DejaVu Sans Mono",
               padding=10,
               background=GREY),
        TextBox(text="◤ ",
                fontsize=45,
                padding=-8,
                foreground=GREY,
                background=DARK_GREY),
        CurrentLayoutIcon(scale=0.6, padding=-4),
        TextBox(text=" ", padding=2),
        GroupBox(fontsize=11,
                 padding=2.8,
                 borderwidth=1,
                 urgent_border=DARK_BLUE,
                 disable_drag=True,
                 highlight_method="block",
                 this_screen_border=DARK_BLUE,
                 other_screen_border=DARK_ORANGE,
                 this_current_screen_border=BLUE,
                 other_current_screen_border=ORANGE),
        TextBox(text="◤",
                fontsize=45,
                padding=-1,
                foreground=DARK_GREY,
                background=GREY),
        TaskList(borderwidth=0,
                 highlight_method="block",
                 background=GREY,
                 border=DARK_GREY,
                 urgent_border=DARK_BLUE),
        Systray(background=GREY),
        TextBox(text="◤",
                fontsize=45,
                padding=-1,
                foreground=GREY,
                background=DARK_GREY),
        Clock(format="%A %d-%m-%Y %H:%M")
    ]
    if hostname in ("spud", "saiga"):
        widgets[-2:-2] = [
            TextBox(text=" ↯", foreground=BLUE, fontsize=14),
            Battery(update_delay=2)
        ]
    if DEBUG:
        widgets += [Sep(), CurrentLayout()]
    return widgets
コード例 #4
0
ファイル: ramnes.py プロジェクト: xianwewu/qtile-examples
def init_widgets():
    prompt = "{0}@{1}: ".format(os.environ["USER"], hostname)
    widgets = [
        Prompt(prompt=prompt,
               font="DejaVu Sans Mono",
               padding=10,
               background=GREY),
        TextBox(text="◤ ",
                fontsize=45,
                padding=-8,
                foreground=GREY,
                background=DARK_GREY),
        CurrentLayoutIcon(scale=0.6, padding=-4),
        Spacer(width=10),
        GroupBox(fontsize=8,
                 padding=4,
                 borderwidth=1,
                 urgent_border=DARK_BLUE,
                 disable_drag=True,
                 highlight_method="block",
                 this_screen_border=DARK_BLUE,
                 other_screen_border=DARK_ORANGE,
                 this_current_screen_border=BLUE,
                 other_current_screen_border=ORANGE),
        TextBox(text="◤",
                fontsize=45,
                padding=-1,
                foreground=DARK_GREY,
                background=GREY),
        TaskList(borderwidth=0,
                 highlight_method="block",
                 background=GREY,
                 border=DARK_GREY,
                 urgent_border=DARK_BLUE),
        Systray(background=GREY),
        TextBox(text="◤",
                fontsize=45,
                padding=-1,
                foreground=GREY,
                background=DARK_GREY),
        Notify(fmt=" 🔥 {}"),
        Clock(fmt=" ⌚ {}", format="%A %d-%m-%Y %H:%M")
    ]
    if os.path.isdir("/sys/module/battery"):
        widgets.insert(-1, Battery(fmt=" ⚡️ {}", update_delay=2))
    if DEBUG:
        widgets += [Sep(), CurrentLayout()]
    return widgets
コード例 #5
0
def test_mirrors_different_bar(minimal_conf_noscreen, manager_nospawn):
    """Verify that mirror created when widget reused in different bar."""
    config = minimal_conf_noscreen
    tbox = TextBox("Testing Mirrors")
    config.fake_screens = [
        libqtile.config.Screen(top=libqtile.bar.Bar([tbox], 10),
                               x=0,
                               y=0,
                               width=400,
                               height=600),
        libqtile.config.Screen(top=libqtile.bar.Bar([tbox], 10),
                               x=400,
                               y=0,
                               width=400,
                               height=600),
    ]

    manager_nospawn.start(config)
    screen0 = manager_nospawn.c.screen[0].bar["top"].info()["widgets"]
    screen1 = manager_nospawn.c.screen[1].bar["top"].info()["widgets"]

    # Original widget should be in the first screen
    assert len(screen0) == 1
    assert [w["name"] for w in screen0] == ["textbox"]

    # Widget is replaced with a mirror on the second screen
    assert len(screen1) == 1
    assert [w["name"] for w in screen1] == ["mirror"]
コード例 #6
0
class TwoScreenConfig(Config):
    auto_fullscreen = True
    groups = [
        config.Group("a"),
        config.Group("b"),
        config.Group("c"),
        config.Group("d")
    ]
    layouts = [
        layout.stack.Stack(num_stacks=1),
        layout.stack.Stack(num_stacks=2)
    ]
    floating_layout = default_config.floating_layout
    keys = [
        config.Key(
            ["control"],
            "k",
            lazy.layout.up(),
        ),
        config.Key(
            ["control"],
            "j",
            lazy.layout.down(),
        ),
    ]
    mouse = []
    follow_mouse_focus = False
    reconfigure_screens = False

    screens = []
    fake_screens = [
        libqtile.config.Screen(top=libqtile.bar.Bar([TextBox("Qtile Test")],
                                                    10),
                               x=0,
                               y=0,
                               width=400,
                               height=600),
        libqtile.config.Screen(top=libqtile.bar.Bar([TextBox("Qtile Test")],
                                                    10),
                               x=400,
                               y=0,
                               width=400,
                               height=600),
    ]
コード例 #7
0
def init_widgets():
    widgets = [
        CurrentLayoutIcon(scale=0.6, padding=8),
        GroupBox(fontsize=8, padding=4, borderwidth=1, urgent_border=DARK_BLUE,
                 disable_drag=True, highlight_method="block",
                 this_screen_border=DARK_BLUE, other_screen_border=DARK_ORANGE,
                 this_current_screen_border=BLUE,
                 other_current_screen_border=ORANGE),

        TextBox(text="◤", fontsize=45, padding=-1, foreground=DARK_GREY,
                background=GREY),

        TaskList(borderwidth=0, highlight_method="block", background=GREY,
                 border=DARK_GREY, urgent_border=DARK_BLUE,
                 markup_floating="<i>{}</i>", markup_minimized="<s>{}</s>"),

        Systray(background=GREY),
        TextBox(text="◤", fontsize=45, padding=-1,
                foreground=GREY, background=DARK_GREY),
        Notify(fmt=" 🔥 {} "),
        PulseVolume(fmt=" {}", emoji=True, volume_app="pavucontrol"),
        PulseVolume(volume_app="pavucontrol"),
        Clock(format=" ⏱ %H:%M  <span color='#666'>%A %d-%m-%Y</span>  ")
    ]
    if os.path.isdir("/sys/module/battery"):
        widgets.insert(-1, Battery(format=" {char} {percent:2.0%} ",
                                   charge_char="⚡", discharge_char="🔋",
                                   full_char="⚡", unknown_char="⚡",
                                   empty_char="⁉️ ", update_interval=2,
                                   show_short_text=False,
                                   default_text=""))
        widgets.insert(-1, Battery(fmt="<span color='#666'>{}</span> ",
                                   format="{hour:d}:{min:02d}",
                                   update_interval=2, show_short_text=True,
                                   default_text=""))
    if DEBUG:
        widgets += [Sep(), CurrentLayout()]
    return widgets
コード例 #8
0
def test_mirrors_same_bar(minimal_conf_noscreen, manager_nospawn):
    """Verify that mirror created when widget reused in same bar."""
    config = minimal_conf_noscreen
    tbox = TextBox("Testing Mirrors")
    config.screens = [
        libqtile.config.Screen(top=libqtile.bar.Bar([tbox, tbox], 10))
    ]

    manager_nospawn.start(config)
    info = manager_nospawn.c.bar["top"].info()["widgets"]

    # First instance is retained, second is replaced by mirror
    assert len(info) == 2
    assert [w["name"] for w in info] == ["textbox", "mirror"]
コード例 #9
0
def test_widgetbox_mirror(manager_nospawn, minimal_conf_noscreen):
    config = minimal_conf_noscreen
    tbox = TextBox(text="Text Box")
    config.screens = [
        libqtile.config.Screen(
            top=libqtile.bar.Bar([tbox, WidgetBox([tbox])], 10))
    ]

    manager_nospawn.start(config)

    manager_nospawn.c.widget["widgetbox"].toggle()
    topbar = manager_nospawn.c.bar["top"]
    widgets = [w["name"] for w in topbar.info()["widgets"]]
    assert widgets == ["textbox", "widgetbox", "mirror"]
コード例 #10
0
def test_widgetbox_mouse_click(manager_nospawn, minimal_conf_noscreen):
    config = minimal_conf_noscreen
    tbox = TextBox(text="Text Box")
    config.screens = [
        libqtile.config.Screen(top=libqtile.bar.Bar([WidgetBox([tbox])], 10))
    ]

    manager_nospawn.start(config)

    topbar = manager_nospawn.c.bar["top"]
    assert len(topbar.info()["widgets"]) == 1

    topbar.fake_button_press(0, "top", 0, 0, button=1)
    assert len(topbar.info()["widgets"]) == 2

    topbar.fake_button_press(0, "top", 0, 0, button=1)
    assert len(topbar.info()["widgets"]) == 1
コード例 #11
0
ファイル: widgets.py プロジェクト: pavalos6401/qtile-config
    def init_widgets(self) -> list:
        """Inits and returns the widgets for primary monitor."""

        return [
            Spacer(**self._widget_settings["spacer"]),
            TextBox(**self._widget_settings["launcher"]),
            Spacer(**self._widget_settings["spacer"]),
            GroupBox(**self._widget_settings["group_box"]),
            CurrentLayoutIcon(**self._widget_settings["current_layout_icon"]),
            Spacer(**self._widget_settings["spacer"]),
            WindowName(**self._widget_settings["window_name"]),
            Spacer(**self._widget_settings["spacer_stretch"]),
            Systray(**self._widget_settings["systray"]),
            Spacer(**self._widget_settings["spacer"]),
            PulseVolume(**self._widget_settings["pulse_volume"]),
            Clock(**self._widget_settings["calendar"]),
            Clock(**self._widget_settings["clock"]),
            Battery(**self._widget_settings["battery"])
            if self.theme_config.widgets["show_battery"] else Spacer(
                **self._widget_settings["spacer"]),
            QuickExit(**self._widget_settings["quick_exit"]),
            Spacer(**self._widget_settings["spacer"]),
        ]
コード例 #12
0
    def load_config(self):
        try:
            self.config.load()
            self.config.validate()
        except Exception as e:
            logger.exception('Error while reading config file (%s)', e)
            self.config = confreader.Config()
            from libqtile.widget import TextBox
            widgets = self.config.screens[0].bottom.widgets
            widgets.insert(0, TextBox('Config Err!'))

        if hasattr(self.core, "wmname"):
            self.core.wmname = getattr(self.config, "wmname", "qtile")

        self.dgroups = DGroups(self, self.config.groups, self.config.dgroups_key_binder)

        if self.config.widget_defaults:
            _Widget.global_defaults = self.config.widget_defaults
        if self.config.extension_defaults:
            _Extension.global_defaults = self.config.extension_defaults

        for installed_extension in _Extension.installed_extensions:
            installed_extension._configure(self)

        for i in self.groups:
            self.groups_map[i.name] = i

        for grp in self.config.groups:
            if isinstance(grp, ScratchPadConfig):
                sp = ScratchPad(grp.name, grp.dropdowns, grp.label)
                sp._configure([self.config.floating_layout],
                              self.config.floating_layout, self)
                self.groups.append(sp)
                self.groups_map[sp.name] = sp

        self.config.mouse += (Click([], "Button1", focus="after"),)
コード例 #13
0
ファイル: qtile.py プロジェクト: wetw3rx/qtile
def make_qtile():
    from argparse import ArgumentParser
    parser = ArgumentParser(
        description='A full-featured, pure-Python tiling window manager.',
        prog='qtile',
    )
    parser.add_argument(
        '--version',
        action='version',
        version=VERSION,
    )
    parser.add_argument(
        "-c",
        "--config",
        action="store",
        default=path.expanduser(
            path.join(getenv('XDG_CONFIG_HOME', '~/.config'), 'qtile',
                      'config.py')),
        dest="configfile",
        help='Use the specified configuration file',
    )
    parser.add_argument("-s",
                        "--socket",
                        action="store",
                        default=None,
                        dest="socket",
                        help='Path of the Qtile IPC socket.')
    parser.add_argument("-n",
                        "--no-spawn",
                        action="store_true",
                        default=False,
                        dest="no_spawn",
                        help='Avoid spawning apps. (Used for restart)')
    parser.add_argument('-l',
                        '--log-level',
                        default='WARNING',
                        dest='log_level',
                        choices=('DEBUG', 'INFO', 'WARNING', 'ERROR',
                                 'CRITICAL'),
                        help='Set qtile log level')
    parser.add_argument(
        '--with-state',
        default=None,
        dest='state',
        help='Pickled QtileState object (typically used only internally)',
    )
    options = parser.parse_args()
    log_level = getattr(logging, options.log_level)
    init_log(log_level=log_level)
    kore = xcore.XCore()

    try:
        if not path.isfile(options.configfile):
            try:
                makedirs(path.dirname(options.configfile), exist_ok=True)
                from shutil import copyfile
                default_config_path = path.join(path.dirname(__file__), "..",
                                                "resources",
                                                "default_config.py")
                copyfile(default_config_path, options.configfile)
                logger.info('Copied default_config.py to %s',
                            options.configfile)
            except Exception as e:
                logger.exception(
                    'Failed to copy default_config.py to %s: (%s)',
                    options.configfile, e)

        config = confreader.Config.from_file(options.configfile, kore=kore)
    except Exception as e:
        logger.exception('Error while reading config file (%s)', e)
        config = confreader.Config()
        from libqtile.widget import TextBox
        widgets = config.screens[0].bottom.widgets
        widgets.insert(0, TextBox('Config Err!'))

    # XXX: the import is here because we need to call init_log
    # before start importing stuff
    from libqtile.core import session_manager
    return session_manager.SessionManager(
        kore,
        config,
        fname=options.socket,
        no_spawn=options.no_spawn,
        state=options.state,
    )
コード例 #14
0
ファイル: my_widgets.py プロジェクト: p5ypher/dotfiles
class ComboWidget(object):
    """ 
    Combowidget is wrapper around PollText and TextBox widgets so that a widget can 
    can be prefixed and suffixed with text/icons. It contains 5 widgets
        1. title_head(glyph mostly): TextBox,
        2. title(icon mostly)): Polltext,
        3. title_tail(glyph mostly)): TextBox,
        4. body(the widget text): Polltext,
        5. body_tail (glyph mostly)): TextBox
    """
    def __init__(self,
                 title_func: Callable[[Qtile], str],
                 title_bg: str,
                 title_fg: str,
                 title_update: Optional[bool] = None,
                 title_padding: Optional[int] = None,
                 title_color_func: Optional[Callable[[Qtile],
                                                     ComboWidgetColor]] = None,
                 body_func: Optional[Callable[[Qtile], str]] = None,
                 body_bg: Optional[str] = None,
                 body_fg: Optional[str] = None,
                 body_padding: Optional[int] = None,
                 body_color_func: Optional[Callable[[Qtile],
                                                    ComboWidgetColor]] = None,
                 poll_interval: Optional[int] = None,
                 title_label: Optional[str] = None,
                 body_label: Optional[str] = None,
                 title_head_text: str = "",
                 title_tail_text: str = "",
                 body_tail_text: str = "",
                 head_tail_font: str = "sans",
                 head_tail_font_size: Optional[int] = None,
                 title_font: str = "sans",
                 title_font_size: Optional[int] = None,
                 body_font: Optional[str] = "sans",
                 body_font_size: Optional[int] = None,
                 click_func: Optional[Callable[[Qtile, int], None]] = None,
                 click_update: Optional[bool] = None,
                 hide: Optional[bool] = None,
                 inactive_hide: Optional[bool] = None,
                 margin_text: str = ""):

        if not body_func and not title_func:
            raise AttributeError("No poll functions provided")

        self.margin_text = margin_text
        self.title_func = title_func
        self.title_color_func = title_color_func
        self.update_title = title_update if title_update else False
        title_poll_interval = poll_interval if not body_func and title_update else None
        self.title_label = title_label

        self.body_func = body_func
        self.body_color_func = body_color_func
        self.body_label = body_label

        self.title_head_text = title_head_text if title_head_text else ""
        self.title_tail_text = title_tail_text if title_tail_text else ""
        self.body_tail_text = body_tail_text if body_tail_text else ""

        self.click_func = click_func
        self.click_update = click_update if click_update else False

        self.inactive_hide = inactive_hide if inactive_hide else False

        _mouse_callbacks = {
            'Button1': lambda q: self.click(q, 1),
            'Button2': lambda q: self.click(q, 2),
            'Button3': lambda q: self.click(q, 3),
            'Button4': lambda q: self.click(q, 4),
            'Button5': lambda q: self.click(q, 5),
        }

        title_func = (lambda: "") if (hide
                                      or self.body_func) else self.pollTitle
        title_head = "" if hide else self.title_head_text
        title_tail = "" if hide else self.title_tail_text
        margin_text = "" if hide else self.margin_text
        self.margin = TextBox(text=margin_text,
                              foreground=title_bg,
                              font=head_tail_font,
                              fontsize=head_tail_font_size,
                              padding=0)
        self.title_head = TextBox(text=title_head,
                                  foreground=title_bg,
                                  font=head_tail_font,
                                  fontsize=head_tail_font_size,
                                  mouse_callbacks=_mouse_callbacks,
                                  padding=0)
        self.title_tail = TextBox(text=title_tail,
                                  foreground=title_bg,
                                  font=head_tail_font,
                                  fontsize=head_tail_font_size,
                                  mouse_callbacks=_mouse_callbacks,
                                  padding=0)
        self.title = PollText(func=title_func,
                              update_interval=title_poll_interval,
                              foreground=title_fg,
                              background=title_bg,
                              font=title_font,
                              fontsize=title_font_size,
                              padding=title_padding,
                              mouse_callbacks=_mouse_callbacks)

        self.body = self.body_tail = None
        if self.body_func:
            body_func = (lambda: "") if hide else self.pollBody
            body_tail = "" if hide else self.body_tail_text
            self.title_tail.background = body_bg
            self.body = PollText(func=body_func,
                                 update_interval=poll_interval,
                                 foreground=body_fg,
                                 background=body_bg,
                                 padding=body_padding,
                                 font=body_font,
                                 fontsize=body_font_size,
                                 mouse_callbacks=_mouse_callbacks)
            self.body_tail = TextBox(text=body_tail,
                                     foreground=body_bg,
                                     font=head_tail_font,
                                     fontsize=head_tail_font_size,
                                     mouse_callbacks=_mouse_callbacks,
                                     padding=0)

    def getWidgets(self):
        if self.body:
            return [
                self.margin, self.title_head, self.title, self.title_tail,
                self.body, self.body_tail
            ]
        else:
            return [self.margin, self.title_head, self.title, self.title_tail]

    def click(self, qtile: Qtile, button: int):
        if self.click_func:
            self.click_func(qtile, button)
        if self.click_update:
            self.update()

    def pollTitle(self, force=False):
        if not self.title or not self.title_func:
            return
        result = self.title_func(qtile=self.title.qtile)
        if result:
            if self.title_color_func:
                colors = self.title_color_func(qtile=self.title.qtile)
                self.title.background = colors.background
                self.title.foreground = colors.foreground
                self.title_head.foreground = colors.background
                self.title_tail.foreground = colors.background
            if self.title_head.text != self.title_head_text:
                self.title_head.update(self.title_head_text)
            if self.title_tail.text != self.title_tail_text:
                self.title_tail.update(self.title_tail_text)
            if self.margin.text != self.margin_text:
                self.margin.update(self.margin_text)
        elif self.inactive_hide:
            self.title_head.update("")
            self.title_tail.update("")
            self.margin.update("")

        _result = self.title_label if (self.title_label and result) else result

        if force:
            self.title.update(_result)

        return _result

    def pollBody(self, force=False):
        if not self.body or not self.body_func:
            return
        result = self.body_func(qtile=self.body.qtile)
        _poll_title = True
        if result:
            if self.body_color_func:
                colors = self.body_color_func(qtile=self.body.qtile)
                self.body.background = colors.background
                self.body.foreground = colors.foreground
                self.body_tail.foreground = colors.background
            if self.body_tail.text != self.body_tail_text:
                self.body_tail.update(self.body_tail_text)
            if not self.title.text or self.title.text == "N/A":
                _poll_title = False
                self.pollTitle(force=True)
        elif self.inactive_hide:
            _poll_title = False
            for w in [
                    self.margin, self.title_head, self.title, self.title_tail,
                    self.body_tail
            ]:
                if w.text:
                    w.update("")

        if self.update_title and _poll_title:
            self.pollTitle(force=True)

        _result = self.body_label if self.body_label else result

        if force:
            self.body.update(_result)

        return _result

    def update(self):
        if self.body:
            self.pollBody(force=True)
        else:
            self.pollTitle(force=True)

    def show(self, show=True):
        if show:
            if self.body is None:
                self.pollTitle(force=True)
            else:
                self.pollBody(force=True)
        else:
            self.hide()

    def hide(self):
        for w in self.getWidgets():
            w.update("")

    def isHidden(self):
        result = [False if w.text else True for w in self.getWidgets()]
        return all(result)
コード例 #15
0
def make_qtile():
    from argparse import ArgumentParser
    parser = ArgumentParser(
        description='A full-featured, pure-Python tiling window manager.',
        prog='qtile',
    )
    parser.add_argument(
        '--version',
        action='version',
        version=VERSION,
    )
    parser.add_argument(
        "-c",
        "--config",
        action="store",
        default=path.expanduser(
            path.join(getenv('XDG_CONFIG_HOME', '~/.config'), 'qtile',
                      'config.py')),
        dest="configfile",
        help='Use the specified configuration file',
    )
    parser.add_argument("-s",
                        "--socket",
                        action="store",
                        default=None,
                        dest="socket",
                        help='Path to Qtile comms socket.')
    parser.add_argument("-n",
                        "--no-spawn",
                        action="store_true",
                        default=False,
                        dest="no_spawn",
                        help='Avoid spawning apps. (Used for restart)')
    parser.add_argument('-l',
                        '--log-level',
                        default='WARNING',
                        dest='log_level',
                        choices=('DEBUG', 'INFO', 'WARNING', 'ERROR',
                                 'CRITICAL'),
                        help='Set qtile log level')
    parser.add_argument(
        '--with-state',
        default=None,
        dest='state',
        help='Pickled QtileState object (typically used only internally)',
    )
    options = parser.parse_args()
    log_level = getattr(logging, options.log_level)
    init_log(log_level=log_level)

    try:
        config = confreader.Config.from_file(options.configfile)
    except Exception as e:
        logger.exception('Error while reading config file (%s)', e)
        config = confreader.Config()
        from libqtile.widget import TextBox
        widgets = config.screens[0].bottom.widgets
        widgets.insert(0, TextBox('Config Err!'))
    # XXX: the import is here becouse we need to call init_log
    # before start importing stuff
    from libqtile import manager
    return manager.Qtile(
        config,
        fname=options.socket,
        no_spawn=options.no_spawn,
        state=options.state,
    )
コード例 #16
0
ファイル: config.py プロジェクト: Hewame/Dotfiles
        "us": "EN",
        "iq ku_ara": "KU",
        "de": "DE",
        "ar": "AR"
    },
}

screens = [
    Screen(top=bar.Bar(
        [
            CurrentLayoutIcon(custom_icon_paths=wd_icon),
            Sep(**w_sep),
            GroupBox(**w_gbox, ),
            TextBox(
                text="🐸",
                fontsize="16",
                padding=5,
            ),
            WindowCount(),
            Prompt(**w_prompt),
            WindowName(foreground=colorz[1]),
            TextBox(
                text="📂",
                fontsize="16",
                padding=5,
                mouse_callbacks={'Button1': open_fm},
            ),
            Systray(icon_size=20),
            TextBox(
                text="[",
                foreground=colorz[2],
コード例 #17
0
    def init_top_main(self, hidpi = False):

        fontsize = 12 if not hidpi else 22

        wl  = []

        wl += [CurrentLayoutIcon(
            fontsize=fontsize,
            # custom_icon_paths=[expanduser("~/.config/qtile/icons")],
            foreground=self.color.white,
            padding=10,
            scale=0.7
        )]

        wl += [GroupBox(
            fontsize=24 if not hidpi else 40,
            font=self.font.bold,
            margin_y=3,
            margin_x=0,
            padding_y=5,
            padding_x=10 if not hidpi else 20,
            borderwidth=3,
            hide_unused=True,
            active=self.color.yellow,
            inactive=self.color.lightgrey,
            urgent_text=self.color.white,
            highlight_method="line",
            urgent_alert_method="line",
            highlight_color=self.color.grey,
            urgent_border=self.color.red,
            this_current_screen_border=self.color.yellow,
            other_screen_border=self.color.magenta,
            this_screen_border=self.color.magenta,
            other_current_screen_border=self.color.yellow,
            rounded=False,
            disable_drag=True,
            use_mouse_wheel=False
        )]

        wl += [self.space.small()]

        wl += [Prompt(
            fontsize=fontsize,
            prompt="λ : ",
            padding=10,
            bell_style="visual",
            foreground=self.color.magenta,
            background=self.color.black
        )]

        wl += [self.space.small()]

        wl += [WindowName(
            fontsize=fontsize,
            padding=0,
            show_state=False,
            for_current_screen=False,
            foreground=self.color.yellow
        )]

        wl += [self.space.extra_large()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.magenta,
            text=" "
        )]
        wl += [DF(
            fontsize=fontsize,
            foreground=self.color.magenta,
            format='{uf}{m}',
            partition='/',
            visible_on_warn=False
        )]

        wl += [self.space.small()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.magenta,
            text=" "
        )]
        wl += [DF(
            fontsize=fontsize,
            foreground=self.color.magenta,
            format='{uf}{m}',
            partition='/home',
            visible_on_warn=False
        )]

        wl += [self.separator.normal()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.blue,
            text=" "
        )]
        wl += [CPU(
            fontsize=fontsize,
            foreground=self.color.blue,
            # TODO Remove hard coded terminal
            mouse_callbacks={'Button1': lambda qtile: qtile.cmd_spawn("alacritty -e ytop")},
            format='{load_percent}%',
            update_interval=2.0
        )]

        wl += [self.space.small()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.blue,
            text=" "
        )]
        wl += [ThermalSensor(
            fontsize=fontsize,
            foreground=self.color.blue,
            threshold=90,
            mouse_callbacks={'Button1': lambda qtile: qtile.cmd_spawn("alacritty -e ytop")},
            update_interval=2.0
        )]

        wl += [self.separator.normal()]
        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.cyan,
            text=" "
        )]
        wl += [Memory(
            fontsize=fontsize,
            foreground=self.color.cyan,
            mouse_callbacks={'Button1': lambda qtile: qtile.cmd_spawn(terminal + ' -e ytop')},
            update_interval=2.0,
        )]

        wl += [self.separator.normal()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.green,
            font=self.font.bold,
            text="直 "
        )]
        wl += [Wlan(
            fontsize=fontsize,
            foreground=self.color.green,
            interface='wlp60s0',
            format='{essid} ({percent:2.0%})'
        )]

        wl += [self.separator.normal()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.orange,
            font=self.font.bold,
            text=" "
        )]
        wl += [Volume(
            fontsize=fontsize,
            foreground=self.color.orange
        )]

        wl += [self.space.small()]

        wl += [TextBox(
            fontsize=fontsize,
            foreground=self.color.orange,
            font=self.font.bold,
            text=" "
        )]
        wl += [Backlight(
            fontsize=fontsize,
            foreground=self.color.orange,
            backlight_name='intel_backlight',
            format='{percent:2.0%}'
        )]

        wl += [self.space.small()]

        wl += [Battery(
            fontsize=fontsize,
            foreground=self.color.orange,
            low_foreground=self.color.red,
            format='{char} {percent:2.0%}',
            low_percentage=0.2,
            charge_char='',
            full_char='',
            empty_char='',
            ramp_cap0_char='',
            ramp_cap1_char='',
            ramp_cap2_char='',
            ramp_cap3_char='',
            ramp_cap4_char='',
            ramp_cap0_foreground=self.color.red[0],
            ramp_cap1_foreground=self.color.red[0],
            ramp_cap2_foreground=self.color.orange[0],
            ramp_cap3_foreground=self.color.orange[0],
            ramp_cap4_foreground=self.color.green[0],
        )]

        # wl += [self.separator.normal()]
        # wl += [TextBox(
        #     font=self.font.bold,
        #     text=" "
        # )]
        # wl += [CheckUpdates(
        #     distro="Arch_checkupdates",
        #     display_format="{updates}",
        #     update_interval=900,
        #     colour_have_updates=self.color.white,
        #     colour_no_updates=self.color.white
        # )]

        # wl += [self.separator.normal()]
        # wl += [Systray(
        #     padding=3,
        #     icon_size=19 if not hidpi else 30
        # )]

        wl += [self.separator.normal()]
        wl += [Clock(
            fontsize=fontsize,
            foreground=self.color.yellow,
            format=" %d.%m.%Y  %H:%M"
        )]
        wl += [self.space.large()]

        return wl
コード例 #18
0
ファイル: markup_text_box.py プロジェクト: filinep/qtile-1
 def __init__(self, *args, **kwargs):
     TextBox.__init__(self, *args, **kwargs)
     self.markup = True
コード例 #19
0
ファイル: my_widgets.py プロジェクト: p5ypher/dotfiles
    def __init__(self,
                 title_func: Callable[[Qtile], str],
                 title_bg: str,
                 title_fg: str,
                 title_update: Optional[bool] = None,
                 title_padding: Optional[int] = None,
                 title_color_func: Optional[Callable[[Qtile],
                                                     ComboWidgetColor]] = None,
                 body_func: Optional[Callable[[Qtile], str]] = None,
                 body_bg: Optional[str] = None,
                 body_fg: Optional[str] = None,
                 body_padding: Optional[int] = None,
                 body_color_func: Optional[Callable[[Qtile],
                                                    ComboWidgetColor]] = None,
                 poll_interval: Optional[int] = None,
                 title_label: Optional[str] = None,
                 body_label: Optional[str] = None,
                 title_head_text: str = "",
                 title_tail_text: str = "",
                 body_tail_text: str = "",
                 head_tail_font: str = "sans",
                 head_tail_font_size: Optional[int] = None,
                 title_font: str = "sans",
                 title_font_size: Optional[int] = None,
                 body_font: Optional[str] = "sans",
                 body_font_size: Optional[int] = None,
                 click_func: Optional[Callable[[Qtile, int], None]] = None,
                 click_update: Optional[bool] = None,
                 hide: Optional[bool] = None,
                 inactive_hide: Optional[bool] = None,
                 margin_text: str = ""):

        if not body_func and not title_func:
            raise AttributeError("No poll functions provided")

        self.margin_text = margin_text
        self.title_func = title_func
        self.title_color_func = title_color_func
        self.update_title = title_update if title_update else False
        title_poll_interval = poll_interval if not body_func and title_update else None
        self.title_label = title_label

        self.body_func = body_func
        self.body_color_func = body_color_func
        self.body_label = body_label

        self.title_head_text = title_head_text if title_head_text else ""
        self.title_tail_text = title_tail_text if title_tail_text else ""
        self.body_tail_text = body_tail_text if body_tail_text else ""

        self.click_func = click_func
        self.click_update = click_update if click_update else False

        self.inactive_hide = inactive_hide if inactive_hide else False

        _mouse_callbacks = {
            'Button1': lambda q: self.click(q, 1),
            'Button2': lambda q: self.click(q, 2),
            'Button3': lambda q: self.click(q, 3),
            'Button4': lambda q: self.click(q, 4),
            'Button5': lambda q: self.click(q, 5),
        }

        title_func = (lambda: "") if (hide
                                      or self.body_func) else self.pollTitle
        title_head = "" if hide else self.title_head_text
        title_tail = "" if hide else self.title_tail_text
        margin_text = "" if hide else self.margin_text
        self.margin = TextBox(text=margin_text,
                              foreground=title_bg,
                              font=head_tail_font,
                              fontsize=head_tail_font_size,
                              padding=0)
        self.title_head = TextBox(text=title_head,
                                  foreground=title_bg,
                                  font=head_tail_font,
                                  fontsize=head_tail_font_size,
                                  mouse_callbacks=_mouse_callbacks,
                                  padding=0)
        self.title_tail = TextBox(text=title_tail,
                                  foreground=title_bg,
                                  font=head_tail_font,
                                  fontsize=head_tail_font_size,
                                  mouse_callbacks=_mouse_callbacks,
                                  padding=0)
        self.title = PollText(func=title_func,
                              update_interval=title_poll_interval,
                              foreground=title_fg,
                              background=title_bg,
                              font=title_font,
                              fontsize=title_font_size,
                              padding=title_padding,
                              mouse_callbacks=_mouse_callbacks)

        self.body = self.body_tail = None
        if self.body_func:
            body_func = (lambda: "") if hide else self.pollBody
            body_tail = "" if hide else self.body_tail_text
            self.title_tail.background = body_bg
            self.body = PollText(func=body_func,
                                 update_interval=poll_interval,
                                 foreground=body_fg,
                                 background=body_bg,
                                 padding=body_padding,
                                 font=body_font,
                                 fontsize=body_font_size,
                                 mouse_callbacks=_mouse_callbacks)
            self.body_tail = TextBox(text=body_tail,
                                     foreground=body_bg,
                                     font=head_tail_font,
                                     fontsize=head_tail_font_size,
                                     mouse_callbacks=_mouse_callbacks,
                                     padding=0)
コード例 #20
0
    def init_top_double(self, tray=True):

        wl = []

        wl += [self.space.large_black()]
        wl += [
            GroupBox(
                font=self.font.bold,
                fontsize=9,
                margin_y=0,
                margin_x=0,
                # padding_y = 6,
                padding_x=3,
                borderwidth=2,
                # hide_unused = True,
                active=self.color.white,
                inactive=self.color.lightgrey,
                urgent_text=self.color.white,
                highlight_method="line",
                highlight_color=["2B303B", "14161B"],
                urgent_alert_method="line",
                rounded=False,
                urgent_border=self.color.red,
                this_current_screen_border=self.color.blue,
                other_screen_border=self.color.magenta,
                this_screen_border=self.color.orange,
                other_current_screen_border=self.color.magenta,
                disable_drag=True,
                use_mouse_wheel=False)
        ]

        wl += [
            Prompt(prompt="λ : ",
                   padding=5,
                   bell_style="visual",
                   foreground=self.color.magenta,
                   background=self.color.black)
        ]

        wl += [self.space.large_black()]

        wl += [
            WindowName(fontsize=11,
                       padding=0,
                       show_state=False,
                       foreground=self.color.darkgreen)
        ]

        wl += [self.space.large_black()]

        wl += [TextBox(fontsize=16, text="")]
        wl += [Net(interface="eth0")]

        if tray:
            wl += [self.separator.bold_white()]
            wl += [Systray(padding=3, icon_size=19)]
        # if not tray:
        # 	wl += [self.separator.bold_white()]
        # wl += [CurrentLayoutIcon(
        # 	padding = 0,
        # 	custom_icon_paths = [expanduser("~/.config/qtile/icons")],
        # 	scale = 0.6
        # )]
        wl += [self.space.large_black()]

        return wl
コード例 #21
0
ファイル: markup_text_box.py プロジェクト: bogobog/qtile
 def __init__( self, *args, **kwargs ):
     TextBox.__init__( self, *args, **kwargs )
     self.markup = True    
コード例 #22
0
    def init_bottom_double(self):

        wl = []

        wl += [self.space.large_black()]
        wl += [
            TaskList(
                fontsize=11,
                margin_x=0,
                margin_y=1,
                padding_x=3,
                padding_y=2.3,
                borderwidth=1,
                # icon_size = 14,
                icon_size=0,
                spacing=1,
                # max_title_width = 190,
                title_width_method='uniform',
                urgent_alert_method="text",
                highlight_method="block",
                txt_minimized="V ",
                txt_maximized="",
                txt_floating="",
                # unfocused_border = "None",
                rounded=True,
                border=self.color.grey)
        ]
        wl += [self.space.large_black()]

        wl += [TextBox(text="")]
        wl += [
            ThermalSensor(tag_sensor="CPU",
                          threshold=85,
                          update_interval=1,
                          foreground_alert=self.color.red,
                          foreground=self.color.white)
        ]

        wl += [self.separator.bold_white()]
        wl += [TextBox(text="")]
        wl += [
            Battery(format="{char} {percent:0.1%}",
                    update_interval=5,
                    low_percentage=0.10,
                    unknown_char="",
                    full_char="",
                    charge_char="+",
                    discharge_char="-",
                    empty_char="",
                    low_foreground=self.color.red)
        ]

        wl += [self.separator.bold_white()]
        wl += [TextBox(font=self.font.bold, text="")]
        wl += [
            Memory(
                # fmt = "{MemUsed}M/{MemTotal}M - {SwapUsed}M",
                fmt="{MemUsed}M - {SwapUsed}M",
                update_interval=1)
        ]

        wl += [self.separator.bold_white()]
        wl += [TextBox(font=self.font.bold, text="")]
        wl += [CurrentLayout()]

        wl += [self.separator.bold_white()]
        wl += [TextBox(font=self.font.bold, text="")]
        wl += [
            CheckUpdates(distro="Arch_checkupdates",
                         display_format="{updates}",
                         update_interval=900,
                         colour_have_updates=self.color.white,
                         colour_no_updates=self.color.white)
        ]

        wl += [self.separator.bold_white()]
        wl += [TextBox(font=self.font.bold, text="")]
        wl += [Clock(format="%a, %b %d - %H:%M")]
        wl += [self.space.large_black()]

        return wl
コード例 #23
0
    def init_top_single(self, tray=True):

        wl = []

        wl += [self.space.large_black()]
        wl += [
            GroupBox(
                font=self.font.bold,
                fontsize=9,
                margin_y=0,
                margin_x=0,
                # padding_y = 6,
                padding_x=3,
                borderwidth=2,
                # hide_unused = True,
                active=self.color.white,
                inactive=self.color.lightgrey,
                urgent_text=self.color.white,
                highlight_method="line",
                highlight_color=["2B303B", "14161B"],
                urgent_alert_method="line",
                rounded=False,
                urgent_border=self.color.red,
                this_current_screen_border=self.color.blue,
                other_screen_border=self.color.magenta,
                this_screen_border=self.color.orange,
                other_current_screen_border=self.color.magenta,
                disable_drag=True,
                use_mouse_wheel=False)
        ]

        wl += [
            Prompt(prompt="λ : ",
                   padding=5,
                   bell_style="visual",
                   foreground=self.color.magenta,
                   background=self.color.black)
        ]

        wl += [self.space.large_black()]

        wl += [
            WindowName(fontsize=11,
                       padding=0,
                       show_state=False,
                       foreground=self.color.darkgreen)
        ]

        wl += [self.space.large_black()]

        wl += [TextBox(fontsize=16, text="")]
        wl += [Net(interface="eth0")]

        wl += [self.separator.bold_white()]
        wl += [TextBox(text="")]
        wl += [
            ThermalSensor(tag_sensor="CPU",
                          threshold=85,
                          update_interval=1,
                          foreground_alert=self.color.red,
                          foreground=self.color.white)
        ]

        wl += [self.separator.bold_white()]
        wl += [TextBox(text="")]
        wl += [
            Battery(format="{char} {percent:0.1%}",
                    update_interval=5,
                    low_percentage=0.10,
                    unknown_char="",
                    full_char="",
                    charge_char="+",
                    discharge_char="-",
                    empty_char="",
                    low_foreground=self.color.red)
        ]

        wl += [self.separator.bold_white()]
        wl += [TextBox(font=self.font.bold, text="")]
        wl += [
            Memory(
                # fmt = "{MemUsed}M/{MemTotal}M - {SwapUsed}M",
                fmt="{MemUsed}M - {SwapUsed}M",
                update_interval=1)
        ]

        wl += [self.separator.bold_white()]
        wl += [TextBox(font=self.font.bold, text="")]
        wl += [CurrentLayout()]

        wl += [self.separator.bold_white()]
        wl += [TextBox(font=self.font.bold, text="")]
        wl += [
            CheckUpdates(distro="Arch_checkupdates",
                         display_format="{updates}",
                         update_interval=900,
                         colour_have_updates=self.color.white,
                         colour_no_updates=self.color.white)
        ]

        if tray:
            wl += [self.separator.bold_white()]
            wl += [Systray(padding=3, icon_size=19)]
        # if not tray:
        # 	wl += [self.separator.bold_white()]
        # wl += [CurrentLayoutIcon(
        # 	padding = 0,
        # 	custom_icon_paths = [expanduser("~/.config/qtile/icons")],
        # 	scale = 0.6
        # )]

        wl += [self.separator.bold_white()]
        wl += [TextBox(font=self.font.bold, text="")]
        wl += [Clock(format="%a, %b %d - %H:%M")]
        wl += [self.space.large_black()]

        return wl