Unified · Split
| @@ -13,7 +13,7 @@ enum { · 12 unmodified lines | ||
| 13 | 13 | Off = 3, |
| 14 | 14 | }; |
| 15 | 15 | |
| 16 | −static int wctl, owidth, width, twidth, bottom, bat, minheight, seplen, sepw, hlitem; | |
| 16 | +static int wctl = -1, owidth, width, twidth, bottom, bat, minheight, seplen, sepw, hlitem; | |
| 17 | 17 | static char sep[16], bats[16], *aux; |
| 18 | 18 | static char *pos = "rb", *dfmt = "YYYY/MM/DD WW hh:mm:ss", *items[64]; |
| 19 | 19 | static int itemw[64], nitems; |
| @@ -68,6 +68,9 @@ place(void) · 48 unmodified lines | ||
| 68 | 68 | char t[64]; |
| 69 | 69 | static int ow, oh; |
| 70 | 70 | |
| 71 | + if(wctl < 0 && (wctl = open("/dev/wctl", OWRITE)) < 0) | |
| 72 | + return; | |
| 73 | + | |
| 71 | 74 | fprint(wctl, bottom ? "bottom" : "top"); |
| 72 | 75 | w = Dx(display->image->r); |
| 73 | 76 | h = Dy(display->image->r); |
| @@ -298,8 +301,6 @@ threadmain(int argc, char **argv) · 224 unmodified lines | ||
| 298 | 301 | Bterm(b); |
| 299 | 302 | } |
| 300 | 303 | |
| 301 | − if((wctl = open("/dev/wctl", ORDWR)) < 0) | |
| 302 | − sysfatal("%r"); | |
| 303 | 304 | bat = open("/mnt/pm/battery", OREAD); |
| 304 | 305 | if(initdraw(nil, nil, "bar") < 0) |
| 305 | 306 | sysfatal("initdraw: %r"); |