summaryrefslogtreecommitdiff
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
parentd1b23e5509863fd0790261b2b388e687d5218d53 (diff)
downloadslstatus-aaf279f6ddfb48146fc1a579efd83a55722910b5.tar.gz
slstatus-aaf279f6ddfb48146fc1a579efd83a55722910b5.zip
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)
-rw-r--r--slstatus.15
-rw-r--r--slstatus.c9
2 files changed, 10 insertions, 4 deletions
diff --git a/slstatus.1 b/slstatus.1
index da1a99a..d802037 100644
--- a/slstatus.1
+++ b/slstatus.1
@@ -1,4 +1,4 @@
1.Dd 2017-08-10 1.Dd 2020-06-23
2.Dt SLSTATUS 1 2.Dt SLSTATUS 1
3.Os 3.Os
4.Sh NAME 4.Sh NAME
@@ -7,6 +7,7 @@
7.Sh SYNOPSIS 7.Sh SYNOPSIS
8.Nm 8.Nm
9.Op Fl s 9.Op Fl s
10.Op Fl 1
10.Sh DESCRIPTION 11.Sh DESCRIPTION
11.Nm 12.Nm
12is a suckless status monitor for window managers that use WM_NAME (e.g. dwm) or 13is a suckless status monitor for window managers that use WM_NAME (e.g. dwm) or
@@ -18,6 +19,8 @@ outputs to WM_NAME.
18.Bl -tag -width Ds 19.Bl -tag -width Ds
19.It Fl s 20.It Fl s
20Write to stdout instead of WM_NAME. 21Write to stdout instead of WM_NAME.
22.It Fl 1
23Write once to stdout and quit.
21.El 24.El
22.Sh CUSTOMIZATION 25.Sh CUSTOMIZATION
23.Nm 26.Nm
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)
41static void 41static void
42usage(void) 42usage(void)
43{ 43{
44 die("usage: %s [-s]", argv0); 44 die("usage: %s [-s] [-1]", argv0);
45} 45}
46 46
47int 47int
@@ -56,6 +56,9 @@ main(int argc, char *argv[])
56 56
57 sflag = 0; 57 sflag = 0;
58 ARGBEGIN { 58 ARGBEGIN {
59 case '1':
60 done = 1;
61 /* fallthrough */
59 case 's': 62 case 's':
60 sflag = 1; 63 sflag = 1;
61 break; 64 break;
@@ -78,7 +81,7 @@ main(int argc, char *argv[])
78 die("XOpenDisplay: Failed to open display"); 81 die("XOpenDisplay: Failed to open display");
79 } 82 }
80 83
81 while (!done) { 84 do {
82 if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) { 85 if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) {
83 die("clock_gettime:"); 86 die("clock_gettime:");
84 } 87 }
@@ -125,7 +128,7 @@ main(int argc, char *argv[])
125 } 128 }
126 } 129 }
127 } 130 }
128 } 131 } while (!done);
129 132
130 if (!sflag) { 133 if (!sflag) {
131 XStoreName(dpy, DefaultRootWindow(dpy), NULL); 134 XStoreName(dpy, DefaultRootWindow(dpy), NULL);