Tiny Core Linux
Tiny Core Extensions => TCE News => TCE 2.x => Topic started by: curaga on September 13, 2009, 12:28:10 PM
-
Title: watcher.tcz
Description: FLTK cpu/ram/swap/battery meter
Version: 1.7
Author: Curaga
Original-site: http://tinycorelinux.com
Copying-policy: GPL
Size: 8K
Extension_by: Curaga
Comments: The latest watcher, now available as an extension. :P
Changes from 1.6:
- battery support
- no borders (looking better on non-swallowing WMs)
-
Use the X standard -g option to position watcher where-ever
wanted. X counts from top-left, so watcher in top-left corner:
watcher -g +0+0
Top-right would be "-0+0", bottom left "+0-0", bottom right
"-0-0".
-
This extension is PPI compatible.
Change-log:
Current: 2009/09/13 Original
Screenshot showing a ton of watchers, all in different options:
(http://preview.shareapic.net/preview6/019261759.png) (http://www.shareapic.net/View-19261759-TC.html)
The "Sun 13" at the bottom is from the JWM tray; my laptop runs JWM, and I wanted to get at least one battery shot in.
-
I'm wondering how watcher gets CPU data, since it's quite different from that shown by Conky and top.
-
ftp://ftp.nluug.nl/pub/metalab/distributions/tinycorelinux/2.x/tce/src/watcher.cxx
:D
-
ftp://ftp.nluug.nl/pub/metalab/distributions/tinycorelinux/2.x/tce/src/watcher.cxx
:D
Tried to recompile for the OLPC XO-1 that has totaly differnt path for battery but even the original gives me a bunch of undefined references (F1_window..., F1:: run ()... etc) and fails
What do I miss?
PS: This is my first attempt to compile...
-
Looks like you don't have FLTK (fltk.org), the gui toolkit.
-
Looks like you don't have FLTK (fltk.org), the gui toolkit.
It makes sense but I assumed that it can be done on TC and I do have fltk2.tcz and fltk-fluid.tcz, along with compiletc.tcz and base-dev.tcz loaded. Anything else I need? Should it be done in another distro?
To be honest since there is no makefile all I tried was "gcc (or c++/g++) -c watcher.cxx" ::) but as I said this IS my first stub at compiling, at least from cxx.
-
Although I am not familar with the watcher code, to link in the fltk support you would typically use -lfltk
-
g++ -o watcher watcher.cxx -lfltk
Watcher uses fltk 1.1, included in the base and devs in compiletc.
-
g++ -o watcher watcher.cxx -lfltk
Watcher uses fltk 1.1, included in the base and devs in compiletc.
Worked like a charm.
However, the -bat option gives me segmentation fault, no matter what.
I guess I'll have to understand what exactly is doing to calculate the battery output.
The problem is that while the bat state file reports a number (actually % full) the bat full file reports a word ???
Just reporting the the output of the -bat state file would be sufficient!
Well,... I have to figure out how to do this :-\
-
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 ???
-
Not really. You should probably try to build with debug symbols (-g) and run under gdb.
There are good beginner instructions for this on the Pidgin site if you haven't used gdb before.
-
Tried it but I just get "no stack" ??? when I try to exec-file either "watcher -bat" or "watcher --args -bat". So I do not really know if I really run "watcher -bat" :(
-
gdb ./watcher
run -bat -otherargs
bt full
-
gdb ./watcher
run -bat -otherargs
bt full
Now this is something...
Run as above runs fine! No faults or anything.
run as ./watcher -bat -> segfault ???
change permissions, directory etc and run directly -> still segfault
bt full only reports
#0 0xb761ae68 in ___newselect_nocancel () from /lib/libc.so.6
No symbol table info available.
#1 0xb77df8fb in fl_wait () from /usr/lib/libfltk.so.1.1
No symbol table info available.
#2 0xb77a0bfd in Fl::wait () from /usr/lib/libfltk.so.1.1
No symbol table info available.
#3 0xb77a0cab in Fl::run () from /usr/lib/libfltk.so.1.1
No symbol table info available.
#4 0x08048df6 in main (argc=3, argv=0xbfd80a84) at watcher.cxx:223
w = 164
window = (struct Fl_Window *) 0x983d0a8
box = (struct Fl_Box *) 0x983d130
???
-
Oh, well...
I gutted watcher and turned it to xo_bat ;D, and this works fine.
Is just a battery monitor for the OLPC XO-1. Binary and source here (http://ftp.cc.uoc.gr/mirrors/linux/TinyCore_for_XO1/TC-XO_sources/)