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.
This commit is contained in:
parent
675134d144
commit
4d2bd4cc53
1 changed files with 18 additions and 6 deletions
|
|
@ -108,6 +108,19 @@ setxkbmap += ' -option compose:ralt -option compose:rctrl'
|
||||||
def frame(content, bg, fg, padding = (3, 3)):
|
def frame(content, bg, fg, padding = (3, 3)):
|
||||||
return Theme(bg = color[bg], fg = color[fg], padding = padding)(content)
|
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
|
# get space for the panel
|
||||||
hc(['pad', str(monitor), str(height)])
|
hc(['pad', str(monitor), str(height)])
|
||||||
|
|
||||||
|
|
@ -129,12 +142,11 @@ bar.widget = W.ListLayout([
|
||||||
|
|
||||||
W.RawLabel('%{r}'),
|
W.RawLabel('%{r}'),
|
||||||
conky.ConkyWidget(text = conky_text),
|
conky.ConkyWidget(text = conky_text),
|
||||||
W.ShortLongLayout(
|
W.TabbedLayout([
|
||||||
W.RawLabel(''),
|
('0', W.RawLabel('')),
|
||||||
W.ListLayout([
|
('1', W.ListLayout([
|
||||||
hlwm.HLWMLayoutSwitcher(hc, xkblayouts, command = setxkbmap.split(' ')),
|
hlwm.HLWMLayoutSwitcher(hc, xkblayouts, command = setxkbmap.split(' ')),
|
||||||
W.RawLabel(' '),
|
W.RawLabel(' ')]))
|
||||||
])
|
], tab_renderer = kbd_renderer),
|
||||||
),
|
|
||||||
frame(W.DateTime('%d. %B, %H:%M'), 'grey', 'white'),
|
frame(W.DateTime('%d. %B, %H:%M'), 'grey', 'white'),
|
||||||
])
|
])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue