~ft/bar

595e1948331d24bb2ff576f47b744f938d2d7021 — Sigrid Solveig Haflínudóttir 2 years ago a45b2a4
race condition (wctl access) with riow - don't fail if wctl fails to open
1 files changed, 4 insertions(+), 3 deletions(-)

M bar.c
M bar.c => bar.c +4 -3
@@ 13,7 13,7 @@ enum {
	Off = 3,
};

static int wctl, owidth, width, twidth, bottom, bat, minheight, seplen, sepw, hlitem;
static int wctl = -1, owidth, width, twidth, bottom, bat, minheight, seplen, sepw, hlitem;
static char sep[16], bats[16], *aux;
static char *pos = "rb", *dfmt = "YYYY/MM/DD WW hh:mm:ss", *items[64];
static int itemw[64], nitems;


@@ 68,6 68,9 @@ place(void)
	char t[64];
	static int ow, oh;

	if(wctl < 0 && (wctl = open("/dev/wctl", OWRITE)) < 0)
		return;

	fprint(wctl, bottom ? "bottom" : "top");
	w = Dx(display->image->r);
	h = Dy(display->image->r);


@@ 298,8 301,6 @@ threadmain(int argc, char **argv)
		Bterm(b);
	}

	if((wctl = open("/dev/wctl", ORDWR)) < 0)
		sysfatal("%r");
	bat = open("/mnt/pm/battery", OREAD);
	if(initdraw(nil, nil, "bar") < 0)
		sysfatal("initdraw: %r");