diff --git a/core/bar/base.py b/core/bar/base.py index 1d95a2f..d0b735d 100644 --- a/core/bar/base.py +++ b/core/bar/base.py @@ -8,14 +8,14 @@ from utils.config import cfg defaults = { - "font": "SauceCodePro Nerd Font Medium", - "fontsize": 10, + "font": "Hasklug Nerd Font Mono Medium", + "fontsize": 11, "padding": None, } class Bar: - def __init__(self, theme: str) -> None: + def __init__(self, theme: str): self.theme = theme @property @@ -48,12 +48,12 @@ def base(bg: str | None, fg: str) -> dict: } -def icon_font(size=15) -> dict: - font = "SauceCodePro Nerd Font" +def symbol(size=16) -> dict: + font = "Symbols Nerd Font Mono Regular" return {"font": font, "fontsize": size} -def powerline(path: str | list[tuple], size=9) -> dict: +def powerline(path: str | list[tuple], size=10): return { "decorations": [ PowerLineDecoration( path=path, @@ -62,7 +62,7 @@ def powerline(path: str | list[tuple], size=9) -> dict: ]} # fmt: skip -def rectangle(side: str = "") -> dict: +def rectangle(side=""): return { "decorations": [ RectDecoration( filled = True, diff --git a/core/bar/shapes.py b/core/bar/shapes.py index 6559ab3..623cf44 100644 --- a/core/bar/shapes.py +++ b/core/bar/shapes.py @@ -1,7 +1,7 @@ from libqtile.bar import CALCULATED from libqtile.lazy import lazy -from core.bar.base import base, icon_font, powerline, rectangle +from core.bar.base import base, symbol, powerline, rectangle from extras import Clock, GroupBox, TextBox, modify, widget from utils.palette import palette @@ -11,209 +11,190 @@ "border_width": 4, "margin": [10, 10, 0, 10], "opacity": 1, - "size": 18, + "size": 20, } -def sep(fg, offset=0, padding=8) -> TextBox: +def sep(fg, offset=0, padding=10): return TextBox( **base(None, fg), - **icon_font(), + **symbol(11), offset=offset, padding=padding, text="󰇙", ) -def logo(bg, fg) -> TextBox: - return modify( +logo = lambda bg, fg: TextBox( + **base(bg, fg), + **symbol(), + **rectangle(), + mouse_callbacks={"Button1": lazy.restart()}, + padding=20, + text="", +) + +groups = lambda bg: GroupBox( + **symbol(), + background=bg, + borderwidth=1, + colors=[ + palette.teal, + palette.pink, + palette.yellow, + palette.red, + palette.blue, + palette.green, + ], + highlight_color=palette.base, + highlight_method="line", + inactive=palette.surface2, + invert=True, + padding=6, + rainbow=True, +) + +volume = lambda bg, fg: [ + modify( TextBox, **base(bg, fg), - **icon_font(), - **rectangle(), - mouse_callbacks={"Button1": lazy.restart()}, - offset=4, - padding=17, - text="", - ) - - -def groups(bg) -> GroupBox: - return GroupBox( - **icon_font(), - background=bg, - borderwidth=1, - colors=[ - palette.teal, - palette.pink, - palette.yellow, - palette.red, - palette.blue, - palette.green, - ], - highlight_color=palette.base, - highlight_method="line", - inactive=palette.surface2, - invert=True, - padding=7, - rainbow=True, - ) - - -def volume(bg, fg) -> list: - return [ - modify( - TextBox, - **base(bg, fg), - **icon_font(), - **rectangle("left"), - text="", - x=4, - ), - widget.Volume( - **base(bg, fg), - **powerline("arrow_right"), - check_mute_command="pamixer --get-mute", - check_mute_string="true", - get_volume_command="pamixer --get-volume-human", - mute_command="pamixer --toggle-mute", - update_interval=0.1, - volume_down_command="pamixer --decrease 5", - volume_up_command="pamixer --decrease 5", - ), - ] - - -def updates(bg, fg) -> list: - return [ - TextBox( - **base(bg, fg), - **icon_font(), - offset=-1, - text="", - x=-5, - ), - widget.CheckUpdates( - **base(bg, fg), - **rectangle("right"), - colour_have_updates=fg, - colour_no_updates=fg, - display_format="{updates} updates ", - distro="Arch_checkupdates", - initial_text="No updates ", - no_update_string="No updates ", - padding=0, - update_interval=3600, - ), - ] - - -def window_name(bg, fg) -> object: - return widget.WindowName( + **symbol(), + **rectangle("left"), + offset=-17, + padding=15, + text="", + x=-2, + ), + widget.Volume( **base(bg, fg), - format="{name}", - max_chars=60, - width=CALCULATED, - ) - + **powerline("arrow_right"), + check_mute_command="pamixer --get-mute", + check_mute_string="true", + get_volume_command="pamixer --get-volume-human", + mute_command="pamixer --toggle-mute", + update_interval=0.1, + volume_down_command="pamixer --decrease 5", + volume_up_command="pamixer --increase 5", + ), +] + +updates = lambda bg, fg: [ + TextBox( + **base(bg, fg), + **symbol(14), + offset=-1, + text="", + x=-2, + ), + widget.CheckUpdates( + **base(bg, fg), + **rectangle("right"), + colour_have_updates=fg, + colour_no_updates=fg, + display_format="{updates} updates ", + distro="Arch_checkupdates", + initial_text="No updates ", + no_update_string="No updates ", + padding=0, + update_interval=3600, + ), +] + +window_name = lambda fg: widget.WindowName( + **base(None, fg), + format="{name}", + max_chars=60, + width=CALCULATED, +) + +cpu = lambda bg, fg: [ + modify( + TextBox, + **base(bg, fg), + **symbol(14), + **rectangle("left"), + offset=-13, + padding=15, + text="󰍛", + ), + widget.CPU( + **base(bg, fg), + **powerline("arrow_right"), + format="{load_percent:.0f}%", + ), +] -def cpu(bg, fg) -> list: - return [ - modify( - TextBox, - **base(bg, fg), - **icon_font(), - **rectangle("left"), - offset=3, - text="󰍛", - x=5, - ), - widget.CPU( - **base(bg, fg), - **powerline("arrow_right"), - format="{load_percent:.0f}%", - ), - ] - - -def ram(bg, fg) -> list: - return [ - TextBox( - **base(bg, fg), - **icon_font(), - offset=-2, - padding=5, - text="󰘚", - x=-2, - ), - widget.Memory( - **base(bg, fg), - **powerline("arrow_right"), - format="{MemUsed: .0f}{mm} ", - padding=-1, - ), - ] - - -def disk(bg, fg) -> list: - return [ - TextBox( - **base(bg, fg), - **icon_font(), - offset=-1, - text="", - x=-5, - ), - widget.DF( - **base(bg, fg), - **rectangle("right"), - format="{f} GB ", - padding=0, - partition="/", - visible_on_warn=False, - warn_color=fg, - ), - ] - - -def clock(bg, fg) -> list: - return [ - modify( - TextBox, - **base(bg, fg), - **icon_font(), - **rectangle("left"), - offset=2, - text="", - x=4, - ), - modify( - Clock, - **base(bg, fg), - **rectangle("right"), - format="%A - %I:%M %p ", - long_format="%B %-d, %Y ", - padding=6, - ), - ] - - -def widgets(): - return [ - widget.Spacer(length=2), - logo(palette.blue, palette.base), - sep(palette.surface2, offset=-8), - groups(None), - sep(palette.surface2, offset=4, padding=4), - *volume(palette.pink, palette.base), - *updates(palette.red, palette.base), - widget.Spacer(), - window_name(None, palette.text), - widget.Spacer(), - *cpu(palette.green, palette.base), - *ram(palette.yellow, palette.base), - *disk(palette.teal, palette.base), - sep(palette.surface2), - *clock(palette.pink, palette.base), - widget.Spacer(length=2), - ] +ram = lambda bg, fg: [ + TextBox( + **base(bg, fg), + **symbol(14), + offset=-1, + padding=5, + text="󰘚", + ), + widget.Memory( + **base(bg, fg), + **powerline("arrow_right"), + format="{MemUsed: .0f}{mm} ", + padding=-3, + ), +] + +disk = lambda bg, fg: [ + TextBox( + **base(bg, fg), + **symbol(14), + offset=-1, + text="", + x=-2, + ), + widget.DF( + **base(bg, fg), + **rectangle("right"), + format="{f} GB ", + padding=0, + partition="/", + visible_on_warn=False, + warn_color=fg, + ), +] + +clock = lambda bg, fg: [ + modify( + TextBox, + **base(bg, fg), + **symbol(14), + **rectangle("left"), + offset=-14, + padding=15, + text="", + ), + modify( + Clock, + **base(bg, fg), + **rectangle("right"), + format="%A - %I:%M %p ", + long_format="%B %-d, %Y ", + padding=7, + ), +] + + +widgets = lambda: [ + widget.Spacer(length=2), + logo(palette.blue, palette.base), + sep(palette.surface2, offset=-14), + groups(None), + sep(palette.surface2, offset=8, padding=2), + *volume(palette.pink, palette.base), + *updates(palette.red, palette.base), + widget.Spacer(), + window_name(palette.text), + widget.Spacer(), + *cpu(palette.green, palette.base), + *ram(palette.yellow, palette.base), + *disk(palette.teal, palette.base), + sep(palette.surface2), + *clock(palette.pink, palette.base), + widget.Spacer(length=2), +] diff --git a/extras/textbox.py b/extras/textbox.py index c26b449..54e2918 100644 --- a/extras/textbox.py +++ b/extras/textbox.py @@ -1,23 +1,15 @@ import math from libqtile import bar -from libqtile.widget import textbox +from libqtile.widget import base, textbox -class TextBox(textbox.TextBox): - def __init__( - self, - offset=0, - text=" ", - width=bar.CALCULATED, - x=0, - y=0, - **config, - ): +class _TextBox(base._TextBox): + def __init__(self, text=" ", width=bar.CALCULATED, **config): super().__init__(text, width, **config) - self.add_offset = offset - self.add_x = x - self.add_y = y + self.add_offset = config.pop("offset", 0) + self.add_x = config.pop("x", 0) + self.add_y = config.pop("y", 0) def calculate_length(self): if self.text: @@ -92,3 +84,8 @@ def draw(self): else: interval = self.scroll_interval self._scroll_timer = self.timeout_add(interval, self.do_scroll) + + +class TextBox(_TextBox, textbox.TextBox): + def __init__(self, text=" ", width=bar.CALCULATED, **config): + super().__init__(text, width, **config) diff --git a/utils/config.py b/utils/config.py index 1517ab0..11c9f36 100644 --- a/utils/config.py +++ b/utils/config.py @@ -29,7 +29,7 @@ def load(cls) -> "Config": return cls(**content) @classmethod - def generate(cls, file: str) -> None: + def generate(cls, file: str): with open(file, "w") as f: content = asdict(cls()) f.write(json.dumps(content, indent=2)) diff --git a/utils/match.py b/utils/match.py index 574ab47..f6949f1 100644 --- a/utils/match.py +++ b/utils/match.py @@ -2,7 +2,7 @@ class Matches: - def __init__(self, property: str, values: tuple) -> None: + def __init__(self, property: str, values: tuple): self.property = property self.values = values