8000 "Lock" timer_module updates to whole seconds instead of simply sleeping for some amount · Issue #2064 · polybar/polybar · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
"Lock" timer_module updates to whole seconds instead of simply sleeping for some amount #2064
Closed
@darkwater

Description

@darkwater

Is your feature request related to a problem? Please describe.

The easiest way to explain this is with an example. Imagine a module like this:

[module/date]
type = "internal/date";
interval = 60;
time = "%H:%M";

This would update the clock once every minute, which seems ideal, but it's not entirely accurate, since it doesn't update at the start of a new minute.

It would be more obvious if you also show the seconds; you would see 08:10:37, 08:11:37, 08:12:37, etc.

In addition, the inaccuracy will actually drift over time because there's actually (interval + time_to_update) seconds between each update; something like 1.002s.

My suggestion would be to sleep until the start of the next {minute, second, whatever interval is specified}. So instead of sleeping for interval_seconds, it would be sleeping for something like interval_seconds - (current_real_time_in_seconds % interval_seconds). With an interval of 5 seconds, this might end up sleeping for something like 3.245s the first time depending on when polybar was launched to sync up with the clock, and then 4.999s every time.

Why does polybar need this feature?

This would make clocks more accurate, with virtually no downside to pretty much all users.

Describe alternatives you've considered

I guess you could hack something like this together with custom script modules using tail, but I believe this should be part of polybar itself. i3status also does this. Currently, to make clocks like %H:%M accurate, you'd need an interval of a (few) second(s), but that would mean the module would update too often, wasting hundreds of precious CPU cycles!!!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0