Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Reduce -o | -n to -s
[slstatus.git]
/
slstatus.c
diff --git
a/slstatus.c
b/slstatus.c
index
9a4831d
..
4b6770b
100644
(file)
--- a/
slstatus.c
+++ b/
slstatus.c
@@
-75,7
+75,6
@@
static void usage(void);
char *argv0;
static unsigned short int delay = 0;
static unsigned short int done;
char *argv0;
static unsigned short int delay = 0;
static unsigned short int done;
-static unsigned short int dflag, oflag, nflag;
static Display *dpy;
#include "config.h"
static Display *dpy;
#include "config.h"
@@
-840,50
+839,34
@@
sighandler(const int signo)
static void
usage(void)
{
static void
usage(void)
{
- fprintf(stderr, "usage: %s [-
d] [-o] [-n] [-v] [-h
]\n", argv0);
+ fprintf(stderr, "usage: %s [-
s
]\n", argv0);
exit(1);
}
int
main(int argc, char *argv[])
{
exit(1);
}
int
main(int argc, char *argv[])
{
- unsigned short int i;
- char status_string[MAXLEN];
- char *element;
struct arg argument;
struct sigaction act;
struct arg argument;
struct sigaction act;
- size_t len;
+ size_t i, len;
+ int sflag = 0;
+ char status_string[MAXLEN];
+ char *element;
ARGBEGIN {
ARGBEGIN {
- case 'd':
- dflag = 1;
- break;
- case 'o':
- oflag = 1;
+ case 's':
+ sflag = 1;
break;
break;
- case 'n':
- nflag = 1;
- break;
- case 'v':
- printf("slstatus-"VERSION"\n");
- return 0;
default:
usage();
} ARGEND
default:
usage();
} ARGEND
- if ((dflag && oflag) || (dflag && nflag) || (oflag && nflag)) {
- usage();
- }
- if (dflag && daemon(1, 1) < 0) {
- err(1, "daemon");
- }
-
memset(&act, 0, sizeof(act));
act.sa_handler = sighandler;
sigaction(SIGINT, &act, 0);
sigaction(SIGTERM, &act, 0);
memset(&act, 0, sizeof(act));
act.sa_handler = sighandler;
sigaction(SIGINT, &act, 0);
sigaction(SIGTERM, &act, 0);
- if (!
o
flag) {
+ if (!
s
flag) {
dpy = XOpenDisplay(NULL);
}
dpy = XOpenDisplay(NULL);
}
@@
-905,11
+888,8
@@
main(int argc, char *argv[])
}
}
}
}
- if (oflag) {
- printf("%s\n", status_string);
- } else if (nflag) {
+ if (sflag) {
printf("%s\n", status_string);
printf("%s\n", status_string);
- done = 1;
} else {
XStoreName(dpy, DefaultRootWindow(dpy), status_string);
XSync(dpy, False);
} else {
XStoreName(dpy, DefaultRootWindow(dpy), status_string);
XSync(dpy, False);
@@
-924,7
+904,7
@@
main(int argc, char *argv[])
}
}
}
}
- if (!
o
flag) {
+ if (!
s
flag) {
XStoreName(dpy, DefaultRootWindow(dpy), NULL);
XCloseDisplay(dpy);
}
XStoreName(dpy, DefaultRootWindow(dpy), NULL);
XCloseDisplay(dpy);
}