wmacpi: Bump to version 2.2rc1.
Source obtained from http://sourceforge.net/projects/wmacpi/files/. 2007 July 14 2.2rc1 Major changes to command line handling and to the way we use libdockapp, courtesy of Patrice Dumas. This should hopefully fix several long-standing bugs with non-wmaker window managers (in particular Debian bugs #280495 and 293546). Updated to support newer kernels that no longer support /proc/acpi/info - thanks to Samuel Ortiz. Fixed a longstanding issue with redrawing - thanks to Vito Caputo. This version changes a number of command line options (little used ones, but they're still incompatible changes) due to the libdockapp work. In particular, -w becomes -x, -v becomes -V (and takes an argument rather than being repeated), and -V becomes -v (thanks to libdockapp grabbing -h, -v and -w for itself). Also, long options are now supported for everything in wmacpi (but not acpi, since it doesn't use libdockapp for command line parsing).
This commit is contained in:
parent
ea8b68a3ce
commit
ffd4b11477
39 changed files with 252 additions and 173 deletions
1
wmacpi/.arch-ids/AUTHORS.id
Normal file
1
wmacpi/.arch-ids/AUTHORS.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.0
|
1
wmacpi/.arch-ids/COPYING.id
Normal file
1
wmacpi/.arch-ids/COPYING.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.1
|
1
wmacpi/.arch-ids/ChangeLog.id
Normal file
1
wmacpi/.arch-ids/ChangeLog.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.2
|
1
wmacpi/.arch-ids/INSTALL.id
Normal file
1
wmacpi/.arch-ids/INSTALL.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.3
|
1
wmacpi/.arch-ids/Makefile.id
Normal file
1
wmacpi/.arch-ids/Makefile.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.4
|
1
wmacpi/.arch-ids/README.id
Normal file
1
wmacpi/.arch-ids/README.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.5
|
1
wmacpi/.arch-ids/TODO.id
Normal file
1
wmacpi/.arch-ids/TODO.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:59:50 2004 11909.0
|
1
wmacpi/.arch-ids/acpi.1.id
Normal file
1
wmacpi/.arch-ids/acpi.1.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 13:18:00 2004 13139.0
|
1
wmacpi/.arch-ids/acpi.c.id
Normal file
1
wmacpi/.arch-ids/acpi.c.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 12:21:51 2004 12157.0
|
1
wmacpi/.arch-ids/libacpi.c.id
Normal file
1
wmacpi/.arch-ids/libacpi.c.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.6
|
1
wmacpi/.arch-ids/libacpi.h.id
Normal file
1
wmacpi/.arch-ids/libacpi.h.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 12:18:57 2004 12091.0
|
1
wmacpi/.arch-ids/master.xpm.id
Normal file
1
wmacpi/.arch-ids/master.xpm.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.10
|
1
wmacpi/.arch-ids/master_low.xpm.id
Normal file
1
wmacpi/.arch-ids/master_low.xpm.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.11
|
1
wmacpi/.arch-ids/wmacpi.1.id
Normal file
1
wmacpi/.arch-ids/wmacpi.1.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.22
|
1
wmacpi/.arch-ids/wmacpi.c.id
Normal file
1
wmacpi/.arch-ids/wmacpi.c.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.8
|
1
wmacpi/.arch-ids/wmacpi.h.id
Normal file
1
wmacpi/.arch-ids/wmacpi.h.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.9
|
2
wmacpi/.hg_archival.txt
Normal file
2
wmacpi/.hg_archival.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
repo: 9cde42e7fe71d3618c7c14b2f4fec73f079b283d
|
||||||
|
node: 65f88f7c4b29c4c74f068ba63c1c63c83c193eec
|
35
wmacpi/.hgempty
Normal file
35
wmacpi/.hgempty
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
Empty original changeset by Simon Fowler <simon@himi.org>:
|
||||||
|
[project @ simon@himi.org--wmacpi/wmacpi--mainline--2.0--patch-2]
|
||||||
|
Fixes for compiling against libdockapp-0.5.0
|
||||||
|
This amounted to a four line patch - narrowing the type of
|
||||||
|
the dockapp width and height to an unsigned short.
|
||||||
|
|
||||||
|
Unfortunately this isn't compatible with libdockapp-0.4.0
|
||||||
|
now.
|
||||||
|
|
||||||
|
Empty original changeset by Simon Fowler <simon@himi.org>:
|
||||||
|
[project @ simon@himi.org--wmacpi/wmacpi--mainline--2.0--patch-3]
|
||||||
|
Upped version numbers for 2.1 release.
|
||||||
|
That's about it.
|
||||||
|
|
||||||
|
Empty original changeset by Simon Fowler <simon@himi.org>:
|
||||||
|
[project @ simon@himi.org--wmacpi/wmacpi--mainline--2.0--patch-4]
|
||||||
|
Small patch submitted by Patrice Dumas <pertusus at free.fr>
|
||||||
|
Keywords: libdockapp build fixes
|
||||||
|
Build fixes for newer versions of libdockapp.
|
||||||
|
|
||||||
|
Empty original changeset by Simon Fowler <simon@himi.org>:
|
||||||
|
[project @ simon@himi.org--wmacpi/wmacpi--mainline--2.0--patch-5]
|
||||||
|
Updated email address and changelog for alpha release.
|
||||||
|
Since my dreamcraft.com.au address will be going away at some point . . .
|
||||||
|
|
||||||
|
Empty original changeset by Simon Fowler <simon@himi.org>:
|
||||||
|
[project @ simon@himi.org--wmacpi/wmacpi--mainline--2.0--patch-6]
|
||||||
|
Fix for 'charged' battery status
|
||||||
|
Some batteries report their status as 'discharging' when they're
|
||||||
|
fully charged, some report their status as 'charged' - previously
|
||||||
|
I was only checking for 'discharging' when switching out of the
|
||||||
|
battery charging state, now we check for 'charged' as well.
|
||||||
|
|
||||||
|
This fixes part of Debian bug #393617.
|
3
wmacpi/.hgignore
Normal file
3
wmacpi/.hgignore
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
(^|/)\{arch\}($|/)
|
||||||
|
(^|/)\.hg($|/)
|
||||||
|
(^|/)\.hgtags($|/)
|
1
wmacpi/.hgtags
Normal file
1
wmacpi/.hgtags
Normal file
|
@ -0,0 +1 @@
|
||||||
|
8b1a90b86e0bf59867af5dc51de1db30b76458e7 v2.2rc1
|
|
@ -1,3 +1,23 @@
|
||||||
|
2007 July 14 2.2rc1
|
||||||
|
Major changes to command line handling and to the way we use
|
||||||
|
libdockapp, courtesy of Patrice Dumas. This should hopefully fix
|
||||||
|
several long-standing bugs with non-wmaker window managers (in
|
||||||
|
particular Debian bugs #280495 and 293546).
|
||||||
|
|
||||||
|
Updated to support newer kernels that no longer support
|
||||||
|
/proc/acpi/info - thanks to Samuel Ortiz.
|
||||||
|
|
||||||
|
Fixed a longstanding issue with redrawing - thanks to Vito
|
||||||
|
Caputo.
|
||||||
|
|
||||||
|
This version changes a number of command line options (little used
|
||||||
|
ones, but they're still incompatible changes) due to the
|
||||||
|
libdockapp work. In particular, -w becomes -x, -v becomes -V (and
|
||||||
|
takes an argument rather than being repeated), and -V becomes -v
|
||||||
|
(thanks to libdockapp grabbing -h, -v and -w for itself). Also,
|
||||||
|
long options are now supported for everything in wmacpi (but not
|
||||||
|
acpi, since it doesn't use libdockapp for command line parsing).
|
||||||
|
|
||||||
2007 January 10 2.2a1
|
2007 January 10 2.2a1
|
||||||
Added a patch from Patrice Dumas to support newer versions of
|
Added a patch from Patrice Dumas to support newer versions of
|
||||||
libdockapp.
|
libdockapp.
|
||||||
|
|
|
@ -14,7 +14,7 @@ BUILD_CLI = 1
|
||||||
|
|
||||||
CC := gcc
|
CC := gcc
|
||||||
CFLAGS := $(OPT) -Wall -W -g -ansi -I/usr/X11R6/include
|
CFLAGS := $(OPT) -Wall -W -g -ansi -I/usr/X11R6/include
|
||||||
LDFLAGS := $(OPT) -L/usr/X11R6/lib -lX11 -lXpm -lXext -ldockapp
|
LDFLAGS := $(OPT) -lX11 -ldockapp
|
||||||
|
|
||||||
WMSRC := wmacpi.c libacpi.c
|
WMSRC := wmacpi.c libacpi.c
|
||||||
HEADERS := libacpi.h wmacpi.h
|
HEADERS := libacpi.h wmacpi.h
|
||||||
|
@ -34,7 +34,7 @@ all: $(targets)
|
||||||
WMOBJ := $(patsubst %.c,%.o,$(filter %.c,$(WMSRC)))
|
WMOBJ := $(patsubst %.c,%.o,$(filter %.c,$(WMSRC)))
|
||||||
|
|
||||||
# include per-file dependencies
|
# include per-file dependencies
|
||||||
include $(WMOBJ:.o=.d)
|
-include $(WMOBJ:.o=.d)
|
||||||
|
|
||||||
wmacpi: $(WMOBJ)
|
wmacpi: $(WMOBJ)
|
||||||
$(CC) $(LDFLAGS) -o $@ $^
|
$(CC) $(LDFLAGS) -o $@ $^
|
||||||
|
@ -44,7 +44,7 @@ wmacpi: $(WMOBJ)
|
||||||
ifdef BUILD_CLI
|
ifdef BUILD_CLI
|
||||||
CLSRC := acpi.c libacpi.c
|
CLSRC := acpi.c libacpi.c
|
||||||
CLOBJ := $(patsubst %.c,%.o,$(filter %.c,$(CLSRC)))
|
CLOBJ := $(patsubst %.c,%.o,$(filter %.c,$(CLSRC)))
|
||||||
include $(CLOBJ:.o=.d)
|
-include $(CLOBJ:.o=.d)
|
||||||
|
|
||||||
acpi: $(CLOBJ)
|
acpi: $(CLOBJ)
|
||||||
$(CC) $(LDFLAGS) -o $@ $^
|
$(CC) $(LDFLAGS) -o $@ $^
|
||||||
|
|
|
@ -18,14 +18,14 @@ wmacpi is a dockapp ACPI battery monitor for modern kernels (ie,
|
||||||
under /proc/acpi, reads status information from them, and then
|
under /proc/acpi, reads status information from them, and then
|
||||||
displays summaries.
|
displays summaries.
|
||||||
|
|
||||||
Version 1.99 and later provides full support for multiple
|
Version 1.99 and later provides full support for multiple batteries.
|
||||||
batteries. You can tell it to monitor a particular battery with the -m
|
You can tell it to monitor a particular battery with the -m option,
|
||||||
option, which will display the percentage remaining and current status
|
which will display the percentage remaining and current status message
|
||||||
message for that battery. The time remaining and AC/battery status are
|
for that battery. The time remaining and AC/battery status are global
|
||||||
global - the time remaining is calculated based on all batteries found
|
- the time remaining is calculated based on all batteries found on the
|
||||||
on the system. When charging, the time displayed is the time remaining
|
system. When charging, the time displayed is the time remaining until
|
||||||
until the battery is fully charged - this only works sensibly if your
|
the battery is fully charged - this only works sensibly if your ACPI
|
||||||
ACPI system is implemented properly (far, far too many laptops have
|
system is implemented properly (far, far too many laptops have
|
||||||
buggered ACPI implementations).
|
buggered ACPI implementations).
|
||||||
|
|
||||||
The displayed time is averaged over 50 samples, each taken every three
|
The displayed time is averaged over 50 samples, each taken every three
|
||||||
|
@ -38,10 +38,10 @@ reading status information from the battery over a slow bus - this
|
||||||
means that on such b0rken laptops, running an ACPI battery monitor
|
means that on such b0rken laptops, running an ACPI battery monitor
|
||||||
could affect interactivity. To provide a workaround for this, current
|
could affect interactivity. To provide a workaround for this, current
|
||||||
versions of wmacpi supports setting the sample rate from the command
|
versions of wmacpi supports setting the sample rate from the command
|
||||||
line. The default -s setting is 100, which translates to once every
|
line. The --sample-rate option specifies the number of times the
|
||||||
three seconds. -s 10 will sample every 30 seconds, -s 1 every 300
|
battery is sampled every minute - the default is 20, and the maximum
|
||||||
seconds. -s 1000 will sample every 0.3 seconds - don't do that unless
|
value is 600. Since -s 600 translates to sampling every 0.1 seconds,
|
||||||
you're just having fun . . .
|
you really don't want to do that unless you're just having fun . . .
|
||||||
|
|
||||||
Also provided is a command line tool to report the battery status. By
|
Also provided is a command line tool to report the battery status. By
|
||||||
default this will only sample once, but with the -a option you can
|
default this will only sample once, but with the -a option you can
|
||||||
|
@ -49,6 +49,6 @@ specify a number. Be aware that it will try to take all those samples
|
||||||
in the space of one second, so if your ACPI implementation is b0rken
|
in the space of one second, so if your ACPI implementation is b0rken
|
||||||
this could have adverse effects.
|
this could have adverse effects.
|
||||||
|
|
||||||
Please report bugs to <simon@dreamcraft.com.au>.
|
Please report bugs to <simon@himi.org>
|
||||||
|
|
||||||
Simon Fowler, 2003-11-23.
|
Simon Fowler, 2007-07-13.
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
2007 July 13 2.2rc1
|
||||||
|
* Make sure that everything works properly on modern kernels.
|
||||||
|
|
||||||
2004 January 18 1.99r3
|
2004 January 18 1.99r3
|
||||||
* Correctly handle changing batteries at runtime, if possible. Note
|
* Correctly handle changing batteries at runtime, if possible. Note
|
||||||
the bug reported by Joey Hess against wmacpi 1.33 . . .
|
the bug reported by Joey Hess against wmacpi 1.33 . . .
|
||||||
|
|
||||||
2003 November 23 1.99
|
2003 November 23 1.99
|
||||||
* Expand libacpi to handle everything else under
|
* Expand libacpi to handle everything else under
|
||||||
|
@ -46,4 +49,4 @@
|
||||||
|
|
||||||
* Code cleanups . . .
|
* Code cleanups . . .
|
||||||
|
|
||||||
-- Simon Fowler, <simon@dreamcraft.com.au>
|
-- Simon Fowler, <simon@himi.org>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include "libacpi.h"
|
#include "libacpi.h"
|
||||||
|
|
||||||
#define ACPI_VER "2.1"
|
#define ACPI_VER "2.2rc1"
|
||||||
|
|
||||||
global_t *globals;
|
global_t *globals;
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ void usage(char *name)
|
||||||
" h - display this help information\n"
|
" h - display this help information\n"
|
||||||
" a - average remaining time over some number of samples\n"
|
" a - average remaining time over some number of samples\n"
|
||||||
" much more accurate than using a single sample\n"
|
" much more accurate than using a single sample\n"
|
||||||
" v - increase verbosity\n",
|
" V - increase verbosity\n"
|
||||||
|
" v - print version information\n",
|
||||||
name, name);
|
name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,10 +62,10 @@ int main(int argc, char *argv[])
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
case 'v':
|
case 'V':
|
||||||
verbosity++;
|
verbosity++;
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'v':
|
||||||
print_version();
|
print_version();
|
||||||
return 0;
|
return 0;
|
||||||
case 'a':
|
case 'a':
|
||||||
|
|
1
wmacpi/debian/.arch-ids/=id
Normal file
1
wmacpi/debian/.arch-ids/=id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.12
|
1
wmacpi/debian/.arch-ids/changelog.id
Normal file
1
wmacpi/debian/.arch-ids/changelog.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.13
|
1
wmacpi/debian/.arch-ids/compat.id
Normal file
1
wmacpi/debian/.arch-ids/compat.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.14
|
1
wmacpi/debian/.arch-ids/control.id
Normal file
1
wmacpi/debian/.arch-ids/control.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.15
|
1
wmacpi/debian/.arch-ids/copyright.id
Normal file
1
wmacpi/debian/.arch-ids/copyright.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.16
|
1
wmacpi/debian/.arch-ids/dirs.id
Normal file
1
wmacpi/debian/.arch-ids/dirs.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.17
|
1
wmacpi/debian/.arch-ids/docs.id
Normal file
1
wmacpi/debian/.arch-ids/docs.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.18
|
1
wmacpi/debian/.arch-ids/menu.id
Normal file
1
wmacpi/debian/.arch-ids/menu.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.19
|
1
wmacpi/debian/.arch-ids/rules.id
Normal file
1
wmacpi/debian/.arch-ids/rules.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.20
|
1
wmacpi/debian/.arch-ids/watch.id
Normal file
1
wmacpi/debian/.arch-ids/watch.id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Simon Fowler <simon@himi.org> Sun Jul 11 11:28:38 2004 11066.21
|
|
@ -139,15 +139,20 @@ int power_init(global_t *globals)
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
int acpi_ver = 0;
|
int acpi_ver = 0;
|
||||||
int retval;
|
int retval;
|
||||||
|
unsigned int version_offset = 0;
|
||||||
|
|
||||||
if (!(acpi = fopen("/proc/acpi/info", "r"))) {
|
if (!(acpi = fopen("/sys/module/acpi/parameters/acpica_version", "r"))) {
|
||||||
pfatal("This system does not support ACPI\n");
|
if (!(acpi = fopen("/proc/acpi/info", "r"))) {
|
||||||
return 1;
|
pfatal("This system does not support ACPI\n");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
version_offset = 25;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* okay, now see if we got the right version */
|
/* okay, now see if we got the right version */
|
||||||
fread(buf, 4096, 1, acpi);
|
fread(buf, 4096, 1, acpi);
|
||||||
acpi_ver = strtol(buf + 25, NULL, 10);
|
acpi_ver = strtol(buf + version_offset, NULL, 10);
|
||||||
pinfo("ACPI version detected: %d\n", acpi_ver);
|
pinfo("ACPI version detected: %d\n", acpi_ver);
|
||||||
if (acpi_ver < 20020214) {
|
if (acpi_ver < 20020214) {
|
||||||
pfatal("This version requires ACPI subsystem version 20020214\n");
|
pfatal("This version requires ACPI subsystem version 20020214\n");
|
||||||
|
@ -169,9 +174,11 @@ int power_reinit(global_t *globals)
|
||||||
FILE *acpi;
|
FILE *acpi;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (!(acpi = fopen("/proc/acpi/info", "r"))) {
|
if (!(acpi = fopen("/sys/module/acpi/parameters/acpica_version", "r"))) {
|
||||||
pfatal("Could not reopen ACPI info file - does this system support ACPI?\n");
|
if (!(acpi = fopen("/proc/acpi/info", "r"))) {
|
||||||
return 1;
|
pfatal("Could not reopen ACPI info file - does this system support ACPI?\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(retval = reinit_batteries(globals)))
|
if (!(retval = reinit_batteries(globals)))
|
||||||
|
@ -337,6 +344,12 @@ int get_battery_info(int batt_no)
|
||||||
info->charge_state = CH_ERR;
|
info->charge_state = CH_ERR;
|
||||||
else if ((strncmp(val, "discharging", 10)) == 0)
|
else if ((strncmp(val, "discharging", 10)) == 0)
|
||||||
info->charge_state = DISCHARGE;
|
info->charge_state = DISCHARGE;
|
||||||
|
else if ((strncmp(val, "charged", 7)) == 0)
|
||||||
|
/* this is a workaround for machines that report
|
||||||
|
* their charge state as 'charged', rather than
|
||||||
|
* what my laptop does, which is go straight to
|
||||||
|
* 'discharging'. dunno which matches the standard */
|
||||||
|
info->charge_state = DISCHARGE;
|
||||||
else
|
else
|
||||||
info->charge_state = CHARGE;
|
info->charge_state = CHARGE;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define _LIBACPI_H_
|
#define _LIBACPI_H_
|
||||||
|
|
||||||
|
|
||||||
#define LIBACPI_VER "0.92"
|
#define LIBACPI_VER "0.93"
|
||||||
|
|
||||||
/* Here because we need it for definitions in this file . . . */
|
/* Here because we need it for definitions in this file . . . */
|
||||||
#define MAX_NAME 128
|
#define MAX_NAME 128
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH WMACPI 1 "August 15 2004"
|
.TH WMACPI 1 "July 13 2007"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
wmacpi \- Battery status monitor for systems supporting ACPI
|
wmacpi \- Battery status monitor for systems supporting ACPI
|
||||||
.SH NAME
|
.SH NAME
|
||||||
|
@ -27,13 +27,13 @@ sample rate ]
|
||||||
.RI -n
|
.RI -n
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
.RI -w
|
.RI -x
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
.RI -a
|
.RI -a
|
||||||
samples ]
|
samples ]
|
||||||
[
|
[
|
||||||
.RI -V
|
.RI -v
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
.RI -h
|
.RI -h
|
||||||
|
@ -44,10 +44,10 @@ samples ]
|
||||||
.RI -a
|
.RI -a
|
||||||
samples ]
|
samples ]
|
||||||
[
|
[
|
||||||
.RI -v
|
.RI -V
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
.RI -V
|
.RI -v
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
.RI -b
|
.RI -b
|
||||||
|
@ -85,24 +85,24 @@ battery to reach full charge if the batteries are charging.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.B wmacpi
|
.B wmacpi
|
||||||
.TP
|
.TP
|
||||||
.B \-c percentage
|
.B \-c, --critical=percentage
|
||||||
Set critical low alarm at <value>% (default: 10%).
|
Set critical low alarm at <percentage>% (default: 10%).
|
||||||
.TP
|
.TP
|
||||||
.B \-d display
|
.B \-d, --display=display
|
||||||
Set the X display to open the window on.
|
Set the X display to open the window on.
|
||||||
.TP
|
.TP
|
||||||
.B \-m battery number
|
.B \-m, --battery=battery number
|
||||||
Set the battery to monitor initially.
|
Set the battery to monitor initially.
|
||||||
.TP
|
.TP
|
||||||
.B \-s sample rate
|
.B \-s, --sample-rate=sample rate
|
||||||
Set the rate at which to sample the ACPI data, in number of times per
|
Set the rate at which to sample the ACPI data, in number of times per
|
||||||
minute. Minimum is 1, ie once a minute, default is 20, maximum is 600.
|
minute. Minimum is 1, ie once a minute, default is 20, maximum is 600.
|
||||||
.TP
|
.TP
|
||||||
.B \-n
|
.B \-n, --no-blink
|
||||||
Disable blinking power glyph when charging. Note that it still blinks when
|
Disable blinking power glyph when charging. Note that it still blinks when
|
||||||
the battery reports its capacity state as critical.
|
the battery reports its capacity state as critical.
|
||||||
.TP
|
.TP
|
||||||
.B \-f
|
.B \-f, --force-capacity-mode
|
||||||
Force the use of capacity mode for calculating time remaining. By defalt
|
Force the use of capacity mode for calculating time remaining. By defalt
|
||||||
.B wmacpi
|
.B wmacpi
|
||||||
will use the reported values of remaining capacity and present rate to
|
will use the reported values of remaining capacity and present rate to
|
||||||
|
@ -113,29 +113,27 @@ of calculation generally underreports the time remaining. This mode
|
||||||
works around certain buggy ACPI BIOSes that fail to report the current
|
works around certain buggy ACPI BIOSes that fail to report the current
|
||||||
rate.
|
rate.
|
||||||
.TP
|
.TP
|
||||||
.B \-w
|
.B \-x, --cmdline
|
||||||
Run wmacpi in command line mode - this operates identically to
|
Run wmacpi in command line mode - this operates identically to
|
||||||
.B acpi
|
.B acpi
|
||||||
..
|
..
|
||||||
.TP
|
.TP
|
||||||
.B \-a num
|
.B \-a, --samples=samples
|
||||||
Average the time remaining over num samples. This greatly improves the
|
Average the time remaining over num samples. This greatly improves the
|
||||||
accuracy of the reported time remaining.
|
accuracy of the reported time remaining.
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-V, --verbosity=num
|
||||||
Increase the verbosity of the program. Can be used more than once -
|
Increase the verbosity of the program. Setting this to 1 will print extra
|
||||||
each successive use increases the verbosity.
|
error information; 2 will produce informational output; 3 will produce
|
||||||
|
copious debugging output.
|
||||||
.TP
|
.TP
|
||||||
.B \-V
|
.B \-v, --version
|
||||||
Print the version information.
|
Print the version information.
|
||||||
.TP
|
.TP
|
||||||
.B \-b
|
.B \-r, --no-scroll
|
||||||
Enable blinking of the power glyph when charging the batteries.
|
|
||||||
.TP
|
|
||||||
.B \-r
|
|
||||||
Disable scrolling message.
|
Disable scrolling message.
|
||||||
.TP
|
.TP
|
||||||
.B \-h
|
.B \-h, --help
|
||||||
Display help.
|
Display help.
|
||||||
.TP
|
.TP
|
||||||
.B acpi
|
.B acpi
|
||||||
|
@ -144,11 +142,15 @@ Display help.
|
||||||
Average the time remaining over num samples. This greatly improves the
|
Average the time remaining over num samples. This greatly improves the
|
||||||
accuracy of the reported time remaining.
|
accuracy of the reported time remaining.
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
|
||||||
Increase the verbosity of the program, as for
|
|
||||||
.B wmacpi
|
|
||||||
.TP
|
|
||||||
.B \-V
|
.B \-V
|
||||||
|
Increase the verbosity of the program. If repeated, the result is the
|
||||||
|
same as setting
|
||||||
|
.B \--verbosity
|
||||||
|
for
|
||||||
|
.B wmacpi
|
||||||
|
to the number of repetitions.
|
||||||
|
.TP
|
||||||
|
.B \-v
|
||||||
Print the version information.
|
Print the version information.
|
||||||
.TP
|
.TP
|
||||||
.B \-h
|
.B \-h
|
||||||
|
@ -162,4 +164,4 @@ This manual page was originally written by Simon Richter
|
||||||
<sjr@debian.org> for the Debian GNU/Linux system, and then updated by
|
<sjr@debian.org> for the Debian GNU/Linux system, and then updated by
|
||||||
Simon Fowler.
|
Simon Fowler.
|
||||||
.br
|
.br
|
||||||
Last modification by Simon Fowler <simon@himi.org>, 2007-01-10.
|
Last modification by Simon Fowler <simon@himi.org>, 2007-07-13.
|
||||||
|
|
201
wmacpi/wmacpi.c
201
wmacpi/wmacpi.c
|
@ -24,7 +24,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <getopt.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@
|
||||||
#include "libacpi.h"
|
#include "libacpi.h"
|
||||||
#include "wmacpi.h"
|
#include "wmacpi.h"
|
||||||
|
|
||||||
#define WMACPI_VER "2.1"
|
#define WMACPI_VER "2.2rc1"
|
||||||
|
|
||||||
/* main pixmap */
|
/* main pixmap */
|
||||||
#ifdef LOW_COLOR
|
#ifdef LOW_COLOR
|
||||||
|
@ -136,13 +135,9 @@ static void redraw_window(void)
|
||||||
|
|
||||||
static void new_window(char *display, char *name, int argc, char **argv)
|
static void new_window(char *display, char *name, int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
XSizeHints *hints;
|
||||||
|
|
||||||
/* Initialise the dockapp window and appicon */
|
/* Initialise the dockapp window and appicon */
|
||||||
/* we don't want libdocapp to parse the command line, but we have to
|
|
||||||
initialize it with DAParseArguments, so we set argc to 1 */
|
|
||||||
DAParseArguments(1, argv, NULL, 0,
|
|
||||||
"help option done", "version option done");
|
|
||||||
/* deprecated
|
|
||||||
DAInitialize(display, name, 64, 64, argc, argv); */
|
|
||||||
DAOpenDisplay(display, argc, argv);
|
DAOpenDisplay(display, argc, argv);
|
||||||
DACreateIcon(name, 64, 64, argc, argv);
|
DACreateIcon(name, 64, 64, argc, argv);
|
||||||
dockapp->display = DADisplay;
|
dockapp->display = DADisplay;
|
||||||
|
@ -166,6 +161,20 @@ static void new_window(char *display, char *name, int argc, char **argv)
|
||||||
pfatal("FATAL: Cannot create text scroll pixmap!\n");
|
pfatal("FATAL: Cannot create text scroll pixmap!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* force the window to stay this size - otherwise the user could
|
||||||
|
* resize us and see our panties^Wmaster pixmap . . . */
|
||||||
|
hints = XAllocSizeHints();
|
||||||
|
if(hints) {
|
||||||
|
hints->flags |= PMinSize | PMaxSize;
|
||||||
|
hints->min_width = 64;
|
||||||
|
hints->max_width = 64;
|
||||||
|
hints->min_height = 64;
|
||||||
|
hints->max_height = 64;
|
||||||
|
XSetWMNormalHints(dockapp->display, dockapp->win, hints);
|
||||||
|
XFree(hints);
|
||||||
|
}
|
||||||
|
|
||||||
DAShow();
|
DAShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +428,7 @@ static void blink_battery_glyph(void)
|
||||||
|
|
||||||
static void set_power_panel(global_t *globals)
|
static void set_power_panel(global_t *globals)
|
||||||
{
|
{
|
||||||
enum panel_states power = PS_NULL;
|
static enum panel_states power = PS_NULL;
|
||||||
battery_t *binfo = globals->binfo;
|
battery_t *binfo = globals->binfo;
|
||||||
adapter_t *ap = &globals->adapter;
|
adapter_t *ap = &globals->adapter;
|
||||||
|
|
||||||
|
@ -568,32 +577,7 @@ void set_batt_id_area(int bno)
|
||||||
copy_xpm_area(sx, sy, w, h, dx, dy);
|
copy_xpm_area(sx, sy, w, h, dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usage(char *name)
|
#define VERSION "wmacpi version " WMACPI_VER "\nUsing libacpi version " LIBACPI_VER
|
||||||
{
|
|
||||||
printf("%s - help\t\t[simon@dreamcraft.com.au]\n\n"
|
|
||||||
"-d display\t\tdisplay on remote display <display>\n"
|
|
||||||
"-b\t\t\tenable blinking of various UI elements\n"
|
|
||||||
"-r\t\t\tdisable scrolling message\n"
|
|
||||||
"-c value\t\tset critical low alarm at <value> percent\n"
|
|
||||||
"\t\t\t(default: 10 percent)\n"
|
|
||||||
"-m <battery number>\tbattery number to monitor\n"
|
|
||||||
"-s <sample rate>\tnumber of times per minute to sample battery information\n"
|
|
||||||
"\t\t\tdefault 20 (once every three seconds)\n"
|
|
||||||
"-f\t\t\tforce the use of capacity mode for calculating time remaining\n"
|
|
||||||
"-n\t\t\tdo not blink\n"
|
|
||||||
"-w\t\t\trun in command line mode\n"
|
|
||||||
"-a <samples>\t\tsamples to average over (cli mode only)\n"
|
|
||||||
"-v\t\t\tincrease verbosity\n"
|
|
||||||
"\t\t\tcan be used multiple times to increase verbosity further\n"
|
|
||||||
"-h\t\t\tdisplay this help\n",
|
|
||||||
name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_version(void)
|
|
||||||
{
|
|
||||||
printf("wmacpi version %s\n", WMACPI_VER);
|
|
||||||
printf(" Using libacpi version %s\n", LIBACPI_VER);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cli_wmacpi(global_t *globals, int samples)
|
void cli_wmacpi(global_t *globals, int samples)
|
||||||
{
|
{
|
||||||
|
@ -647,12 +631,11 @@ void cli_wmacpi(global_t *globals, int samples)
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *display = NULL;
|
char *display = NULL;
|
||||||
int ch;
|
|
||||||
int sample_count = 0;
|
int sample_count = 0;
|
||||||
int batt_reinit, ac_reinit;
|
int batt_reinit, ac_reinit;
|
||||||
int batt_count = 0;
|
int batt_count = 0;
|
||||||
int ac_count = 0;
|
int ac_count = 0;
|
||||||
int cli = 0, samples = 1;
|
int cli = 0, samples = 1, critical = 10;
|
||||||
int samplerate = 20;
|
int samplerate = 20;
|
||||||
int sleep_rate = 10;
|
int sleep_rate = 10;
|
||||||
int sleep_time = 1000000/sleep_rate;
|
int sleep_time = 1000000/sleep_rate;
|
||||||
|
@ -662,6 +645,19 @@ int main(int argc, char **argv)
|
||||||
battery_t *binfo;
|
battery_t *binfo;
|
||||||
global_t *globals;
|
global_t *globals;
|
||||||
|
|
||||||
|
DAProgramOption options[] = {
|
||||||
|
{"-r", "--no-scroll", "disable scrolling message", DONone, False, {NULL}},
|
||||||
|
{"-n", "--no-blink", "disable blinking of various UI elements", DONone, False, {NULL}},
|
||||||
|
{"-x", "--cmdline", "run in command line mode", DONone, False, {NULL}},
|
||||||
|
{"-f", "--force-capacity-mode", "force the use of capacity mode for calculating time remaining", DONone, False, {NULL}},
|
||||||
|
{"-d", "--display", "display or remote display", DOString, False, {&display}},
|
||||||
|
{"-c", "--critical", "set critical low alarm at <number> percent\n (default: 10 percent)", DONatural, False, {&critical}},
|
||||||
|
{"-m", "--battery", "battery number to monitor", DONatural, False, {&battery_no}},
|
||||||
|
{"-s", "--sample-rate", "number of times per minute to sample battery information\n default 20 (once every three seconds)", DONatural, False, {&samplerate}},
|
||||||
|
{"-V", "--verbosity", "Set verbosity", DONatural, False, {&verbosity}},
|
||||||
|
{"-a", "--samples", "number of samples to average over (cli mode only)", DONatural, False, {&samples}},
|
||||||
|
};
|
||||||
|
|
||||||
dockapp = calloc(1, sizeof(struct dockapp));
|
dockapp = calloc(1, sizeof(struct dockapp));
|
||||||
globals = calloc(1, sizeof(global_t));
|
globals = calloc(1, sizeof(global_t));
|
||||||
|
|
||||||
|
@ -682,84 +678,37 @@ int main(int argc, char **argv)
|
||||||
* are available /before/ we can decide if the battery we want to
|
* are available /before/ we can decide if the battery we want to
|
||||||
* monitor is available. */
|
* monitor is available. */
|
||||||
/* parse command-line options */
|
/* parse command-line options */
|
||||||
while ((ch = getopt(argc, argv, "d:c:m:s:a:fhnwbrvV")) != EOF) {
|
DAParseArguments(argc, argv, options, 10,
|
||||||
switch (ch) {
|
"A battery monitor dockapp for ACPI based systems",
|
||||||
case 'c':
|
VERSION);
|
||||||
if (optarg) {
|
|
||||||
globals->crit_level = atoi(optarg);
|
if (options[0].used)
|
||||||
if ((globals->crit_level < 0) || (globals->crit_level > 100)) {
|
dockapp->scroll = 0;
|
||||||
fprintf(stderr, "Please use values between 0 and 100%%\n");
|
if (options[1].used)
|
||||||
globals->crit_level = 10;
|
dockapp->blink = 0;
|
||||||
fprintf(stderr, "Using default value of 10%%\n");
|
if (options[2].used)
|
||||||
}
|
cli = 1;
|
||||||
}
|
if (options[3].used) {
|
||||||
break;
|
rt_mode = RT_CAP;
|
||||||
case 'd':
|
rt_forced = 1;
|
||||||
if (optarg)
|
|
||||||
display = strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
if (optarg) {
|
|
||||||
battery_no = atoi(optarg);
|
|
||||||
if (battery_no >= MAXBATT) {
|
|
||||||
fprintf(stderr, "Please specify a battery number below %d\n",
|
|
||||||
MAXBATT);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
pinfo("Monitoring battery %d\n", battery_no);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
if (optarg) {
|
|
||||||
samplerate = atoi(optarg);
|
|
||||||
if (samplerate == 0) samplerate = 1;
|
|
||||||
if (samplerate > 600) samplerate = 600;
|
|
||||||
} else {
|
|
||||||
usage(argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
rt_mode = RT_CAP;
|
|
||||||
rt_forced = 1;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
usage(argv[0]);
|
|
||||||
return 0;
|
|
||||||
case 'v':
|
|
||||||
verbosity++;
|
|
||||||
break;
|
|
||||||
case 'V':
|
|
||||||
print_version();
|
|
||||||
return 0;
|
|
||||||
case 'n':
|
|
||||||
dockapp->blink = 0;
|
|
||||||
break;
|
|
||||||
case 'w':
|
|
||||||
cli = 1;
|
|
||||||
break;
|
|
||||||
case 'a':
|
|
||||||
if(optarg != NULL) {
|
|
||||||
samples = atoi(optarg);
|
|
||||||
if(samples > 1000 || samples <= 0) {
|
|
||||||
fprintf(stderr, "Please specify a reasonable number of samples\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'b':
|
|
||||||
dockapp->blink = 1;
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
dockapp->scroll = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage(argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (samplerate == 0) samplerate = 1;
|
||||||
|
if (samplerate > 600) samplerate = 600;
|
||||||
|
|
||||||
|
if (critical > 100) {
|
||||||
|
fprintf(stderr, "Please use values between 0 and 100%%\n");
|
||||||
|
fprintf(stderr, "Using default value of 10%%\n");
|
||||||
|
critical = 10;
|
||||||
|
}
|
||||||
|
globals->crit_level = critical;
|
||||||
|
|
||||||
|
if (battery_no >= MAXBATT) {
|
||||||
|
fprintf(stderr, "Please specify a battery number below %d\n", MAXBATT);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
pinfo("Monitoring battery %d\n", battery_no);
|
||||||
|
|
||||||
if (power_init(globals))
|
if (power_init(globals))
|
||||||
/* power_init functions handle printing error messages */
|
/* power_init functions handle printing error messages */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -805,6 +754,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* main loop */
|
/* main loop */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
Atom atom;
|
||||||
|
Atom wmdelwin;
|
||||||
XEvent event;
|
XEvent event;
|
||||||
while (XPending(dockapp->display)) {
|
while (XPending(dockapp->display)) {
|
||||||
XNextEvent(dockapp->display, &event);
|
XNextEvent(dockapp->display, &event);
|
||||||
|
@ -831,6 +782,28 @@ int main(int argc, char **argv)
|
||||||
set_batt_id_area(battery_no);
|
set_batt_id_area(battery_no);
|
||||||
dockapp->update = 1;
|
dockapp->update = 1;
|
||||||
break;
|
break;
|
||||||
|
case ClientMessage:
|
||||||
|
/* what /is/ this crap?
|
||||||
|
* Turns out that libdockapp adds the WM_DELETE_WINDOW atom to
|
||||||
|
* the WM_PROTOCOLS property for the window, which means that
|
||||||
|
* rather than get a simple DestroyNotify message, we get a
|
||||||
|
* nice little message from the WM saying "hey, can you delete
|
||||||
|
* yourself, pretty please?". So, when running as a window
|
||||||
|
* rather than an icon, we're impossible to kill in a friendly
|
||||||
|
* manner, because we're expecting to die from a DestroyNotify
|
||||||
|
* and thus blithely ignoring the WM knocking on our window
|
||||||
|
* border . . .
|
||||||
|
*
|
||||||
|
* This simply checks for that scenario - it may fail oddly if
|
||||||
|
* something else comes to us via a WM_PROTOCOLS ClientMessage
|
||||||
|
* event, but I suspect it's not going to be an issue. */
|
||||||
|
wmdelwin = XInternAtom(dockapp->display, "WM_DELETE_WINDOW", 1);
|
||||||
|
atom = event.xclient.data.l[0];
|
||||||
|
if (atom == wmdelwin) {
|
||||||
|
XCloseDisplay(dockapp->display);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue