Small tweaks for new navbar and fallback for older qtile on work laptop
This commit is contained in:
parent
e4b40d40b1
commit
dfcb366241
3 changed files with 60 additions and 28 deletions
|
|
@ -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"))
|
||||||
|
|
|
||||||
|
|
@ -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,12 +687,13 @@ 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 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'
|
pass # Wayland background layer 'window'
|
||||||
else:
|
else:
|
||||||
logger.error(f"Unknown window type {client.__class__.__name__}")
|
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"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)
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
self.cur_type = new_type
|
||||||
|
if new_type == "floating":
|
||||||
|
self.margin = [8, 8, 0, 8]
|
||||||
|
self._set_bg_transparent()
|
||||||
else:
|
else:
|
||||||
widget.highlight_color = widget.highlight_color[:-2] + "88"
|
self.margin = [0, 0, 0, 0]
|
||||||
logger.warning(f"Highlight: {widget.highlight_color}")
|
self._set_bg_opaque()
|
||||||
self.drawer.clear(self.background)
|
|
||||||
self.draw()
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue