enkore / i3pystatus

A complete replacement for i3status
https://i3pystatus.readthedocs.io/
MIT License
445 stars 188 forks source link

[request] timer module - desktop notification on overflow #402

Open tcpaiva opened 8 years ago

tcpaiva commented 8 years ago

When i3bar is hided, the overflow of the timer module is easily missed because it has no obvious indication of its situation besides what is shown in the bar ("+" sign and background color).

One idea would be to make something similar to what battery module does with DesktopNotification, where a message blink while no action is done (I believe it is a desktop notification that lasts very little, but is called again in the next refresh of the bar).

richese commented 8 years ago

Timer already provides two settings on_overflow and on_reset that were created exactly for this purpose. You can pass them a string with shell commands or a python function.

I did not implement any specific method so that everyone can play with it and use whatever notification method they prefer. Since you already found that part of code in battery module I am sure you can put together what you want in a few minute time. :wink:

tcpaiva commented 8 years ago

Well, here is what I could get:

status.register("timer",
    on_leftclick = ['start', 1 * 60],
    on_overflow = DesktopNotification(
        title="Time!",
        body="Please check the timer.",
        urgency=2,
        timeout=0,
    ).display,
)

However, it does not work well because

  1. the alert is not eliminated if the overflow is cleared;
  2. the alert will show only if the i3bar is active (it is not triggered with a hidden i3bar);
richese commented 8 years ago

the alert will show only if the i3bar is active (it is not triggered with a hidden i3bar);

What exactly do you mean by hidden bar? I am not aware of any features that hide the bar in i3. The only case I can think of is a fullscreen window but then desktop notifications won't show by design since no window can be rendered on top of fullscreen window.

tcpaiva commented 8 years ago

here you can find more information about that.

richese commented 8 years ago

@tcpaiva Thanks. I do not hide my bar so I'm not very familiar with these features. I'll try it later to see if the notification does not occur while bar is hidden but it should work since #370 does not seem to be implemented yet.

I will also look at that DesktopNotification class since it looks like our little wrapper is missing some features like closing or updating an already existing notification which could be quite useful.

tcpaiva commented 8 years ago

hi @richese , thank you for spending time on this.

So, the timer itself is running, no question. When I reactive the i3bar, the timer value take around 2s to be refreshed with the right value, but it is not a problem at all. Seems that the notification call (on_overflow) itself is somehow related to the refresh of the i3bar.

The extra features on DesktopNotification wrapper will certainly be very convenient. =)

enkore commented 8 years ago

Since SIGSTOP stops the bar process (#370) I think we'd have to set an alarm(2) to wake the process up in time (and re-stop after that?)

richese commented 8 years ago

@enkore Well, I have bad and good news.

The bad news is that there is no way to wake a process from SIGSTOP other than receiving SIGCONT.

The good news is that the guys who made the i3-bar protocol did their job and it allows us to define which signals we want to receive to stop/start processing. See docs.