[core/output] Implement autohide

Allow output to automatically hide widgets that are *not* in any
critical mode
This commit is contained in:
Tobias Witek 2020-03-15 14:01:09 +01:00
parent 6975f179fc
commit f2dc5f4b40
2 changed files with 6 additions and 0 deletions

View file

@ -39,4 +39,7 @@ class Config(util.store.Store):
def iconset(self): def iconset(self):
return self._args.iconset return self._args.iconset
def autohide(self, name):
return name in self._args.autohide
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -93,6 +93,9 @@ class i3(object):
def widgets(self, module): def widgets(self, module):
widgets = [] widgets = []
for widget in module.widgets(): for widget in module.widgets():
if self._config.autohide(widget.module().name()):
if not any(state in widget.state() for state in [ 'warning', 'critical']):
continue
widgets += self.__separator(module, widget) widgets += self.__separator(module, widget)
widgets += self.__main(module, widget, self._status[widget]) widgets += self.__main(module, widget, self._status[widget])
core.event.trigger('next-widget') core.event.trigger('next-widget')