Xinqi Bao's Git
projects
/
slstatus.git
/ diff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
aa86547
)
Add option to output only once and exit
author
Aaron Marcher <
[email protected]
>
Mon, 21 May 2018 12:07:41 +0000
(14:07 +0200)
committer
Aaron Marcher <
[email protected]
>
Mon, 21 May 2018 12:07:41 +0000
(14:07 +0200)
slstatus.1
diff
|
blob
|
history
slstatus.c
diff
|
blob
|
history
diff --git
a/slstatus.1
b/slstatus.1
index
da1a99a
..
9517fab
100644
(file)
--- a/
slstatus.1
+++ b/
slstatus.1
@@
-6,7
+6,7
@@
.Nd suckless status monitor
.Sh SYNOPSIS
.Nm
.Nd suckless status monitor
.Sh SYNOPSIS
.Nm
-.Op Fl s
+.Op Fl s
o
.Sh DESCRIPTION
.Nm
is a suckless status monitor for window managers that use WM_NAME (e.g. dwm) or
.Sh DESCRIPTION
.Nm
is a suckless status monitor for window managers that use WM_NAME (e.g. dwm) or
@@
-18,6
+18,8
@@
outputs to WM_NAME.
.Bl -tag -width Ds
.It Fl s
Write to stdout instead of WM_NAME.
.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
.El
.Sh CUSTOMIZATION
.Nm
diff --git
a/slstatus.c
b/slstatus.c
index
3222b02
..
b3abafb
100644
(file)
--- a/
slstatus.c
+++ b/
slstatus.c
@@
-42,7
+42,7
@@
difftimespec(struct timespec *res, struct timespec *a, struct timespec *b)
static void
usage(void)
{
static void
usage(void)
{
- die("usage: %s [-s]", argv0);
+ die("usage: %s [-s
o
]", argv0);
}
int
}
int
@@
-51,15
+51,18
@@
main(int argc, char *argv[])
struct sigaction act;
struct timespec start, current, diff, intspec, wait;
size_t i, len;
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;
char status[MAXLEN];
const char *res;
- sflag = 0;
+ sflag =
oflag =
0;
ARGBEGIN {
case 's':
sflag = 1;
break;
ARGBEGIN {
case 's':
sflag = 1;
break;
+ case 'o':
+ oflag = 1;
+ break;
default:
usage();
} ARGEND
default:
usage();
} ARGEND
@@
-107,6
+110,10
@@
main(int argc, char *argv[])
XFlush(dpy);
}
XFlush(dpy);
}
+ if (oflag) {
+ done = 1;
+ }
+
if (!done) {
if (clock_gettime(CLOCK_MONOTONIC, ¤t) < 0) {
die("clock_gettime:");
if (!done) {
if (clock_gettime(CLOCK_MONOTONIC, ¤t) < 0) {
die("clock_gettime:");