Source obtained from http://sourceforge.net/projects/wmacpi/files/.

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
        all interrupts while reading from the battery, which apparently
        causes some interactivity issues. I have no idea why reading once
        every three seconds (which is our default), but there've been some
        complaints.
---
 wmacpi/ChangeLog          | 14 ++++++++++++++
 wmacpi/acpi-ng.c          | 17 +++++++----------
 wmacpi/debian/changelog   | 12 ++++++++++++
 wmacpi/debian/wmacpi-ng.1 | 15 ++++++++++++---
 wmacpi/wmacpi-ng.c        | 39 ++++++++++++++++++++++++++++++++++++---
 5 files changed, 81 insertions(+), 16 deletions(-)

diff --git a/wmacpi/ChangeLog b/wmacpi/ChangeLog
index 78bf8bc..009feb9 100644
--- a/wmacpi/ChangeLog
+++ b/wmacpi/ChangeLog
@@ -1,3 +1,17 @@
+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
+       all interrupts while reading from the battery, which apparently
+       causes some interactivity issues. I have no idea why reading once
+       every three seconds (which is our default), but there've been some
+       complaints. 
+
+       Also fixed acpi-ng to properly handle the -a option.
+       
+2003 August 6 0.91
+       Fix a problem I'm seeing with docking the app - if the window name
+       is set to "acpi" rather than "apm" it doesn't dock . . .
+       
 2003 July 16 0.90
        Make the time display show '--:--' instead of '00:00' when the
        time remaining is 0 - I think this is reasonable, since it'll only
