status

statusbar program for dwm
git clone anongit@rnpnr.xyz:status.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 1081f135706c0fc7cb9b5685e44cc235029dfd3a
Parent: f9830d7d45965ff050cf5509c0e1f4eea50a22eb
Author: 0x766F6964
Date:   Fri, 27 Sep 2019 23:38:20 -0600

add -d for printing to stdout

Diffstat:
Mstatus.c | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/status.c b/status.c @@ -1,3 +1,4 @@ +/* See LICENSE for license details. */ #include <signal.h> #include <stdarg.h> #include <stdio.h> @@ -12,6 +13,7 @@ #include "config.h" static int done = 0; +static int dflag = 0; static char buf[1024]; static Display *dpy; @@ -67,6 +69,11 @@ pscanf(const char *path, const char *fmt, ...) static void setstatus(char *str) { + if (dflag) { + puts(str); + return; + } + XStoreName(dpy, DefaultRootWindow(dpy), str); XSync(dpy, False); } @@ -118,7 +125,7 @@ mpd(enum mpd_tag_type type) } int -main(void) +main(int argc, char *argv[]) { struct sigaction sa; const char *s; @@ -130,6 +137,16 @@ main(void) sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); + if (argc > 2) + die("usage: %s [-d]\n", argv[0]); + + for (;argc && *argv; argc--) { + switch ((argv++)[0][1]) { + case 'd': + dflag = 1; + } + } + if (!(dpy = XOpenDisplay(NULL))) die("XOpenDisplay: can't open display\n");