summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMart Lubbers <mart@martlubbers.net>2020-06-18 08:46:12 +0200
committerAaron Marcher <me@drkhsh.at>2020-11-30 21:23:49 +0100
commitd1b23e5509863fd0790261b2b388e687d5218d53 (patch)
treedb5528821556c67988da3491b90b3a8ead684717
parent3fc2872d1b3e62903a4af49326d42c97c11911d5 (diff)
downloadslstatus-d1b23e5509863fd0790261b2b388e687d5218d53.tar.gz
slstatus-d1b23e5509863fd0790261b2b388e687d5218d53.zip
Handle SIGUSR1 for forced refreshes
At some point one might want to force a refresh for example after checking email or changing the volume. Sending a SIGUSR1 achieves this now
-rw-r--r--slstatus.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/slstatus.c b/slstatus.c
index 96fa5b6..0806773 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -18,7 +18,7 @@ struct arg {
18}; 18};
19 19
20char buf[1024]; 20char buf[1024];
21static int done; 21static volatile sig_atomic_t done;
22static Display *dpy; 22static Display *dpy;
23 23
24#include "config.h" 24#include "config.h"
@@ -26,9 +26,8 @@ static Display *dpy;
26static void 26static void
27terminate(const int signo) 27terminate(const int signo)
28{ 28{
29 (void)signo; 29 if (signo != SIGUSR1)
30 30 done = 1;
31 done = 1;
32} 31}
33 32
34static void 33static void
@@ -72,6 +71,8 @@ main(int argc, char *argv[])
72 act.sa_handler = terminate; 71 act.sa_handler = terminate;
73 sigaction(SIGINT, &act, NULL); 72 sigaction(SIGINT, &act, NULL);
74 sigaction(SIGTERM, &act, NULL); 73 sigaction(SIGTERM, &act, NULL);
74 act.sa_flags |= SA_RESTART;
75 sigaction(SIGUSR1, &act, NULL);
75 76
76 if (!sflag && !(dpy = XOpenDisplay(NULL))) { 77 if (!sflag && !(dpy = XOpenDisplay(NULL))) {
77 die("XOpenDisplay: Failed to open display"); 78 die("XOpenDisplay: Failed to open display");