mirror of
https://github.com/pikami/slstatus.git
synced 2024-11-27 13:55:41 +00:00
Reduce -o | -n to -s
What we really want is to either output to WM_NAME or stdout. If we want just one single line, we do slstatus | head -n 1.
This commit is contained in:
parent
4d33c36014
commit
c9d47405f4
@ -6,7 +6,7 @@
|
|||||||
.Nd suckless status monitor
|
.Nd suckless status monitor
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl o | n
|
.Op Fl s
|
||||||
.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
|
||||||
@ -16,10 +16,8 @@ By default,
|
|||||||
outputs to WM_NAME.
|
outputs to WM_NAME.
|
||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl n
|
.It Fl s
|
||||||
Write to stdout once and exit.
|
Write to stdout instead of WM_NAME.
|
||||||
.It Fl o
|
|
||||||
Write to stdout continuously.
|
|
||||||
.El
|
.El
|
||||||
.Sh CUSTOMIZATION
|
.Sh CUSTOMIZATION
|
||||||
.Nm
|
.Nm
|
||||||
|
31
slstatus.c
31
slstatus.c
@ -75,7 +75,6 @@ static void usage(void);
|
|||||||
char *argv0;
|
char *argv0;
|
||||||
static unsigned short int delay = 0;
|
static unsigned short int delay = 0;
|
||||||
static unsigned short int done;
|
static unsigned short int done;
|
||||||
static unsigned short int oflag, nflag;
|
|
||||||
static Display *dpy;
|
static Display *dpy;
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -840,41 +839,34 @@ sighandler(const int signo)
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: %s [-o | -n]\n", argv0);
|
fprintf(stderr, "usage: %s [-s]\n", argv0);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
unsigned short int i;
|
|
||||||
char status_string[MAXLEN];
|
|
||||||
char *element;
|
|
||||||
struct arg argument;
|
struct arg argument;
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
size_t len;
|
size_t i, len;
|
||||||
|
int sflag = 0;
|
||||||
|
char status_string[MAXLEN];
|
||||||
|
char *element;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'o':
|
case 's':
|
||||||
oflag = 1;
|
sflag = 1;
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
nflag = 1;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
} ARGEND
|
} ARGEND
|
||||||
|
|
||||||
if (oflag && nflag) {
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&act, 0, sizeof(act));
|
memset(&act, 0, sizeof(act));
|
||||||
act.sa_handler = sighandler;
|
act.sa_handler = sighandler;
|
||||||
sigaction(SIGINT, &act, 0);
|
sigaction(SIGINT, &act, 0);
|
||||||
sigaction(SIGTERM, &act, 0);
|
sigaction(SIGTERM, &act, 0);
|
||||||
|
|
||||||
if (!oflag) {
|
if (!sflag) {
|
||||||
dpy = XOpenDisplay(NULL);
|
dpy = XOpenDisplay(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,11 +888,8 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oflag) {
|
if (sflag) {
|
||||||
printf("%s\n", status_string);
|
printf("%s\n", status_string);
|
||||||
} else if (nflag) {
|
|
||||||
printf("%s\n", status_string);
|
|
||||||
done = 1;
|
|
||||||
} else {
|
} else {
|
||||||
XStoreName(dpy, DefaultRootWindow(dpy), status_string);
|
XStoreName(dpy, DefaultRootWindow(dpy), status_string);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@ -915,7 +904,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oflag) {
|
if (!sflag) {
|
||||||
XStoreName(dpy, DefaultRootWindow(dpy), NULL);
|
XStoreName(dpy, DefaultRootWindow(dpy), NULL);
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user