From dfcb36624187d1195c0efa47afd18b69fb38a60a Mon Sep 17 00:00:00 2001 From: Kevin Alberts Date: Tue, 17 Feb 2026 12:23:06 +0100 Subject: [PATCH] Small tweaks for new navbar and fallback for older qtile on work laptop --- kuro/config/ppc1006083.py | 4 +++- kuro/theme.py | 36 +++++++++++++++++------------ kuro/utils/bar.py | 48 ++++++++++++++++++++++++++++----------- 3 files changed, 60 insertions(+), 28 deletions(-) diff --git a/kuro/config/ppc1006083.py b/kuro/config/ppc1006083.py index f3f6939..795526c 100644 --- a/kuro/config/ppc1006083.py +++ b/kuro/config/ppc1006083.py @@ -92,7 +92,9 @@ class Config(GeneralConfig): def initialize(cls, qtile): super(Config, cls).initialize(qtile=qtile) # Add keyboard remapping to autostart apps - cls.apps_autostart['common'].append(["xmodmap", "-e", "keycode 191 = Super_L"]) + cls.apps_autostart['common'] = [ + ["xmodmap", "-e", "keycode 191 = Super_L"] + ] # Determine screens programatically qtile_width = int(os.getenv("QTILE_WIDTH", "3840")) diff --git a/kuro/theme.py b/kuro/theme.py index 6605863..d558ebc 100644 --- a/kuro/theme.py +++ b/kuro/theme.py @@ -9,7 +9,14 @@ from dateutil import tz from typing import Optional from libqtile.backend.base import Window -from libqtile.backend.wayland.window import Window as WaylandWindow, Static as WaylandStatic + +# QTile 0.33.x fallback (for work laptop) +try: + from libqtile.backend.wayland.window import Window as WaylandWindow, Static as WaylandStatic +except ImportError: + from libqtile.backend.wayland.xwindow import XWindow as WaylandWindow, XStatic as WaylandStatic + + from libqtile.backend.x11.window import XWindow as XorgXWindow # Initialize logging from libqtile.log_utils import logger @@ -680,15 +687,16 @@ class Kuro(BaseTheme): # TODO: Move get_pid to an utility function w_pid = None - try: + if hasattr(client, 'get_pid'): w_pid = client.get_pid() - except AttributeError: # Some windows might not have this .get_pid method. Try other ways - if isinstance(client, XorgXWindow): - w_pid = client.get_net_wm_pid() - elif isinstance(client, WaylandStatic) or isinstance(client, WaylandInternal): - pass # Wayland background layer 'window' - else: - logger.error(f"Unknown window type {client.__class__.__name__}") + elif hasattr(client, 'get_net_wm_pid'): + w_pid = client.get_net_wm_pid() + elif hasattr(client, 'surface') and hasattr(client.surface, 'pid'): + w_pod = client.surface.pid + elif client.__class__.__name__ in ["Static", "XStatic", "LayerStatic"]: + pass # Wayland background layer 'window' + else: + logger.error(f"Unknown window type {client.__class__.__name__}") if w_pid is not None and w_pid in self.autostart_app_rules.keys(): rule_id = self.autostart_app_rules[w_pid] @@ -928,20 +936,20 @@ class Kuro(BaseTheme): logger.warning(f"Ignored clients: {ignore_windows}") logger.warning(f"Extra clients: {extra_windows}") if (len(layout_ref.clients) == 0 and len(extra_windows) == 0) or (len(ignore_windows) > 0 and all(w in ignore_windows for w in layout_ref.clients)): - screen_ref.top.margin = [8, 8, 0, 8] + screen_ref.top.update_bar_type("floating") else: - screen_ref.top.margin = [0, 0, 0, 0] + screen_ref.top.update_bar_type("docked") elif isinstance(layout_ref, layout.columns.Columns): clients = extra_windows for column in layout_ref.columns: clients.extend(column.clients) is_single = len([c for c in clients if c not in ignore_windows]) == 1 if is_single: - screen_ref.top.margin = [0, 0, 0, 0] + screen_ref.top.update_bar_type("docked") else: - screen_ref.top.margin = [8, 8, 0, 8] + screen_ref.top.update_bar_type("floating") else: - screen_ref.top.margin = [8, 8, 0, 8] + screen_ref.top.update_bar_type("floating") # Re-render the top bar to apply margins screen_ref.top._configure(qtile=qtile, screen=screen_ref, reconfigure=True) diff --git a/kuro/utils/bar.py b/kuro/utils/bar.py index 63d5d4f..22ae89d 100644 --- a/kuro/utils/bar.py +++ b/kuro/utils/bar.py @@ -19,8 +19,22 @@ class KuroBar(bar.Bar): ), ] - def process_pointer_enter(self, x: int, y: int) -> None: - super().process_pointer_enter(x=x, y=y) + cur_type: str = "docked" + + def _set_bg_transparent(self): + self.background = self.background_normal + # GroupBox Widget background color + for widget in self.widgets: + if isinstance(widget, GroupBox): + if len(widget.highlight_color) in [6, 7]: + widget.highlight_color = widget.highlight_color + "88" + else: + widget.highlight_color = widget.highlight_color[:-2] + "88" + logger.warning(f"Highlight: {widget.highlight_color}") + self.drawer.clear(self.background) + self.draw() + + def _set_bg_opaque(self): self.background = self.background_hover # GroupBox Widget background color for widget in self.widgets: @@ -33,16 +47,24 @@ class KuroBar(bar.Bar): self.drawer.clear(self.background) self.draw() + + def process_pointer_enter(self, x: int, y: int) -> None: + super().process_pointer_enter(x=x, y=y) + if self.cur_type == "floating": + self._set_bg_opaque() + def process_pointer_leave(self, x: int, y: int) -> None: super().process_pointer_leave(x=x, y=y) - self.background = self.background_normal - # GroupBox Widget background color - for widget in self.widgets: - if isinstance(widget, GroupBox): - if len(widget.highlight_color) in [6, 7]: - widget.highlight_color = widget.highlight_color + "88" - else: - widget.highlight_color = widget.highlight_color[:-2] + "88" - logger.warning(f"Highlight: {widget.highlight_color}") - self.drawer.clear(self.background) - self.draw() + if self.cur_type == "floating": + self._set_bg_transparent() + + def update_bar_type(self, new_type: str): + if new_type not in ["docked", "floating"]: + return + self.cur_type = new_type + if new_type == "floating": + self.margin = [8, 8, 0, 8] + self._set_bg_transparent() + else: + self.margin = [0, 0, 0, 0] + self._set_bg_opaque()