i3pystatus icon indicating copy to clipboard operation
i3pystatus copied to clipboard

[request] timer module - desktop notification on overflow

Open tcpaiva opened this issue 8 years ago • 8 comments

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).

tcpaiva avatar Jun 18 '16 03:06 tcpaiva

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:

richese avatar Jun 18 '16 08:06 richese

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);

tcpaiva avatar Jun 19 '16 05:06 tcpaiva

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.

richese avatar Jun 19 '16 06:06 richese

here you can find more information about that.

tcpaiva avatar Jun 19 '16 06:06 tcpaiva

@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.

richese avatar Jun 19 '16 17:06 richese

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. =)

tcpaiva avatar Jun 19 '16 17:06 tcpaiva

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?)

enkore avatar Jun 20 '16 19:06 enkore

@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.

richese avatar Jun 20 '16 21:06 richese