From 4d2bd4cc53be5214c29bae5eb96c029f8e99a611 Mon Sep 17 00:00:00 2001 From: Thomas Preisner Date: Fri, 2 Mar 2018 20:38:06 +0100 Subject: [PATCH] config: barpyrus: config.py: use TabbedLayout for keyboard switcher Using the ShortLongLayout works well, but having a colored keyboard icon with changing background color instead of '<'/'>' is fancier. Thus it has been exchanged by a TabbedLayout using a custom rendering function (kbd_renderer) which does exactly that. --- config/barpyrus/config.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/config/barpyrus/config.py b/config/barpyrus/config.py index c5c5c30..44b28e8 100644 --- a/config/barpyrus/config.py +++ b/config/barpyrus/config.py @@ -108,6 +108,19 @@ setxkbmap += ' -option compose:ralt -option compose:rctrl' def frame(content, bg, fg, padding = (3, 3)): return Theme(bg = color[bg], fg = color[fg], padding = padding)(content) +# renderer for the keyboard selection +def kbd_renderer(self, painter): + if self.label == '0': + painter.fg(color['lightgrey']) + painter.symbol(0xe26f) + painter.space(8) + else: + painter.fg(color['cyan']) + painter.bg(color['grey']) + painter.space(8) + painter.symbol(0xe26f) + painter.space(8) + # get space for the panel hc(['pad', str(monitor), str(height)]) @@ -129,12 +142,11 @@ bar.widget = W.ListLayout([ W.RawLabel('%{r}'), conky.ConkyWidget(text = conky_text), - W.ShortLongLayout( - W.RawLabel(''), - W.ListLayout([ + W.TabbedLayout([ + ('0', W.RawLabel('')), + ('1', W.ListLayout([ hlwm.HLWMLayoutSwitcher(hc, xkblayouts, command = setxkbmap.split(' ')), - W.RawLabel(' '), - ]) - ), + W.RawLabel(' ')])) + ], tab_renderer = kbd_renderer), frame(W.DateTime('%d. %B, %H:%M'), 'grey', 'white'), ])