@@ 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");