Skip to content
This repository was archived by the owner on Jun 25, 2024. It is now read-only.
This repository was archived by the owner on Jun 25, 2024. It is now read-only.

Clock is incorrent after suspend #150

@WGH-

Description

@WGH-

After computer is resumed from suspend, the time in the bar is often incorrect. Depending on luck, it might show the time just before the suspend for up to one minute.

This's likely caused by the fact that the timer uses scheduler that doesn't advance during sleep. E.g. if you suspend the machine at 18:03:01, and resume at 20:03:59, the clock won't update for about a minute.

This can be fixed by using Linux-specific timerfd: you can arm the timer to be triggered every minute at exactly :00 seconds of real-time clock, and you will only have to integrate the file descriptor into the event loop. If you skip the event (due to suspend as well), it will trigger immediately, and the kernel will even tell how many expirations you have skipped (this's not really relevant to this use case, but still pretty cool).

I used this in my own toy event-driven i3status-replacement, and it worked pretty well: https://github.com/WGH-/myi3status/blob/c738163286ccde1f31bc0cfefbd78141412f3f4b/src/utils.cpp#L11-L30 https://github.com/WGH-/myi3status/blob/1cc1448c25179f4437b14ad447667f57294ed76a/src/widget_time.cpp#L23-L28

If this idea sounds good, I can try to implement a PoC for barista.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmoduleCan affect user bars that use a specific built-in module

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions