i3pystatus icon indicating copy to clipboard operation
i3pystatus copied to clipboard

Generic update in background

Open teto opened this issue 8 years ago • 3 comments

Hi, I am very happy with how https://github.com/enkore/i3pystatus/issues/311 works and I consider extending this to all modules, ie, display an "in progress" message upon background tasks:

  • when clicking on the date, I want to sync my calendars (caldav)
  • when clicking on my mailbox, I want to sync my mailbox
  • etc...

In order for the module to know to display this "In progress" message whiule waiting for the job to finish, you need to give the module a hint. It could be via checking the callback against a specifc type ? on_leftclick=BackgroundCallback () or on_leftclick=["background_command", ]

What do you think ?

teto avatar Feb 08 '16 21:02 teto

When executing commands as callbacks it could remember the PIDs and check / use an alternate formatter while any of these PIDs are active.

enkore avatar Feb 09 '16 14:02 enkore

Here is one usecase with 2 callbacks: 1/ right click: run offlineimap to check if new mail => background task => Want "In progress" formatter 2/ left click: launch "mutt" or "thunderbird". I want the formatter to remain as is. If acting on PID, you have no way to distinguish between the 2 (i.e., changing formatter or not) ?

teto avatar Feb 10 '16 12:02 teto

I see. We could add a helper function that does the formatter switch until a PID dies. That way a callback could be formulated like this:

@get_module
def callback(self):
    pid = run_command()
    self.busy_on_pid(pid)

This could be shipped as a function to use as callback, used like this then

status.register(...
    on_leftclick=busy_execute("command")
)

(Better names are in order)

enkore avatar Feb 10 '16 13:02 enkore