status

statusbar program for dwm
git clone anongit@rnpnr.xyz:status.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 27a1a9cae9a442439218de82504fd0e00132a230
Parent: db56d3ba6b063539f862c5de941db66820e5a864
Author: Randy Palamar
Date:   Sun, 15 Oct 2023 00:34:57 -0600

move initialization to single function

Diffstat:
Mstatus.c | 28++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/status.c b/status.c @@ -65,7 +65,7 @@ updatestatus(void) } XStoreName(dpy, DefaultRootWindow(dpy), status); - XSync(dpy, False); + XSync(dpy, False); } static void @@ -120,22 +120,34 @@ setupsigs(void) for (b = blks; b->fn; b++) if (b->signal > 0) sigaction(SIGRTMIN + b->signal, &sa, NULL); + + /* start with signals blocked */ + sigprocmask(SIG_BLOCK, &blocksigmask, NULL); } static void -statusloop(void) +statusinit(void) { - unsigned int i; struct Block *b; - struct timespec t; - sigprocmask(SIG_BLOCK, &blocksigmask, NULL); + setupsigs(); + + if (!dflag && !(dpy = XOpenDisplay(NULL))) + die("XOpenDisplay: can't open display\n"); /* initialize blocks before first print */ for (b = blks; b->fn; b++) if (b->interval != -1) updateblock(b); updatestatus(); +} + +static void +statusloop(void) +{ + unsigned int i; + struct Block *b; + struct timespec t; for (i = 1; ; i++) { sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL); @@ -175,11 +187,7 @@ main(int argc, char *argv[]) } } - setupsigs(); - - if (!dflag && !(dpy = XOpenDisplay(NULL))) - die("XOpenDisplay: can't open display\n"); - + statusinit(); statusloop(); return 0;