From d9d5397f360b7b57353c381a9bbbe2e283650439 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 19 Feb 2024 13:49:26 -0800 Subject: make max title length configurable --- panel.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/panel.py b/panel.py index 10abafe..32fc037 100755 --- a/panel.py +++ b/panel.py @@ -229,8 +229,9 @@ class ModHLWMTags(ModHLWMBase): subprocess.run(('herbstclient', *cmd.split())) class ModHLWMTitle(ModHLWMBase): - def __init__(self, **kwargs): + def __init__(self, max_len=None, **kwargs): super().__init__(**kwargs) + self.max_len = max_len self.listen('focus_changed', self.refresh) self.listen('window_title_changed', self.refresh) @@ -239,7 +240,10 @@ class ModHLWMTitle(ModHLWMBase): def refresh(self): title = self.hc('attr', 'clients.focus.title') - self.out = title if len(title) < 65 else title[0:63] + '…' + self.out = ( + title[0:self.max_len-1] + '…' + if self.max_len and len(title) > self.max_len + else title) self.repaint() class ModInputUnavail(Mod): @@ -330,7 +334,7 @@ class Panel: Panel( ModHLWMTags(spacing=0), - ModHLWMTitle(), + ModHLWMTitle(max_len=96), ModRight(), ModInputUnavail( '/dev/input/by-id/usb-HID_Keyboard_HID_Keyboard-event-kbd', -- cgit v1.2.3-70-g09d2