Small tweaks for new navbar and fallback for older qtile on work laptop

This commit is contained in:
Kevin Alberts 2026-02-17 12:23:06 +01:00
parent e4b40d40b1
commit dfcb366241
3 changed files with 60 additions and 28 deletions

View file

@ -92,7 +92,9 @@ class Config(GeneralConfig):
def initialize(cls, qtile): def initialize(cls, qtile):
super(Config, cls).initialize(qtile=qtile) super(Config, cls).initialize(qtile=qtile)
# Add keyboard remapping to autostart apps # 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 # Determine screens programatically
qtile_width = int(os.getenv("QTILE_WIDTH", "3840")) qtile_width = int(os.getenv("QTILE_WIDTH", "3840"))

View file

@ -9,7 +9,14 @@ from dateutil import tz
from typing import Optional from typing import Optional
from libqtile.backend.base import Window 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 from libqtile.backend.x11.window import XWindow as XorgXWindow
# Initialize logging # Initialize logging
from libqtile.log_utils import logger from libqtile.log_utils import logger
@ -680,15 +687,16 @@ class Kuro(BaseTheme):
# TODO: Move get_pid to an utility function # TODO: Move get_pid to an utility function
w_pid = None w_pid = None
try: if hasattr(client, 'get_pid'):
w_pid = client.get_pid() w_pid = client.get_pid()
except AttributeError: # Some windows might not have this .get_pid method. Try other ways elif hasattr(client, 'get_net_wm_pid'):
if isinstance(client, XorgXWindow): w_pid = client.get_net_wm_pid()
w_pid = client.get_net_wm_pid() elif hasattr(client, 'surface') and hasattr(client.surface, 'pid'):
elif isinstance(client, WaylandStatic) or isinstance(client, WaylandInternal): w_pod = client.surface.pid
pass # Wayland background layer 'window' elif client.__class__.__name__ in ["Static", "XStatic", "LayerStatic"]:
else: pass # Wayland background layer 'window'
logger.error(f"Unknown window type {client.__class__.__name__}") 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(): if w_pid is not None and w_pid in self.autostart_app_rules.keys():
rule_id = self.autostart_app_rules[w_pid] 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"Ignored clients: {ignore_windows}")
logger.warning(f"Extra clients: {extra_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)): 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: else:
screen_ref.top.margin = [0, 0, 0, 0] screen_ref.top.update_bar_type("docked")
elif isinstance(layout_ref, layout.columns.Columns): elif isinstance(layout_ref, layout.columns.Columns):
clients = extra_windows clients = extra_windows
for column in layout_ref.columns: for column in layout_ref.columns:
clients.extend(column.clients) clients.extend(column.clients)
is_single = len([c for c in clients if c not in ignore_windows]) == 1 is_single = len([c for c in clients if c not in ignore_windows]) == 1
if is_single: if is_single:
screen_ref.top.margin = [0, 0, 0, 0] screen_ref.top.update_bar_type("docked")
else: else:
screen_ref.top.margin = [8, 8, 0, 8] screen_ref.top.update_bar_type("floating")
else: else:
screen_ref.top.margin = [8, 8, 0, 8] screen_ref.top.update_bar_type("floating")
# Re-render the top bar to apply margins # Re-render the top bar to apply margins
screen_ref.top._configure(qtile=qtile, screen=screen_ref, reconfigure=True) screen_ref.top._configure(qtile=qtile, screen=screen_ref, reconfigure=True)

View file

@ -19,8 +19,22 @@ class KuroBar(bar.Bar):
), ),
] ]
def process_pointer_enter(self, x: int, y: int) -> None: cur_type: str = "docked"
super().process_pointer_enter(x=x, y=y)
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 self.background = self.background_hover
# GroupBox Widget background color # GroupBox Widget background color
for widget in self.widgets: for widget in self.widgets:
@ -33,16 +47,24 @@ class KuroBar(bar.Bar):
self.drawer.clear(self.background) self.drawer.clear(self.background)
self.draw() 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: def process_pointer_leave(self, x: int, y: int) -> None:
super().process_pointer_leave(x=x, y=y) super().process_pointer_leave(x=x, y=y)
self.background = self.background_normal if self.cur_type == "floating":
# GroupBox Widget background color self._set_bg_transparent()
for widget in self.widgets:
if isinstance(widget, GroupBox): def update_bar_type(self, new_type: str):
if len(widget.highlight_color) in [6, 7]: if new_type not in ["docked", "floating"]:
widget.highlight_color = widget.highlight_color + "88" return
else: self.cur_type = new_type
widget.highlight_color = widget.highlight_color[:-2] + "88" if new_type == "floating":
logger.warning(f"Highlight: {widget.highlight_color}") self.margin = [8, 8, 0, 8]
self.drawer.clear(self.background) self._set_bg_transparent()
self.draw() else:
self.margin = [0, 0, 0, 0]
self._set_bg_opaque()