all repos — slstatus @ 870d68d44e33f9fb7a5402becbc0b5c363066bcc

my build of slstatus (tools.suckless.org/slstatus/)

added option to output only once and exit afterwards
Aaron Marcher info@nulltime.net
Thu, 11 May 2017 19:06:45 +0200
commit

870d68d44e33f9fb7a5402becbc0b5c363066bcc

parent

ac1a57ec30e8729166b6b890a0f33256218d1ef6

2 files changed, 16 insertions(+), 7 deletions(-)

jump to
M slstatus.1slstatus.1

@@ -15,7 +15,10 @@ .B \-h

display help .TP .B \-o -output to console instead of WM_NAME +output continuously to console instead of WM_NAME +.TP +.B \-n +output to console once and exit .TP .B \-v display version and copyright details
M slstatus.cslstatus.c

@@ -71,7 +71,7 @@

char *argv0; static unsigned short int delay = 0; static unsigned short int done; -static unsigned short int dflag, oflag; +static unsigned short int dflag, oflag, nflag; static Display *dpy; #include "config.h"

@@ -775,7 +775,7 @@

static void usage(const int eval) { - fprintf(stderr, "usage: %s [-d] [-o] [-v] [-h]\n", argv0); + fprintf(stderr, "usage: %s [-d] [-o] [-n] [-v] [-h]\n", argv0); exit(eval); }

@@ -795,6 +795,9 @@ break;

case 'o': oflag = 1; break; + case 'n': + nflag = 1; + break; case 'v': printf("slstatus (C) 2016-2017 slstatus engineers\n"); return 0;

@@ -804,7 +807,7 @@ default:

usage(1); } ARGEND - if (dflag && oflag) { + if ((dflag && oflag) || (dflag && nflag) || (oflag && nflag)) { usage(1); } if (dflag && daemon(1, 1) < 0) {

@@ -842,11 +845,14 @@ free(res);

free(element); } - if (!oflag) { + if (oflag) { + printf("%s\n", status_string); + } else if (nflag) { + printf("%s\n", status_string); + done = 1; + } else { XStoreName(dpy, DefaultRootWindow(dpy), status_string); XSync(dpy, False); - } else { - printf("%s\n", status_string); } if ((UPDATE_INTERVAL - delay) <= 0) {