Add option to output only once and exit
This commit is contained in:
parent
aa8654795d
commit
fa8b939990
@ -6,7 +6,7 @@
|
|||||||
.Nd suckless status monitor
|
.Nd suckless status monitor
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl s
|
.Op Fl so
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
is a suckless status monitor for window managers that use WM_NAME (e.g. dwm) or
|
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
|
.Bl -tag -width Ds
|
||||||
.It Fl s
|
.It Fl s
|
||||||
Write to stdout instead of WM_NAME.
|
Write to stdout instead of WM_NAME.
|
||||||
|
.It Fl o
|
||||||
|
Write only once and exit.
|
||||||
.El
|
.El
|
||||||
.Sh CUSTOMIZATION
|
.Sh CUSTOMIZATION
|
||||||
.Nm
|
.Nm
|
||||||
|
13
slstatus.c
13
slstatus.c
@ -42,7 +42,7 @@ difftimespec(struct timespec *res, struct timespec *a, struct timespec *b)
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
die("usage: %s [-s]", argv0);
|
die("usage: %s [-so]", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -51,15 +51,18 @@ main(int argc, char *argv[])
|
|||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
struct timespec start, current, diff, intspec, wait;
|
struct timespec start, current, diff, intspec, wait;
|
||||||
size_t i, len;
|
size_t i, len;
|
||||||
int sflag, ret;
|
int sflag, oflag, ret;
|
||||||
char status[MAXLEN];
|
char status[MAXLEN];
|
||||||
const char *res;
|
const char *res;
|
||||||
|
|
||||||
sflag = 0;
|
sflag = oflag = 0;
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 's':
|
case 's':
|
||||||
sflag = 1;
|
sflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
oflag = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
} ARGEND
|
} ARGEND
|
||||||
@ -107,6 +110,10 @@ main(int argc, char *argv[])
|
|||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oflag) {
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, ¤t) < 0) {
|
if (clock_gettime(CLOCK_MONOTONIC, ¤t) < 0) {
|
||||||
die("clock_gettime:");
|
die("clock_gettime:");
|
||||||
|
Loading…
Reference in New Issue
Block a user