From what I understand watcher just gives the output of a division between the current bat state and the full one.
The OLPC XO does not have that, but outputs directly the percent full as a 2 digit number.
So I pointed "batnow" to this file, commented out the "batfull" bit and I set the "batmsg" to read "batnow" directly.
so lines 24 to 49 look like that
float timeout=1.5,mem=0,swap=0,cpu=0,used=0,oldused=0,cputotal=0,oldcputotal=0;
float batnow=0; //batfull=0;
int arg_i=0, fontsize=10, mib=0, showswap=1;
char memind[2]="m", swapind[2]="m", batname[6]="", longpath[PATH_MAX]="", batmsg[10]="";
FILE *meminfo,*cpuinfo,*batinfo;
void batcheckup(){
sprintf(longpath,"/sys/class/power_supply/%s/capacity",batname);
if((batinfo=fopen(longpath,"r"))==NULL) {
fprintf(stderr,"Error opening batinfo %s\n",longpath);
exit(1);
}
fscanf(batinfo,"%f",&batnow);
fclose(batinfo);
/* sprintf(longpath,"/sys/class/power_supply/%s/capacity",batname);
if((batinfo=fopen(longpath,"r"))==NULL) {
fprintf(stderr,"Error opening batinfo %s\n",longpath);
exit(1);
}
fscanf(batinfo,"%f",&batfull);
fclose(batinfo);
*/
sprintf(batmsg," %.1f%%B",(float)(batnow));
}
Complies and runs fine but as soon as I rum with the -bat option I get segfault.
Tried with different versions of the sprintf, same segfault every time.

Any idea