diff --git a/wmacpi/acpi-ng.c b/wmacpi/acpi-ng.c
index 5b5a4eb..3341dbf 100644
--- a/wmacpi/acpi-ng.c
+++ b/wmacpi/acpi-ng.c
@@ -34,7 +34,7 @@ void usage(char *name)
 {
        printf("%s: query battery status on ACPI enabled systems.\n"
               "Usage:\n"
-              "%s [-h] [-a]\n"
+              "%s [-h] [-a samples]\n"
               " h - display this help information\n"
               " a - average remaining time over some number of samples\n"
               "     much more accurate than using a single sample\n"
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
        battery_t *binfo;
        adapter_t *ap;
 
-       while((ch = getopt(argc, argv, "hvVa::")) != EOF) {
+       while((ch = getopt(argc, argv, "hvVa:")) != EOF) {
                switch(ch) {
                case 'h':
                        usage(argv[0]);
@@ -68,16 +68,12 @@ int main(int argc, char *argv[])
                        print_version();
                        return 0;
                case 'a':
-                       printf("case a\n");
-                       if(optarg == NULL) {
-                               printf("empty optarg\n");
-                       } else {
-                               printf("optarg: %s\n", optarg);
+                       if(optarg != NULL) {
                                samples = atoi(optarg);
+                               if(samples > 1000 || samples <= 0) {
+                                       printf("Please specify a reasonable 
number of samples\n");
+                                       exit(1);
                        }
-                       if(samples > 1000 || samples <= 0) {
-                               printf("Please specify a reasonable number of 
samples\n");
-                               exit(1);
                        }
                        printf("samples: %d\n", samples);
                        sleep_time = 1000000/samples;
@@ -106,6 +102,7 @@ int main(int argc, char *argv[])
                        binfo = &batteries[i];
                        if(binfo->present && (binfo->charge_state == CHARGE)) {
                                printf("; Battery %s charging", binfo->name);
+                               printf(", currently at %2d%%", 
binfo->percentage);
                                if(binfo->charge_time >= 0) 
                                        printf(", %2d:%02d remaining", 
                                               binfo->charge_time/60,
diff --git a/wmacpi/debian/changelog b/wmacpi/debian/changelog
index 2361cf4..dfe30c8 100644
--- a/wmacpi/debian/changelog
+++ b/wmacpi/debian/changelog
@@ -1,3 +1,15 @@
+wmacpi-ng (0.92-1) unstable; urgency=low
+
+  * New upstream version.
+
+ -- Simon Fowler <[email protected]>  Tue, 23 Sep 2003 11:57:09 +1000
+
+wmacpi-ng (0.91-1) unstable; urgency=low
+
+  * New upstream version.
+
+ -- Simon Fowler <[email protected]>  Wed,  6 Aug 2003 18:32:11 +1000
+
 wmacpi-ng (0.90-1) unstable; urgency=low
 
   * New upstream version.
diff --git a/wmacpi/debian/wmacpi-ng.1 b/wmacpi/debian/wmacpi-ng.1
index 9744b6d..ae564b4 100644
--- a/wmacpi/debian/wmacpi-ng.1
+++ b/wmacpi/debian/wmacpi-ng.1
@@ -18,6 +18,9 @@ display ]
 .RI -m
 battery no ]
 [
+.RI -s
+sample rate ]
+[
 .RI -v
 ]
 ]
@@ -73,18 +76,24 @@ battery to reach full charge if the batteries are charging.
 .B \-b
 Make noise when battery is critical low (beep).
 .TP
-.B \-c value
+.B \-c percentage
 Set critical low alarm at <value>% (default: 10%).
 .TP
-.B \-d
+.B \-d display
 Set the X display to open the window on.
 .TP
-.B \-m
+.B \-m battery number
 Set the battery to monitor initially.
 .TP
+.B \-s sample rate
+Set the rate at which to sample the ACPI data (default is 100, which 
+translates to once every three seconds. 10 gives once every 30 seconds, 
+1 once every 300 seconds (five minutes), 1000 once every 0.3 seconds).
+.TP
 .B \-n
 Disable blinking power glyph when charging. Note that it still blinks when 
 the battery reports its capacity state as critical.
+.TP
 .B \-v
 Increase the verbosity of the program. Can be used more than once -
 each successive use increases the verbosity.
diff --git a/wmacpi/wmacpi-ng.c b/wmacpi/wmacpi-ng.c
index a369058..3caf2a5 100644
--- a/wmacpi/wmacpi-ng.c
+++ b/wmacpi/wmacpi-ng.c
@@ -618,6 +618,7 @@ int main(int argc, char **argv)
     char *display = NULL;
     char ch;
     int update = 0;
+    int samplerate = 100;
     battery_t *binfo;
 
     dockapp = calloc(1, sizeof(Dockapp));
@@ -633,7 +634,7 @@ int main(int argc, char **argv)
        exit(1);
 
     /* parse command-line options */
-    while ((ch = getopt(argc, argv, "bd:c:m:hnvV")) != EOF) {
+    while ((ch = getopt(argc, argv, "bd:c:m:s:hnvV")) != EOF) {
        switch (ch) {
        case 'b':
            noisy_critical = 1;
@@ -668,6 +669,16 @@ int main(int argc, char **argv)
                fprintf(stderr, "Monitoring battery %d\n", battery_no);
            } 
            break;
+       case 's':
+           if (optarg) {
+               samplerate = atoi(optarg);
+               if (samplerate == 0) samplerate = 1;
+               if (samplerate > 3000) samplerate = 3000;
+           } else {
+               usage(argv[0]);
+               exit(1);
+           }
+           break;
        case 'h':
            usage(argv[0]);
            return 0;
@@ -693,7 +704,10 @@ int main(int argc, char **argv)
        exit(1);
 
     /* make new dockapp window */
-    new_window("acpi");
+    /* Don't even /think/ of asking me why, but if I set the window name to 
+     * "acpi", the app refuses to dock properly - it's just plain /weird/ */
+/*    new_window("acpi"); */
+    new_window("apm");
 
     /* get initial statistics */
     acquire_all_info();
@@ -736,7 +750,26 @@ int main(int argc, char **argv)
            }
        }
 
-       if (update++ == 30) {
+       /* XXX: some laptops have problems with sampling the battery
+        * regularly - apparently, the BIOS disables interrupts while
+        * reading from the battery, which is generally on a slow bus 
+        * and is a slow device, so you get significant periods without
+        * interrupts. This causes interactivity to suffer . . . 
+        * 
+        * My proposed workaround is to allow the user to set the sample
+        * rate - it defaults to ten, but can be set lower (or higher).
+        *
+        * The only problem with this is that we need to sample less 
+        * frequently, while still allowing the app to update normally. 
+        * That means calling redraw_window() and all the set_*() functions
+        * normally, but only calling acquire_all_info() every so often. 
+        * As it stands, we only call acquire_all_info() once every three
+        * seconds (once every thirty updates) . . . I'm not entirely sure
+        * /how/ this could cause interactivity problems, but hey . . . 
+        *
+        * So, given the base rate of once every three seconds, we want to
+        * change this test to . . . */
+       if (update++ == (3000/samplerate)) {
            acquire_all_info();
            update = 0;
        }
-- 
1.9.1


-- 
To unsubscribe, send mail to [email protected].

Reply via email to