summaryrefslogtreecommitdiff
path: root/slstatus.c
diff options
context:
space:
mode:
authorDaniel Moch <daniel@danielmoch.com>2020-06-23 16:35:43 -0400
committerAaron Marcher <me@drkhsh.at>2020-11-30 21:23:56 +0100
commitaaf279f6ddfb48146fc1a579efd83a55722910b5 (patch)
treea6dd7a1eb4bada70f67f52a9c58903de7d28171c /slstatus.c
parentd1b23e5509863fd0790261b2b388e687d5218d53 (diff)
Add a -1 option flag
Allow slstatus to be used by programs that can grab status by calling an external program on a periodic basis (e.g. tmux)
Diffstat (limited to 'slstatus.c')
-rw-r--r--slstatus.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/slstatus.c b/slstatus.c
index 0806773..64da5cb 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -41,7 +41,7 @@ difftimespec(struct timespec *res, struct timespec *a, struct timespec *b)
static void
usage(void)
{
- die("usage: %s [-s]", argv0);
+ die("usage: %s [-s] [-1]", argv0);
}
int
@@ -56,6 +56,9 @@ main(int argc, char *argv[])
sflag = 0;
ARGBEGIN {
+ case '1':
+ done = 1;
+ /* fallthrough */
case 's':
sflag = 1;
break;
@@ -78,7 +81,7 @@ main(int argc, char *argv[])
die("XOpenDisplay: Failed to open display");
}
- while (!done) {
+ do {
if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) {
die("clock_gettime:");
}
@@ -125,7 +128,7 @@ main(int argc, char *argv[])
}
}
}
- }
+ } while (!done);
if (!sflag) {
XStoreName(dpy, DefaultRootWindow(dpy), NULL);