Source obtained from http://sourceforge.net/projects/wmacpi/files/.
2003 September 26 0.99 Fix the last of the old wmacpi code oddities (specifically, the APMInfo struct, which was a completely inappropriate name given we no longer deal with APM, and because of the various code refactoring). I think this is probably as good as I can make it without getting more feedback and the like, so I'm going to make this version 0.99, preliminary to either wmacpi-ng 1.0 or wmacpi 2.0 (depending which direction I go with that). --- wmacpi/ChangeLog | 11 +++++++++++ wmacpi/acpi-ng.c | 14 +++++++------- wmacpi/debian/changelog | 6 ++++++ wmacpi/libacpi.c | 20 ++++++++++---------- wmacpi/libacpi.h | 4 ++-- wmacpi/wmacpi-ng.c | 30 +++++++++++++++--------------- 6 files changed, 51 insertions(+), 34 deletions(-) diff --git a/wmacpi/ChangeLog b/wmacpi/ChangeLog index 009feb9..4bc42ed 100644 --- a/wmacpi/ChangeLog +++ b/wmacpi/ChangeLog @@ -1,3 +1,14 @@ +2003 September 26 0.99 + Fix the last of the old wmacpi code oddities (specifically, the + APMInfo struct, which was a completely inappropriate name given we + no longer deal with APM, and because of the various code + refactoring). + + I think this is probably as good as I can make it without getting + more feedback and the like, so I'm going to make this version + 0.99, preliminary to either wmacpi-ng 1.0 or wmacpi 2.0 (depending + which direction I go with that). + 2003 September 23 0.92 Fix a few more bugs, and include an option to allow the user to specify how often to sample the ACPI data - some BIOSes disable diff --git a/wmacpi/acpi-ng.c b/wmacpi/acpi-ng.c index 3341dbf..ebc9184 100644 --- a/wmacpi/acpi-ng.c +++ b/wmacpi/acpi-ng.c @@ -26,9 +26,9 @@ #include "libacpi.h" -#define ACPI_NG_VER "0.90" +#define ACPI_NG_VER "0.99" -APMInfo *apminfo; +global_t *globals; void usage(char *name) { @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) } } - apminfo = (APMInfo *) malloc(sizeof(APMInfo)); + globals = (global_t *) malloc(sizeof(global_t)); power_init(); /* we want to acquire samples over some period of time, so . . . */ @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) usleep(sleep_time); } - ap = &apminfo->adapter; + ap = &globals->adapter; if(ap->power == AC) { printf("On AC Power"); for(i = 0; i < batt_count; i++) { @@ -118,9 +118,9 @@ int main(int argc, char *argv[]) printf(", Battery %s at %d%%", binfo->name, binfo->percentage); } - if(apminfo->rtime >= 0) - printf("; %d:%02d remaining", apminfo->rtime/60, - apminfo->rtime%60); + if(globals->rtime >= 0) + printf("; %d:%02d remaining", globals->rtime/60, + globals->rtime%60); printf("\n"); } return 0; diff --git a/wmacpi/debian/changelog b/wmacpi/debian/changelog index dfe30c8..5778797 100644 --- a/wmacpi/debian/changelog +++ b/wmacpi/debian/changelog @@ -1,3 +1,9 @@ +wmacpi-ng (0.99-1) unstable; urgency=low + + * New upstream version. + + -- Simon Fowler <si...@dreamcraft.com.au> Fri, 26 Sep 2003 13:48:55 +1000 + wmacpi-ng (0.92-1) unstable; urgency=low * New upstream version. diff --git a/wmacpi/libacpi.c b/wmacpi/libacpi.c index fbc48f9..e0b536d 100644 --- a/wmacpi/libacpi.c +++ b/wmacpi/libacpi.c @@ -10,7 +10,7 @@ #include "libacpi.h" extern char *state[]; -extern APMInfo *apminfo; +extern global_t *globals; /* temp buffer */ char buf[512]; @@ -87,7 +87,7 @@ int init_ac_adapters(void) { DIR *acdir; struct dirent *adapter; - adapter_t *ap = &apminfo->adapter; + adapter_t *ap = &globals->adapter; char *name; acdir = opendir("/proc/acpi/ac_adapter"); @@ -166,7 +166,7 @@ power_state_t get_power_status(void) FILE *file; char buf[1024]; char *val; - adapter_t *ap = &apminfo->adapter; + adapter_t *ap = &globals->adapter; if ((file = fopen(ap->state_file, "r")) == NULL) { snprintf(buf, 1024, "Could not open state file %s", ap->state_file); @@ -385,7 +385,7 @@ static int calc_charge_time(int batt) void acquire_batt_info(int batt) { battery_t *binfo; - adapter_t *ap = &apminfo->adapter; + adapter_t *ap = &globals->adapter; get_battery_info(batt); @@ -395,7 +395,7 @@ void acquire_batt_info(int batt) binfo->percentage = 0; binfo->valid = 0; binfo->charge_time = 0; - apminfo->rtime = 0; + globals->rtime = 0; return; } @@ -403,10 +403,10 @@ void acquire_batt_info(int batt) /* set the battery's capacity state, based (at present) on some * guesstimated values: more than 75% == HIGH, 25% to 75% MED, and - * less than 25% is LOW. Less than apminfo->crit_level is CRIT. */ + * less than 25% is LOW. Less than globals->crit_level is CRIT. */ if (binfo->percentage == -1) binfo->state = BS_ERR; - if (binfo->percentage < apminfo->crit_level) + if (binfo->percentage < globals->crit_level) binfo->state = CRIT; else if (binfo->percentage > 75) binfo->state = HIGH; @@ -416,7 +416,7 @@ void acquire_batt_info(int batt) binfo->state = LOW; /* we need to /know/ that we've got a valid state for the - * apminfo->power value . . . .*/ + * globals->power value . . . .*/ ap->power = get_power_status(); if ((ap->power != AC) && (binfo->charge_state == DISCHARGE)) { @@ -451,7 +451,7 @@ void acquire_global_info(void) float rcap = 0; float rate = 0; battery_t *binfo; - adapter_t *ap = &apminfo->adapter; + adapter_t *ap = &globals->adapter; static float rate_samples[SAMPLES]; static int j = 0; static int sample_count = 0; @@ -507,7 +507,7 @@ void acquire_global_info(void) rtime = 0; out: eprint(0, "time rem: %d\n", rtime); - apminfo->rtime = rtime; + globals->rtime = rtime; /* get the power status. * note that this is actually reported seperately from the diff --git a/wmacpi/libacpi.h b/wmacpi/libacpi.h index 61b83a4..fac7f8d 100644 --- a/wmacpi/libacpi.h +++ b/wmacpi/libacpi.h @@ -77,7 +77,7 @@ typedef struct { int timer; /* how long been on battery? */ int crit_level; /* anything below this is critical low */ battery_t *binfo; /* pointer to the battery being monitored */ -} APMInfo; +} global_t; /* * Note that there are some serious problems with this: firstly, handling of @@ -119,7 +119,7 @@ int batt_count; /* check if apm/acpi is enabled, etc */ int power_init(void); -/* fill APMInfo with data */ +/* fill global_t with data */ void acquire_batt_info(int); void acquire_all_batt_info(void); void acquire_global_info(void); diff --git a/wmacpi/wmacpi-ng.c b/wmacpi/wmacpi-ng.c index 3caf2a5..27a77cc 100644 --- a/wmacpi/wmacpi-ng.c +++ b/wmacpi/wmacpi-ng.c @@ -35,7 +35,7 @@ #include "libacpi.h" #include "wmacpi-ng.h" -#define WMACPI_NG_VER "0.90" +#define WMACPI_NG_VER "0.99" /* main pixmap */ #ifdef LOW_COLOR @@ -66,7 +66,7 @@ char *state[] = { "AC", "Charging", "High", "Low", "Crit" }; /* globals */ Dockapp *dockapp; -APMInfo *apminfo; +global_t *globals; int count = 0; /* global timer variable */ int noisy_critical = 0; /* ring xbell annoyingly if critical? */ @@ -449,8 +449,8 @@ static void blink_battery_glyph(void) static void set_power_panel(void) { enum panel_states power = PS_NULL; - battery_t *binfo = apminfo->binfo; - adapter_t *ap = &apminfo->adapter; + battery_t *binfo = globals->binfo; + adapter_t *ap = &globals->adapter; if (ap->power == AC) { if (power != PS_AC) { @@ -504,8 +504,8 @@ enum messages { static void set_message(void) { static enum messages state = M_NULL; - battery_t *binfo = apminfo->binfo; - adapter_t *ap = &apminfo->adapter; + battery_t *binfo = globals->binfo; + adapter_t *ap = &globals->adapter; /* battery not present case */ if (!binfo->present) { @@ -563,7 +563,7 @@ void set_time_display(void) if (binfo->charge_state == CHARGE) display_time(binfo->charge_time); else if (binfo->charge_state == DISCHARGE) - display_time(apminfo->rtime); + display_time(globals->rtime); else invalid_time_display(); } @@ -622,10 +622,10 @@ int main(int argc, char **argv) battery_t *binfo; dockapp = calloc(1, sizeof(Dockapp)); - apminfo = calloc(1, sizeof(APMInfo)); + globals = calloc(1, sizeof(global_t)); dockapp->blink = 1; - apminfo->crit_level = 10; + globals->crit_level = 10; battery_no = 1; /* see if whatever we want to use is supported */ @@ -641,10 +641,10 @@ int main(int argc, char **argv) break; case 'c': if (optarg) { - apminfo->crit_level = atoi(optarg); - if ((apminfo->crit_level < 0) || (apminfo->crit_level > 100)) { + globals->crit_level = atoi(optarg); + if ((globals->crit_level < 0) || (globals->crit_level > 100)) { fprintf(stderr, "Please use values between 0 and 100%%\n"); - apminfo->crit_level = 10; + globals->crit_level = 10; fprintf(stderr, "Using default value of 10%%\n"); } } @@ -712,7 +712,7 @@ int main(int argc, char **argv) /* get initial statistics */ acquire_all_info(); binfo = &batteries[battery_no]; - apminfo->binfo = binfo; + globals->binfo = binfo; fprintf(stderr, "monitoring battery %s\n", binfo->name); clear_time_display(); set_power_panel(); @@ -742,8 +742,8 @@ int main(int argc, char **argv) /* cycle through the known batteries. */ battery_no++; battery_no = battery_no % batt_count; - apminfo->binfo = &batteries[battery_no]; - binfo = apminfo->binfo; + globals->binfo = &batteries[battery_no]; + binfo = globals->binfo; fprintf(stderr, "changing to monitor battery %d\n", battery_no + 1); set_batt_id_area(battery_no); break; -- 1.9.1 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.