X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=bar.c;h=1f125122695214639acb1dfcaf171d681496926b;hb=896f08d7d553f7def3877648c113cf03e6ca546a;hp=17db8cdba0340119cbeedc371ce817528da1aa54;hpb=586f66331d1105be03c42e6faeae1672b974a98a;p=dwm.git diff --git a/bar.c b/bar.c index 17db8cd..1f12512 100644 --- a/bar.c +++ b/bar.c @@ -5,22 +5,24 @@ #include "wm.h" -static const char *status[] = { - "sh", "-c", "echo -n `date` `uptime | sed 's/.*://; s/,//g'`" - " `acpi | awk '{print $4}' | sed 's/,//'`", 0 \ -}; - void draw_bar() { - static char buf[1024]; - - buf[0] = 0; - pipe_spawn(buf, sizeof(buf), dpy, (char **)status); - brush.rect = barrect; brush.rect.x = brush.rect.y = 0; - draw(dpy, &brush, False, buf); + draw(dpy, &brush, False, NULL); + + if(stack) { + brush.rect.width = textwidth(&brush.font, stack->name) + labelheight(&brush.font); + swap((void **)&brush.fg, (void **)&brush.bg); + draw(dpy, &brush, True, stack->name); + swap((void **)&brush.fg, (void **)&brush.bg); + brush.rect.x += brush.rect.width; + } + + brush.rect.width = textwidth(&brush.font, statustext) + labelheight(&brush.font); + brush.rect.x = barrect.x + barrect.width - brush.rect.width; + draw(dpy, &brush, False, statustext); XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, barrect.width, barrect.height, 0, 0);