wmbattery: Add -n option to disable dial graphic.

Thanks to Christoph Fritz for the feature request.
This commit is contained in:
Doug Torrance 2015-05-13 23:38:54 -05:00 committed by Carlos R. Mafra
parent 0b45f308ad
commit 81e95eabca
3 changed files with 61 additions and 2 deletions

46
wmbattery/mask_nodial.xbm Normal file
View file

@ -0,0 +1,46 @@
#define mask_nodial_width 64
#define mask_nodial_height 64
static char mask_nodial_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff,
0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff,
0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff,
0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff,
0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff,
0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

View file

@ -111,6 +111,9 @@ translated into the appropriate values.
.TP
.B \-i
Display as icon.
.TP
.B \-n
Disable dial graphic.
.SH EXAMPLE
Start at 10% battery to execute 'echo' including status information:
.RS

View file

@ -40,6 +40,7 @@
#endif
#include "mask.xbm"
#include "mask_nodial.xbm"
#include "sonypi.h"
#include "acpi.h"
#ifdef HAL
@ -83,6 +84,7 @@ int delay = 0;
int always_estimate_remaining = 0;
int granularity_estimate_remaining = 1;
int initial_state = WithdrawnState;
int use_dial = 1;
signed int low_pct = -1;
signed int critical_pct = -1;
@ -378,7 +380,7 @@ char *parse_commandline(int argc, char *argv[])
char *ret = NULL;
while (c != -1) {
c = getopt(argc, argv, "hd:g:if:b:w:c:l:es:a:x:v");
c = getopt(argc, argv, "hd:g:if:b:w:c:l:es:a:x:vn");
switch (c) {
case 'h':
printf("Usage: wmbattery [options]\n");
@ -394,6 +396,7 @@ char *parse_commandline(int argc, char *argv[])
printf("\t-s granularity\tignore fluctuations less than granularity%% (implies -e)\n");
printf("\t-a file\t\twhen critical send file to /dev/audio\n");
printf("\t-x command\twhen critical execute this command\n");
printf("\t-n\t\tdisable dial graphic\n");
printf("\t-v\t\tdisplay version number\n");
exit(0);
break;
@ -435,6 +438,9 @@ char *parse_commandline(int argc, char *argv[])
printf("wmbattery "PACKAGE_VERSION"\n");
exit(0);
break;
case 'n':
use_dial = 0;
break;
}
}
@ -500,8 +506,12 @@ void make_window(char *display_name, int argc, char *argv[])
GCForeground | GCBackground | GCGraphicsExposures,
&gcv);
pixmask = XCreateBitmapFromData(display, win, mask_bits,
if (use_dial)
pixmask = XCreateBitmapFromData(display, win, mask_bits,
mask_width, mask_height);
else
pixmask = XCreateBitmapFromData(display, win, mask_nodial_bits,
mask_nodial_width, mask_nodial_height);
XShapeCombineMask(display, win, ShapeBounding, 0, 0,
pixmask, ShapeSet);
XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0,