diff -urN bbapm-0.0.1.orig/Makefile.am bbapm-0.0.1/Makefile.am --- bbapm-0.0.1.orig/Makefile.am Wed Aug 18 03:57:13 1999 +++ bbapm-0.0.1/Makefile.am Tue Mar 19 12:38:46 2002 @@ -9,6 +9,7 @@ resource.cc resource.hh \ Baseresource.cc Baseresource.hh \ Basewindow.cc Basewindow.hh \ - blackboxstyle.hh + blackboxstyle.hh \ + open_apm.h open_apm.cc EXTRA_DIST = BUGS TODO -bbapm_LDADD = @X_LIBS@ -lapm +bbapm_LDADD = @X_LIBS@ diff -urN bbapm-0.0.1.orig/Makefile.in bbapm-0.0.1/Makefile.in --- bbapm-0.0.1.orig/Makefile.in Fri Aug 20 17:28:11 1999 +++ bbapm-0.0.1/Makefile.in Tue Mar 19 12:37:52 2002 @@ -73,7 +73,7 @@ bbapm_SOURCES = bbapm.cc Image.cc LinkedList.cc bbapm.hh Image.hh LinkedList.hh resource.cc resource.hh Baseresource.cc Baseresource.hh Basewindow.cc Basewindow.hh blackboxstyle.hh EXTRA_DIST = BUGS TODO -bbapm_LDADD = @X_LIBS@ -lapm +bbapm_LDADD = @X_LIBS@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_CLEAN_FILES = version.h @@ -88,7 +88,7 @@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ bbapm_OBJECTS = bbapm.o Image.o LinkedList.o resource.o Baseresource.o \ -Basewindow.o +Basewindow.o open_apm.o bbapm_DEPENDENCIES = bbapm_LDFLAGS = CXXFLAGS = @CXXFLAGS@ diff -urN bbapm-0.0.1.orig/bbapm.cc bbapm-0.0.1/bbapm.cc --- bbapm-0.0.1.orig/bbapm.cc Fri Aug 20 17:20:45 1999 +++ bbapm-0.0.1/bbapm.cc Tue Mar 19 12:38:46 2002 @@ -307,13 +307,8 @@ redraw = True; if (!broken) { - - if (apm_exists() < 0) - broken = True; - else { - if ((apm_read(&apm))<0) - broken = True; - } + if ((apm_read(&apm))<0) + broken = True; } if (redraw) @@ -336,7 +331,7 @@ // loadbar to show that the battery is loading. A bit like GSM. But // in this case the label will show how far the loading is done. if ((resource->show.loading) && - (apm.ac_line_status==1) && + (apm.ac_state==1) && (resource->show.percentage)) { for (i=0; i < resource->loadbar.number_of_bars; i++) { if (noLoadBarFilled>=i) { @@ -361,7 +356,7 @@ resource->loadbar.number_of_bars << endl; #endif for (i = 0; i < resource->loadbar.number_of_bars; i++) { - if (apm.battery_percentage >= load[i].level) + if (apm.battery_life >= load[i].level) XCopyArea(dpy, pixmap.loadbar_active, framewin, frameGC, 2, load[i].y - 1, load[i].width, load[i].height, load[i].x, @@ -389,7 +384,7 @@ XSetForeground(dpy, frameGC, resource->label.percentage_textColor.pixel); - sprintf(t, "%03d%%", apm.battery_percentage); + sprintf(t, "%03d%%", apm.battery_life); XDrawString(dpy, labelwin, frameGC, label.space_width, (label.height + resource->label.font->ascent - resource->label.font->descent) / 2, @@ -413,7 +408,7 @@ XSetForeground(dpy, frameGC, resource->label.time_textColor.pixel); - sprintf(t, "%02d:%02d", apm.battery_time/60, apm.battery_time%60); + sprintf(t, "%02d:%02d", apm.minutes_left/60, apm.minutes_left%60); XDrawString(dpy, labelwin, frameGC, xposition, (label.height + resource->label.font->ascent - resource->label.font->descent) / 2, t, strlen(t)); @@ -519,7 +514,7 @@ } } - if (apm.ac_line_status==1) { + if (apm.ac_state==1) { if (time(NULL) - lastLoadingTime > resource->show.loadingTime) { ReadAPM(); lastLoadingTime = time(NULL); @@ -565,6 +560,8 @@ int main(int argc, char **argv) { + apm_init(); + ToolWindow * AppWindow = new ToolWindow(argc, argv); diff -urN bbapm-0.0.1.orig/bbapm.hh bbapm-0.0.1/bbapm.hh --- bbapm-0.0.1.orig/bbapm.hh Mon Aug 16 13:10:23 1999 +++ bbapm-0.0.1/bbapm.hh Tue Mar 19 12:38:46 2002 @@ -21,9 +21,7 @@ #ifndef __MAIN_HH #define __MAIN_HH -extern "C" { -#include -} +#include "open_apm.h" #include "Image.hh" #include "Basewindow.hh" diff -urN bbapm-0.0.1.orig/open_apm.cc bbapm-0.0.1/open_apm.cc --- bbapm-0.0.1.orig/open_apm.cc Wed Dec 31 19:00:00 1969 +++ bbapm-0.0.1/open_apm.cc Tue Mar 19 12:38:46 2002 @@ -0,0 +1,20 @@ +#include "open_apm.h" + +int apm_desc = -1; + +void apm_init() { + if ( (apm_desc = open( "/dev/apm", O_RDONLY ) ) == -1 ) { + printf("Error: cannot open APM device: /dev/apm: %s\n", strerror( errno ) ); + exit( 1 ); + } +} + +int apm_read( apm_info* a_info ) { + if( apm_desc < 0 ) + return -1; + + if ( ioctl( apm_desc, APM_IOC_GETPOWER, a_info ) == -1 ) + return -1; + else + return 0; +} diff -urN bbapm-0.0.1.orig/open_apm.h bbapm-0.0.1/open_apm.h --- bbapm-0.0.1.orig/open_apm.h Wed Dec 31 19:00:00 1969 +++ bbapm-0.0.1/open_apm.h Tue Mar 19 12:38:46 2002 @@ -0,0 +1,19 @@ +#ifndef _OPEN_APM_H +#define _OPEN_APM_H + +#include +#include +#include +#include +#include + +typedef struct apm_power_info apm_info; + +extern int apm_desc; +extern int errno; + +void apm_init(); + +int apm_read( apm_info* ); + +#endif