From 5d78e2a0631daad676135ed322d72c23a9239947 Mon Sep 17 00:00:00 2001 From: Sigmanificient Date: Sat, 14 Sep 2024 19:01:15 +0200 Subject: [PATCH] Remove battery indicator on desktop --- home/qtile/src/core/bar.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/home/qtile/src/core/bar.py b/home/qtile/src/core/bar.py index aecf5dd..f0fe004 100644 --- a/home/qtile/src/core/bar.py +++ b/home/qtile/src/core/bar.py @@ -1,3 +1,6 @@ +import re +import subprocess + from libqtile import bar, widget from utils import Color @@ -43,10 +46,21 @@ def __init__(self, id_): margin=[0, 0, 8, 0] ) + def is_desktop(self) -> bool: + machine_info = subprocess.check_output( + ["hostnamectl", "status"], universal_newlines=True) + m = re.search(r"Chassis: (\w+)\s.*\n", machine_info) + chassis_type = "desktop" if m is None else m.group(1) + + return chassis_type == "desktop" + def _build_widgets(self): - widgets_copy = [widget_cls() for widget_cls in self._widgets] + if self.is_desktop(): + self._widgets = [w for w in self._widgets if w != Battery] + widgets = [widget_cls() for widget_cls in self._widgets] if self.id == 0: - widgets_copy.insert(13, Systray()) - return widgets_copy + widgets.insert(13, Systray()) + + return widgets