Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pomodoro module is not updating timer when i3bar is not visible #179

Closed
ghost opened this issue Feb 16, 2016 · 13 comments
Closed

pomodoro module is not updating timer when i3bar is not visible #179

ghost opened this issue Feb 16, 2016 · 13 comments
Assignees

Comments

@ghost
Copy link

ghost commented Feb 16, 2016

Hi,

Pomodoro's module timer is stopped when i3bar is not shown in display, situations where I found this:

I don't know if this could affect other modules that require to be updated.

For me this is a big issue that I don't know how to fix.

@ghost ghost changed the title pomodoro module is not updating timer when i3 bar is not visible pomodoro module is not updating timer when i3bar is not visible Feb 16, 2016
@ultrabug ultrabug self-assigned this Feb 16, 2016
@ultrabug
Copy link
Owner

Hello @pedro-nonfree,

Well this behaviour is expected when running with mode hide only imho (I can't reproduce when doing full screen or switching to tty).

This is not related to py3status but is instead a feature of i3bar.

  • When the bar gets hidden, the i3bar code sends a SIGSTOP to the whole process (py3status included) so everything is freezed.
  • When the bar is unhidden, a SIGCONT is sent and the process continues.

This is here : http://code.stapelberg.de/git/i3/commit/?id=a83e7699e75cad515019aa1ad5f7d59ee236a918

The only workaround I could think of regarding pomodoro would be to calculate the remaining seconds based on a timestamp instead of a simple decrementation of an interger. But this couldn't beat the fact that you'd get no notification since the whole process is freezed by i3bar.

Hope this helps mate.

@ghost
Copy link
Author

ghost commented Feb 16, 2016

I'm using self compiled version:
i3 version 4.11-31-gd3f42c2 (2015-11-16, branch "master") © 2009 Michael Stapelberg and contributors

in Debian 8.3 Stable Jessie

I don't know why you cannot reproduce it.

Timestamp is a nice idea!

@Anon1234
Copy link
Contributor

@pedro-nonfree another workaround could be recompiling i3 with reverted a83e7699e7 commit.

@ultrabug
Copy link
Owner

Problem with timestamp @pedro-nonfree is that you still would never get your pomodoro's notifications ! This defeats the whole point of it don't you think ?

@ghost
Copy link
Author

ghost commented Feb 17, 2016

@Anon1234 Oh no, back to 2010 ? 😢

@ultrabug Use case is not always being in this "hide" situations. So you receive a late notification, better than nothing.
Uh, and I don't know why you cannot reproduce this for full screen (Mod + F) or going to tty.

Thinking in a better design, what about starting an independent background process for the timer and notification, and share that info with py3status to print it in the bar?

This is in general useful for other modules such as battery notifications, perhaps for new possible modules?

@pydsigner
Copy link
Contributor

@ultrabug We definitely need to fix the pomodoro countdown to look at time.time() changes rather than naively assuming 1 sec/update.
@pedro-nonfree I think that this is a good use case for the proposed py3status IPC capability; have a pomodoro daemon that sends updates to the pomodoro module.

Alternatively, this could be addressed now by using subprocess to communicate with a pomodoro process. I've used subprocess to watch the output of tail -f and update a py3status module and it works quite nicely in my experience.

@pydsigner
Copy link
Contributor

@pedro-nonfree You wouldn't be going back to 2010, @Anon1234 is suggesting that you only revert that one commit. So you'd just run something like git revert a83e7699e7 and then recompile.

@ghost
Copy link
Author

ghost commented Feb 17, 2016

@pydsigner
First time I git revert, merged blindly, but I experience the same problems as described in my first message.

@Anon1234
Copy link
Contributor

This patch works for me:

diff --git a/i3bar/src/child.c b/i3bar/src/child.c
index 3570dde..3c787ee 100644
--- a/i3bar/src/child.c
+++ b/i3bar/src/child.c
@@ -654,10 +654,10 @@ void kill_child(void) {
  *
  */
 void stop_child(void) {
-    if (child.stop_signal > 0 && !child.stopped) {
-        child.stopped = true;
-        killpg(child.pid, child.stop_signal);
-    }
+    // if (child.stop_signal > 0 && !child.stopped) {
+    //     child.stopped = true;
+    //     killpg(child.pid, child.stop_signal);
+    // }
 }

 /*

Tested with this module:

from time import time, sleep


class Py3status(object):

    cache_timeout = 1
    count = 0

    def incr_count(self, *args):
        self.count += 1
        return dict(full_text=str(self.count),
                    cached_until=time()+self.cache_timeout)


if __name__ == '__main__':
    x = Py3status()

    for i in range(5):
        print(x.incr_count())
        sleep(x.cache_timeout)

@ghost
Copy link
Author

ghost commented Feb 17, 2016

@Anon1234
I can verify that your patch (with suggested git revert) pomodoro works as expected in my 3 use cases described! Such nice!

Now my question for i3, I understand this is a sweety optimization, but is necessary, really?

@Anon1234
Copy link
Contributor

@pedro-nonfree you don't need to revert if using the patch

@ghost
Copy link
Author

ghost commented Feb 17, 2016

@Anon1234 true, latest master with that patch works.

Correcting myself about that optimization: well, that commit fixed a bug...

And I found a related issue to mode hide: after first pomodoro (during break, or next pomodoros) i3bar cannot hide. Pressing mod key, i3bard hides and appears again perhaps during print/sleep 1.

@ultrabug
Copy link
Owner

Hello,

This behaviour has been fixed thanks to the work of @tobes and @cornerman on PR #266 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants