diff -urN wmapm-3.1.org/wmapm/Makefile wmapm-3.1/wmapm/Makefile --- wmapm-3.1.org/wmapm/Makefile Wed Jan 12 01:42:25 2000 +++ wmapm-3.1/wmapm/Makefile Mon Oct 15 20:33:07 2001 @@ -8,13 +8,13 @@ ../wmgeneral/wmgeneral.o .c.o: - $(CC) $(COPTS) -D$(shell echo `uname -s`) -c $< -o $*.o $(INCDIR) + $(CC) $(CFLAGS) -D$(shell echo `uname -s`) -c $< -o $*.o $(INCDIR) all: wmapm.o wmapm wmapm.o: wmapm_master.xpm wmapm_mask.xbm wmapm.h wmapm: $(OBJS) - $(CC) $(COPTS) $(SYSTEM) -o wmapm $^ $(INCDIR) $(LIBDIR) $(LIBS) + $(CC) $(CFLAGS) $(SYSTEM) -o wmapm $^ $(INCDIR) $(LIBDIR) $(LIBS) clean: for i in $(OBJS) ; do \ Binary files wmapm-3.1.org/wmapm/wmapm and wmapm-3.1/wmapm/wmapm differ diff -urN wmapm-3.1.org/wmapm/wmapm.c wmapm-3.1/wmapm/wmapm.c --- wmapm-3.1.org/wmapm/wmapm.c Wed Jan 12 01:37:25 2000 +++ wmapm-3.1/wmapm/wmapm.c Mon Oct 15 20:33:44 2001 @@ -155,6 +155,8 @@ #include #include #include +#include +#include #include #endif #include @@ -175,10 +177,11 @@ int apm_read(struct my_apm_info *i); #else # ifdef FreeBSD -int apm_read(apm_info_t temp_info); +int apm_read(struct my_apm_info *i); # endif #endif int apm_exists(); +int acpi_exists(); void ParseCMDLine(int argc, char *argv[]); void pressEvent(XButtonEvent *xev); @@ -213,24 +216,21 @@ struct my_apm_info my_cur_info; int time_left, hour_left, - min_left, - digit; -#ifdef FreeBSD - struct apm_info temp_info; -#endif + min_left; XEvent event; - int m, mMax, n, nMax, k, Toggle; + int m, mMax, n, nMax, k, Toggle = 0; long int r, rMax, s, sMax; FILE *fp; + int apm_acpi_exists = 0; - BlinkRate = 3.0; - UpdateRate = 1.0/1.25; + BlinkRate = 1.0/10.0; + UpdateRate = 1.0/30.0; @@ -261,14 +261,32 @@ * Check for APM support */ if (!apm_exists()) { +/* #ifdef Linux fprintf(stderr, "No APM support in kernel\n"); #else fprintf(stderr, "Unable to access APM info\n"); #endif - exit(1); +*/ + apm_acpi_exists++; + } + + + /* + * Check for ACPI support + */ + if (!acpi_exists()) { +#ifdef Linux + fprintf(stderr, "No ACPI support in kernel\n"); +#else + fprintf(stderr, "Unable to access ACPI info\n"); +#endif + apm_acpi_exists++; } + if (apm_acpi_exists == 2) { + exit(1); + } @@ -307,15 +325,15 @@ if (apm_read(&my_cur_info)) { #else # ifdef FreeBSD - if (apm_read(&temp_info)) { + if (apm_read(&my_cur_info)) { # endif #endif - fprintf(stderr, "Cannot read APM information: %i\n"); + fprintf(stderr, "Cannot read APM information: \n"); exit(1); } -#ifdef FreeBSD /* Convert status's */ +#ifdef FreeBSD_APM /* Convert status's (XXX not used) */ my_cur_info.ac_line_status = (int)temp_info.ai_acline; my_cur_info.battery_status = (int)temp_info.ai_batt_stat; my_cur_info.battery_percentage = (int)temp_info.ai_batt_life; @@ -362,7 +380,7 @@ /* * Check to see if we are charging. */ - if ( (int)(my_cur_info.battery_status) == 3){ + if ( (int)(my_cur_info.battery_status) == 2){ /* * Battery Status: Charging. @@ -401,7 +419,7 @@ if (my_cur_info.battery_time >= ((my_cur_info.using_minutes) ? 1440 : 86400) ) { #else # ifdef FreeBSD - if (my_cur_info.battery_time >= 86400) { + if (my_cur_info.battery_time == -1) { # endif #endif @@ -419,7 +437,7 @@ time_left = (my_cur_info.using_minutes) ? my_cur_info.battery_time : my_cur_info.battery_time / 60; #endif #ifdef FreeBSD - time_left = (my_cur_info.using_minutes) ? my_cur_info.battery_time / 60 : my_cur_info.battery_time / 3600; + time_left = my_cur_info.battery_time; #endif hour_left = time_left / 60; @@ -489,8 +507,9 @@ m = 0; - if (( (int)(my_cur_info.battery_status) == 2) - ||( (int)(my_cur_info.battery_percentage) <= CriticalLevel )){ +/* if (( (int)(my_cur_info.battery_status) == 2) + ||( (int)(my_cur_info.battery_percentage) <= CriticalLevel )){ */ + if (( (int)(my_cur_info.battery_percentage) <= CriticalLevel )){ /* * Battery Status: Critical. @@ -507,8 +526,9 @@ copyXPMArea(81, 68, 4, 4, 30, 51); /* turn off yellow */ copyXPMArea(87, 68, 4, 4, 36, 51); /* turn off green */ - } else if (( (int)(my_cur_info.battery_status) == 1) - ||( (int)(my_cur_info.battery_percentage) <= LowLevel )){ +/* } else if (( (int)(my_cur_info.battery_status) == 1) + ||( (int)(my_cur_info.battery_percentage) <= LowLevel )){ */ + } else if (( (int)(my_cur_info.battery_percentage) <= LowLevel )){ /* * Battery Status: Low. @@ -517,8 +537,9 @@ copyXPMArea(101, 68, 4, 4, 30, 51); /* turn ON yellow */ copyXPMArea(87, 68, 4, 4, 36, 51); /* turn off green */ - } else if (( (int)( my_cur_info.battery_status ) == 0) - ||( (int)(my_cur_info.battery_percentage) > LowLevel )){ +/* } else if (( (int)( my_cur_info.battery_status ) == 0) + ||( (int)(my_cur_info.battery_percentage) > LowLevel )){ */ + } else if (( (int)(my_cur_info.battery_percentage) > LowLevel )){ /* * Battery Status: High. @@ -546,8 +567,9 @@ * This controls Critical Alerts */ if (Alert){ - if (( (int)(my_cur_info.battery_status) == 2) - ||( (int)(my_cur_info.battery_percentage) <= CriticalLevel )){ +/* if (( (int)(my_cur_info.battery_status) == 2) + ||( (int)(my_cur_info.battery_percentage) <= CriticalLevel )){ */ + if (( (int)(my_cur_info.battery_percentage) <= CriticalLevel )){ if (s>sMax){ @@ -595,6 +617,9 @@ while(XPending(display)){ XNextEvent(display, &event); switch(event.type){ + case EnterNotify: + n = nMax; + break; case Expose: RedrawWindow(); break; @@ -712,7 +737,11 @@ int apm_exists() { +#if FreeBSD + if (open(APMDEV, O_RDONLY) == -1) +#else if (access(APMDEV, R_OK)) +#endif /* * Cannot find /proc/apm @@ -725,6 +754,25 @@ } +int acpi_exists() +{ + +#if FreeBSD + if (open("/dev/acpi", O_RDONLY) == -1) +#else + if (access(APMDEV, R_OK)) +#endif + + /* + * Cannot find /proc/apm + */ + return 0; + + else + + return 1; + +} @@ -839,26 +887,36 @@ } #else # ifdef FreeBSD -int apm_read(apm_info_t temp_info) { - - int fd; - - if ( (fd = open(APMDEV, O_RDWR)) < 0){ - - return(1); - - } else if ( ioctl(fd, APMIO_GETINFO, temp_info) == -1 ) { - - close(fd); - return(1); +int apm_read(struct my_apm_info *i) { + /* add */ + int tmp; + size_t len; + + /* [ACPI] + hw.acpi.acline: 1 + hw.acpi.battery.state: 2 + hw.acpi.battery.life: 62 + hw.acpi.battery.time: -1 - } else { + [APM] + my_cur_info.ac_line_status = (int)temp_info.ai_acline; + my_cur_info.battery_status = (int)temp_info.ai_batt_stat; + my_cur_info.battery_percentage = (int)temp_info.ai_batt_life; + my_cur_info.battery_time = (int)temp_info.ai_batt_time; + */ - close(fd); + len = sizeof(tmp); + sysctlbyname("hw.acpi.acline", &tmp, &len, NULL, 0); + i->ac_line_status = tmp; + sysctlbyname("hw.acpi.battery.state", &tmp, &len, NULL, 0); + i->battery_status = tmp; + sysctlbyname("hw.acpi.battery.life", &tmp, &len, NULL, 0); + i->battery_percentage = tmp; + sysctlbyname("hw.acpi.battery.time", &tmp, &len, NULL, 0); + i->battery_time = tmp; + + /* end */ return(0); - - } - } # endif #endif @@ -941,8 +999,8 @@ */ void ParseCMDLine(int argc, char *argv[]) { char *cmdline; -int i,j; -char puke[20]; +int i; +/* char puke[20]; */ for (i = 1; i < argc; i++) { cmdline = argv[i]; Binary files wmapm-3.1.org/wmapm/wmapm.o and wmapm-3.1/wmapm/wmapm.o differ diff -urN wmapm-3.1.org/wmgeneral/wmgeneral.c wmapm-3.1/wmgeneral/wmgeneral.c --- wmapm-3.1.org/wmgeneral/wmgeneral.c Tue Aug 4 10:49:00 1998 +++ wmapm-3.1/wmgeneral/wmgeneral.c Mon Oct 15 20:17:54 2001 @@ -324,8 +324,8 @@ classHint.res_class = wname; XSetClassHint(display, win, &classHint); - XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask); - XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask); + XSelectInput(display, win, ButtonPressMask | ExposureMask | EnterWindowMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask); + XSelectInput(display, iconwin, ButtonPressMask | ExposureMask| EnterWindowMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask); if (XStringListToTextProperty(&wname, 1, &name) == 0) { fprintf(stderr, "%s: can't allocate window name\n", wname); Binary files wmapm-3.1.org/wmgeneral/wmgeneral.o and wmapm-3.1/wmgeneral/wmgeneral.o differ