diff options
author | Aaron Marcher <me@drkhsh.at> | 2018-05-21 14:07:41 +0200 |
---|---|---|
committer | Aaron Marcher <me@drkhsh.at> | 2018-05-21 14:07:41 +0200 |
commit | fa8b939990ed0648f99b0cbeba4efed807160db3 (patch) | |
tree | 11faa55b84bbc20e72a0aac91641348cd40b9806 /slstatus.c | |
parent | aa8654795da19a8d517faf1b84cd4dc4ac75f6e7 (diff) | |
download | slstatus-fa8b939990ed0648f99b0cbeba4efed807160db3.tar.gz |
Add option to output only once and exit
Diffstat (limited to 'slstatus.c')
-rw-r--r-- | slstatus.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -42,7 +42,7 @@ difftimespec(struct timespec *res, struct timespec *a, struct timespec *b) static void usage(void) { - die("usage: %s [-s]", argv0); + die("usage: %s [-so]", argv0); } int @@ -51,15 +51,18 @@ main(int argc, char *argv[]) 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(); } ARGEND @@ -107,6 +110,10 @@ main(int argc, char *argv[]) XFlush(dpy); } + if (oflag) { + done = 1; + } + if (!done) { if (clock_gettime(CLOCK_MONOTONIC, ¤t) < 0) { die("clock_gettime:"); |