lemonbar: Trigger formatting on mode cycle and i3ws events

This commit is contained in:
2020-02-02 21:06:05 +01:00
parent b21211fc2b
commit e6dc178e4d
3 changed files with 20 additions and 3 deletions

View File

@@ -60,6 +60,7 @@ class i3ws(object):
# Callback functions have argument i3ws
self.change_callbacks = []
self.focus_callbacks = []
self.final_callback = None # Called after all other callbacks
def work(self):
# While loop to restart connection as long as there is an i3 ipc socket
@@ -124,6 +125,9 @@ class i3ws(object):
for cb in self.change_callbacks:
cb(self)
if self.final_callback: # TODO ideally this would not be called on change if win_focused comes right after
self.final_callback(self)
def win_focused(self, i3, e):
self.focused_window = i3.get_tree().find_focused()
name = self.focused_window.name
@@ -134,6 +138,9 @@ class i3ws(object):
for cb in self.focus_callbacks:
cb(self)
if self.final_callback:
self.final_callback(self)
def format(self, workspaces, outputs):
# Formats the text according to the workspace data given.
# Only important when running in free standing mode