[core/output] Make it possible to update modules via events
Add an event callback "update-modules" that allows various pieces of bumblebee-status to update the status bar.
This commit is contained in:
parent
b9b1e65176
commit
07ca5cf383
1 changed files with 5 additions and 3 deletions
|
@ -105,6 +105,7 @@ class i3(object):
|
||||||
self.__content = {}
|
self.__content = {}
|
||||||
self.__theme = theme
|
self.__theme = theme
|
||||||
self.__config = config
|
self.__config = config
|
||||||
|
core.event.register('update-modules', self.update)
|
||||||
core.event.register('start', self.draw, 'start')
|
core.event.register('start', self.draw, 'start')
|
||||||
core.event.register('update', self.draw, 'statusline')
|
core.event.register('update', self.draw, 'statusline')
|
||||||
core.event.register('stop', self.draw, 'stop')
|
core.event.register('stop', self.draw, 'stop')
|
||||||
|
@ -165,7 +166,7 @@ class i3(object):
|
||||||
return blocks
|
return blocks
|
||||||
|
|
||||||
# TODO: only updates full text, not the state!?
|
# TODO: only updates full text, not the state!?
|
||||||
def update(self, affected_modules=None):
|
def update(self, affected_modules=None, redraw_only=False):
|
||||||
now = time.time()
|
now = time.time()
|
||||||
for module in self.__modules:
|
for module in self.__modules:
|
||||||
if affected_modules and not module.id in affected_modules:
|
if affected_modules and not module.id in affected_modules:
|
||||||
|
@ -173,8 +174,9 @@ class i3(object):
|
||||||
if not affected_modules and module.next_update:
|
if not affected_modules and module.next_update:
|
||||||
if now < module.next_update:
|
if now < module.next_update:
|
||||||
continue
|
continue
|
||||||
module.update_wrapper()
|
if not redraw_only:
|
||||||
module.next_update = now + float(module.parameter('interval', self.__config.interval()))
|
module.update_wrapper()
|
||||||
|
module.next_update = now + float(module.parameter('interval', self.__config.interval()))
|
||||||
for widget in module.widgets():
|
for widget in module.widgets():
|
||||||
self.__content[widget] = widget.full_text()
|
self.__content[widget] = widget.full_text()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue