Commit Diff


commit - f80a5ceaf03e13c98e13cc9091cb44c854f8e7ef
commit + 0386ec3071e4e205bd9cfb7730d7bdc27f0f0637
blob - 489a70b8b32e25fe9908b0b052709cc59c8d923e
blob + 40316dcbe9d1831f6f7fed1bcef42d972c6d806b
--- modules/clock.c
+++ modules/clock.c
@@ -6,6 +6,7 @@
 #include "statbar.h"
 
 static volatile sig_atomic_t should_quit = 0;
+static volatile sig_atomic_t renormalize = 0;
 
 static void
 get_clock(char *clock_string)
@@ -45,6 +46,7 @@ static void
 signal_handler(int sig)
 {
 	if (sig == SIGTERM || sig == SIGINT) should_quit = 1;
+	if (sig == SIGUSR1) renormalize = 1;
 }
 
 pid_t
@@ -78,6 +80,7 @@ start_clock_process(int *pipe_fd)
 
 	(void)signal(SIGTERM, signal_handler);
 	(void)signal(SIGINT, signal_handler);
+	(void)signal(SIGUSR1, signal_handler);
 
 	if (pledge("stdio", NULL) == -1)
 	{
@@ -92,6 +95,11 @@ start_clock_process(int *pipe_fd)
 
 	while (!should_quit)
 	{
+		if (renormalize)
+		{
+			normalize_clock_interval(&interval);
+			renormalize = 0;
+		}
 		get_clock(clock_string);
 		(void)dprintf(clock_pipe[1], "%s", clock_string);
 
blob - 1c476b749e34fa40cc14b6ce98c928709ddd30dc
blob + 2ff440e2976c78a1329a3bd7ee7accf034a7dbd6
--- src/main.c
+++ src/main.c
@@ -16,6 +16,7 @@
 #define NFDS 6
 
 static volatile sig_atomic_t should_quit = 0;
+static int renormalize_clock = 0;
 static int reload_mail = 0;
 static int reload_battery = 0;
 
@@ -157,6 +158,10 @@ main(void)
 				(void)printf("Got command 0x%02x: ", cmd);
 				switch (cmd)
 				{
+					case 0x02:
+						(void)puts("renormalizing clock interval");
+						renormalize_clock = 1;
+						break;
 					case 0x03:
 						(void)puts("reloading mail");
 						reload_mail = 1;
@@ -196,6 +201,12 @@ main(void)
 			dirty = true;
 		}
 
+		if (renormalize_clock)
+		{
+			renormalize_clock = 0;
+			(void)kill(clock_pid, SIGUSR1);
+		}
+
 		/* Mail */
 		if (reload_mail)
 		{
blob - 3fc672918f869da97a24e6eabb090b7717276205
blob + f64ff47fe646de6cf7a6045074b6148182c3b1bb
--- statbarctl.sh
+++ statbarctl.sh
@@ -24,6 +24,7 @@ if [ -z "$1" ]; then
 fi
 
 case "$1" in
+	renormalize-clock) CMDBYTE="\x02" ;;
 	reload-mail) CMDBYTE="\x03" ;;
 	reload-battery) CMDBYTE="\x04" ;;
 	help)