summaryrefslogtreecommitdiff
path: root/i3status.c
diff options
context:
space:
mode:
authorGereon Kremer <gereon.kremer@rwth-aachen.de>2013-01-05 12:47:02 +0100
committerMichael Stapelberg <michael@stapelberg.de>2013-01-08 22:02:03 +0100
commit11757b8105ebebba40c3a94c5d6c5431cc58b3d1 (patch)
tree390608f8a2e50f8b06dfd193686c46b380e5a57f /i3status.c
parent6147e2b268fd1ffc858453f833f443b8778bc986 (diff)
make refreshs align with minutes
Diffstat (limited to 'i3status.c')
-rw-r--r--i3status.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/i3status.c b/i3status.c
index 87a793b..af62a7c 100644
--- a/i3status.c
+++ b/i3status.c
@@ -515,10 +515,11 @@ int main(int argc, char *argv[]) {
/* To provide updates on every full second (as good as possible)
* we don’t use sleep(interval) but we sleep until the next
* second (with microsecond precision) plus (interval-1)
- * seconds. */
+ * seconds. We also align to 60 seconds modulo interval such
+ * that we start with :00 on every new minute. */
struct timeval current_timeval;
gettimeofday(&current_timeval, NULL);
- struct timespec ts = {interval - 1, (10e5 - current_timeval.tv_usec) * 1000};
+ struct timespec ts = {interval - 1 - (current_timeval.tv_sec % interval), (10e5 - current_timeval.tv_usec) * 1000};
nanosleep(&ts, NULL);
}
}