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):
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"))

View file

@ -9,7 +9,14 @@ from dateutil import tz
from typing import Optional
from libqtile.backend.base import Window
# 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,12 +687,13 @@ 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):
elif hasattr(client, 'get_net_wm_pid'):
w_pid = client.get_net_wm_pid()
elif isinstance(client, WaylandStatic) or isinstance(client, WaylandInternal):
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__}")
@ -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)

View file

@ -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"
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:
widget.highlight_color = widget.highlight_color[:-2] + "88"
logger.warning(f"Highlight: {widget.highlight_color}")
self.drawer.clear(self.background)
self.draw()
self.margin = [0, 0, 0, 0]
self._set_bg_opaque()