i3 - improved tiling WM


Perform minute alignment for refreshes only once per minute

Patch status: rejected

Patch by Marco Hunsicker

Long description:

This patch ensures that the minute alignment for refreshes is only
done once per minute to make sure that the refresh interval time
is obeyed as much as possible after a refresh has been forced from
the outside. This also reduces the total number of refreshs in such
cases.

To apply this patch, use:
curl http://cr.i3wm.org/patch/465/raw.patch | git am

b/i3status.c

18
@@ -677,7 +677,12 @@ int main(int argc, char *argv[]) {
19
                  * that we start with :00 on every new minute. */
20
                 struct timeval current_timeval;
21
                 gettimeofday(&current_timeval, NULL);
22
-                struct timespec ts = {interval - 1 - (current_timeval.tv_sec % interval), (10e5 - current_timeval.tv_usec) * 1000};
23
+                /* how many seconds until the next full minute? */
24
+                int gap = 60 - (current_timeval.tv_sec % 60);
25
+                struct timespec ts = {
26
+                        interval - 1 - (interval >= gap ? current_timeval.tv_sec % interval : 0),
27
+                        (10e5 - current_timeval.tv_usec) * 1000
28
+                };
29
                 nanosleep(&ts, NULL);
30
         }
31
 }