xbattmon

simple battery monitor for X
git clone git://git.2f30.org/xbattmon
Log | Files | Refs | README | LICENSE

commit d7ee2967d11f673af4d45ac8edaf2a5f4e690d44
parent 9771821db659cba749eeeaa16bce2ccdf311fee6
Author: sin <sin@2f30.org>
Date:   Sun,  9 Nov 2014 17:39:25 +0000

Prepare ground for left/right placement

Diffstat:
Mconfig.def.h | 2+-
Mxbattmon.c | 16++++++++++++----
2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -7,6 +7,6 @@ char *colors[] = { unsigned int thickness = 2; /* 2 pixels by default */ time_t pollinterval = 5; /* poll battery state every 5 seconds */ -int bottom = 1; /* set to 0 if you want the bar to be at the top */ +int placement = BOTTOM; /* set to TOP if you want a top placement */ int maxcap = 100; /* maximum battery capacity */ int raise = 0; /* set to 1 if you want the bar to be raised on top of other windows */ diff --git a/xbattmon.c b/xbattmon.c @@ -24,6 +24,11 @@ enum { COLOR_BAT_LEFT2DRAIN }; +enum { + BOTTOM, + TOP +}; + char *argv0; Display *dpy; Window winbar; @@ -60,16 +65,19 @@ setup(void) if (thickness > height) thickness = height; - if (bottom == 1) { + switch (placement) { + case BOTTOM: barx = 0; bary = height - thickness; barwidth = width; barheight = thickness; - } else { + break; + case TOP: barx = 0; bary = 0; barwidth = width; barheight = thickness; + break; } winbar = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), barx, bary, barwidth, @@ -257,9 +265,9 @@ main(int argc, char *argv[]) case 'p': arg = EARGF(usage()); if (strcmp(arg, "bottom") == 0) - bottom = 1; + placement = BOTTOM; else if (strcmp(arg, "top") == 0) - bottom = 0; + placement = TOP; else errx(1, "%s: invalid placement", arg); break;