On Mon, Jun 20, 2011 at 12:17:58PM +0200, Stefan Mark wrote: > On 20.06.2011 11:59, ilf wrote: > > On 06-19 22:55, Erik Hahn wrote: > >> http://dwm.suckless.org/scripts/simple_monitors > > > > I have done this the /proc/acpi/battery/BAT0/state | shell way for years > > and found it to be way more resource intense then calling acpi -b. > > > > Let's face it, the Shell/Perl/Python/whatever scripting is relatively > > easy, but very inefficient. > >
This program allows me to put 'whatever I can create on stdout' to the statusbar #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include <stdlib.h> #include <stdio.h> #include <X11/Xlib.h> int main (int argc, char *argv[]) { int ret; Display *dpy; Window root; const char *display; char *line = 0; size_t size = 0; /* open display */ display = getenv("DISPLAY") ?: ":0"; dpy = XOpenDisplay(display); if (!dpy) { fprintf(stderr, "Unable to open display '%s'\n", display); exit(1); } root = RootWindow(dpy, DefaultScreen(dpy)); while (1) { ret = getline(&line, &size, stdin); if (ret < 0) break; XStoreName(dpy, root, line); XSync(dpy, False); } return 0; }