summaryrefslogtreecommitdiff
path: root/slstatus.c
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 /slstatus.c
parent3fc2872d1b3e62903a4af49326d42c97c11911d5 (diff)
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
Diffstat (limited to 'slstatus.c')
-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 {
};
char buf[1024];
-static int done;
+static volatile sig_atomic_t done;
static Display *dpy;
#include "config.h"
@@ -26,9 +26,8 @@ static Display *dpy;
static void
terminate(const int signo)
{
- (void)signo;
-
- done = 1;
+ if (signo != SIGUSR1)
+ done = 1;
}
static void
@@ -72,6 +71,8 @@ main(int argc, char *argv[])
act.sa_handler = terminate;
sigaction(SIGINT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
+ act.sa_flags |= SA_RESTART;
+ sigaction(SIGUSR1, &act, NULL);
if (!sflag && !(dpy = XOpenDisplay(NULL))) {
die("XOpenDisplay: Failed to open display");