summaryrefslogtreecommitdiff
path: root/panel.py
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2024-03-01 15:30:53 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2024-03-01 15:30:53 -0800
commitf87ef86275d077cb45ee546fb53efd2334f43318 (patch)
tree647e81722c9382d2e484a560ab75d9e99b7d38c2 /panel.py
parent8662a3dc0820c9e2811658e4b490ef67a4eee3dc (diff)
downloadpanel-f87ef86275d077cb45ee546fb53efd2334f43318.tar.gz
panel-f87ef86275d077cb45ee546fb53efd2334f43318.tar.xz
automatically detect monitor width
Diffstat (limited to 'panel.py')
-rwxr-xr-xpanel.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/panel.py b/panel.py
index 0248838..17c41ca 100755
--- a/panel.py
+++ b/panel.py
@@ -181,7 +181,8 @@ class HLWMClient():
else:
self.listeners[hook] = [d]
- def exec(self, *args):
+ @staticmethod
+ def exec(*args):
res = subprocess.run(
('herbstclient', *args),
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
@@ -394,7 +395,7 @@ class ModMem(ModInterval):
self.out = Fmt.labelled('MEM', f'{percent:.0f}%%')
class Panel:
- def __init__(self, *mods, max_paint_delay=0):
+ def __init__(self, *mods, max_paint_delay=0, width=1920, height=22):
self.e_repaint = threading.Event()
self.e_flush = threading.Event()
self.mods = mods
@@ -403,6 +404,8 @@ class Panel:
m.e_flush = self.e_flush
self.mod_by_id = {id(m): m for m in self.mods}
self.max_paint_delay = max_paint_delay
+ self.width = width
+ self.height = height
def process_cmds(self, pipe):
while True:
@@ -421,7 +424,8 @@ class Panel:
('/home/david/lemonbar-xft/lemonbar',
'-bf', 'Monospace:size=10:dpi=96',
'-f', 'Monospace:size=10:dpi=96:bold',
- '-u', '2', '-g', '1920x22', '-a', '100'),
+ '-g', f'{self.width}x{self.height}',
+ '-u', '2', '-a', '100'),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
text=True)
@@ -461,5 +465,7 @@ Panel(
fmts=('%Y-%m-%d %H:%M:%S', '%H:%M'),
tzs=({'id': None}, {'id': 'UTC'},
{'id': 'Asia/Yerevan', 'label': 'AMT'})),
- max_paint_delay=0.01
+ max_paint_delay=0.01,
+ width=(re.match('[0-9]+', HLWMClient.exec('attr', 'monitors.0.geometry'))
+ .group())
).run()