Skip to content

Commit

Permalink
Remove battery indicator on desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmanificient committed Sep 14, 2024
1 parent 812d9fa commit 5d78e2a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions home/qtile/src/core/bar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import re
import subprocess

from libqtile import bar, widget

from utils import Color
Expand Down Expand Up @@ -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

0 comments on commit 5d78e2a

Please sign in to comment.