vivien / i3blocks

The hacker-friendly status_command for Sway and i3
https://vivien.github.io/i3blocks/
GNU General Public License v3.0
2.28k stars 181 forks source link

Interval should align with actual time. #486

Open iguanajuice opened 1 month ago

iguanajuice commented 1 month ago

If you set an interval of 5 seconds, it should run every 5 seconds on the clock.

An example config like this:

[date]
command=date
interval=5

might currently output like so:

Sun Jul 28 01:18:07 PM EDT 2024
Sun Jul 28 01:18:12 PM EDT 2024
Sun Jul 28 01:18:17 PM EDT 2024
...

instead of like this:

Sun Jul 28 01:18:05 PM EDT 2024
Sun Jul 28 01:18:10 PM EDT 2024
Sun Jul 28 01:18:15 PM EDT 2024
...

This is especially desired for minutely and hourly intervals; with i3blocks's current behaviour, setting a command to run every hour won’t run when the hour actually changes on the clock.

gportay commented 1 month ago

I do not think it should.

TBH, i3block is scheduler spawning scripts starting counting since it is started.

Synchronizing the start on the second zero and maintaining it is complex since the date time may be reset after i3block is started (either by yourself, ot the by the NTP, or whatsoever).

Having such feature is resteicted to block let outputting the date time, and thus it is not very general purpose.

The example you took is a very simple example. If you want kind of human alignment syncing, you have not choice but to set interval to 1 to output the current time every seconds.

And remember, that the output will never be the actual time since it it never sync on actual time.

However, you have all you need to implement your request yourself within a block let, using the persistent block let.

Furthermore, how should i3block behave with a 7 second interval for the second minute? i.e. a 60s modulo interval that is not zero. Does it break the 7 interval to sync up with the next zero second? Or should it output HH:mm:02 (If I know counting)?