Add option to output only once and exit
Aaron Marcher me@drkhsh.at
Mon, 21 May 2018 14:07:41 +0200
2 files changed,
13 insertions(+),
4 deletions(-)
M
slstatus.1
→
slstatus.1
@@ -6,7 +6,7 @@ .Nm slstatus
.Nd suckless status monitor .Sh SYNOPSIS .Nm -.Op Fl s +.Op Fl so .Sh DESCRIPTION .Nm is a suckless status monitor for window managers that use WM_NAME (e.g. dwm) or@@ -18,6 +18,8 @@ .Sh OPTIONS
.Bl -tag -width Ds .It Fl s Write to stdout instead of WM_NAME. +.It Fl o +Write only once and exit. .El .Sh CUSTOMIZATION .Nm
M
slstatus.c
→
slstatus.c
@@ -42,7 +42,7 @@
static void usage(void) { - die("usage: %s [-s]", argv0); + die("usage: %s [-so]", argv0); } int@@ -51,14 +51,17 @@ {
struct sigaction act; struct timespec start, current, diff, intspec, wait; size_t i, len; - int sflag, ret; + int sflag, oflag, ret; char status[MAXLEN]; const char *res; - sflag = 0; + sflag = oflag = 0; ARGBEGIN { case 's': sflag = 1; + break; + case 'o': + oflag = 1; break; default: usage();@@ -105,6 +108,10 @@ if (XStoreName(dpy, DefaultRootWindow(dpy), status) < 0) {
die("XStoreName: Allocation failed"); } XFlush(dpy); + } + + if (oflag) { + done = 1; } if (!done) {