wmacpi: Bump to version 1.99.
Source obtained from http://sourceforge.net/projects/wmacpi/files/. 2003 November 23 1.99 Finally claimed the wmacpi name as my own . . . Renamed wmacpi-ng and acpi-ng, renamed the header files, fixed up the makefile. For the Debian package, also made compilation of the command line tool optional, defaulting to not building it. This is because after the renaming, my acpi clashes with the acpi package that's already in Debian. The command line functionality is now accessible via the -w option to wmacpi. This is wmacpi 1.99, so that I can have a release packaged and in Debian before going to 2.0, so that any bugs that are left can be found by all the extra users.
This commit is contained in:
parent
310714058f
commit
6961aed640
|
@ -1,3 +1,6 @@
|
||||||
|
Simon Fowler <simon@dreamcraft.com.au>
|
||||||
|
Complete rewriting of the code from wmacpi-1.34.
|
||||||
|
|
||||||
timecop
|
timecop
|
||||||
timecop@japan.co.jp
|
timecop@japan.co.jp
|
||||||
all the code
|
all the code
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
2003 November 23 1.99
|
||||||
|
Finally claimed the wmacpi name as my own . . .
|
||||||
|
|
||||||
|
Renamed wmacpi-ng and acpi-ng, renamed the header files, fixed up
|
||||||
|
the makefile.
|
||||||
|
|
||||||
|
For the Debian package, also made compilation of the command line
|
||||||
|
tool optional, defaulting to not building it. This is because
|
||||||
|
after the renaming, my acpi clashes with the acpi package that's
|
||||||
|
already in Debian. The command line functionality is now
|
||||||
|
accessible via the -w option to wmacpi.
|
||||||
|
|
||||||
|
This is wmacpi 1.99, so that I can have a release packaged and in
|
||||||
|
Debian before going to 2.0, so that any bugs that are left can be
|
||||||
|
found by all the extra users.
|
||||||
|
|
||||||
2003 September 26 0.99
|
2003 September 26 0.99
|
||||||
Fix the last of the old wmacpi code oddities (specifically, the
|
Fix the last of the old wmacpi code oddities (specifically, the
|
||||||
APMInfo struct, which was a completely inappropriate name given we
|
APMInfo struct, which was a completely inappropriate name given we
|
||||||
|
|
|
@ -1,10 +1,20 @@
|
||||||
to install:
|
The basic install is very simple: make, make install.
|
||||||
|
|
||||||
* vi Makefile
|
You can change the default install prefix (/usr/local) by specifying
|
||||||
* change what you want, according to instructions, save Makefile
|
it in the make install command, eg: make install PREFIX=/usr
|
||||||
* make
|
|
||||||
* copy wmacpi somewhere useful
|
To build the command line tool, either uncomment the BUILD_CLI=1 line
|
||||||
* dance
|
in the Makefile, or specify BUILD_CLI=1 on the make command line. ie,
|
||||||
* <somewhere useful>/wmacpi &
|
make BUILD_CLI=1
|
||||||
* phear
|
make install BUILD_CLI=1
|
||||||
(if it doesn't work, skip the phear step)
|
|
||||||
|
No uninstall is supported, but isn't exactly difficult to delete all
|
||||||
|
the files by hand . . .
|
||||||
|
|
||||||
|
Files installed (paths relative to PREFIX):
|
||||||
|
bin/wmacpi
|
||||||
|
bin/acpi
|
||||||
|
man/man1/wmacpi.1
|
||||||
|
man/man1/acpi.1
|
||||||
|
|
||||||
|
Simon Fowler <simon@dreamcraft.com.au>, 2003-11-23
|
|
@ -3,21 +3,28 @@
|
||||||
|
|
||||||
OPT := -O2
|
OPT := -O2
|
||||||
|
|
||||||
|
# uncomment this to build the command line acpi tool
|
||||||
|
#BUILD_CLI = 1
|
||||||
|
|
||||||
# uncomment this to make wmacpi use less system colors (looks uglier too)
|
# uncomment this to make wmacpi use less system colors (looks uglier too)
|
||||||
#OPT += -DLOW_COLOR
|
#OPT += -DLOW_COLOR
|
||||||
|
|
||||||
# debugging options (don't bother with these)
|
# debugging options (don't bother with these)
|
||||||
#OPT = -pg -g -DPRO -DACPI
|
#OPT = -pg -g
|
||||||
|
|
||||||
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
|
LDFLAGS := $(OPT) -L/usr/X11R6/lib -lX11 -lXpm -lXext
|
||||||
|
|
||||||
WMSRC := wmacpi-ng.c libacpi.c
|
WMSRC := wmacpi.c libacpi.c
|
||||||
CLSRC := acpi-ng.c libacpi.c
|
HEADERS := libacpi.h wmacpi.h
|
||||||
HEADERS := libacpi.h wmacpi-ng.h
|
targets := wmacpi
|
||||||
targets := wmacpi-ng acpi-ng
|
doc_targets := wmacpi.1
|
||||||
doc_targets := debian/wmacpi-ng.1 debian/acpi-ng.1
|
|
||||||
|
ifdef BUILD_CLI
|
||||||
|
targets += acpi
|
||||||
|
doc_targets += acpi.1
|
||||||
|
endif
|
||||||
|
|
||||||
PREFIX := /usr/local
|
PREFIX := /usr/local
|
||||||
|
|
||||||
|
@ -25,17 +32,23 @@ all: $(targets)
|
||||||
|
|
||||||
# build the list of object files
|
# build the list of object files
|
||||||
WMOBJ := $(patsubst %.c,%.o,$(filter %.c,$(WMSRC)))
|
WMOBJ := $(patsubst %.c,%.o,$(filter %.c,$(WMSRC)))
|
||||||
CLOBJ := $(patsubst %.c,%.o,$(filter %.c,$(CLSRC)))
|
|
||||||
|
|
||||||
# include per-file dependencies
|
# include per-file dependencies
|
||||||
include $(WMOBJ:.o=.d)
|
include $(WMOBJ:.o=.d)
|
||||||
|
|
||||||
|
wmacpi: $(WMOBJ)
|
||||||
|
$(CC) $(LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
# for the Debian package, we want to make building the command line tools
|
||||||
|
# optional. So, we hide all the necessary stuff here . . .
|
||||||
|
ifdef BUILD_CLI
|
||||||
|
CLSRC := acpi.c libacpi.c
|
||||||
|
CLOBJ := $(patsubst %.c,%.o,$(filter %.c,$(CLSRC)))
|
||||||
include $(CLOBJ:.o=.d)
|
include $(CLOBJ:.o=.d)
|
||||||
|
|
||||||
wmacpi-ng: $(WMOBJ)
|
acpi: $(CLOBJ)
|
||||||
$(CC) $(LDFLAGS) -o $@ $^
|
|
||||||
|
|
||||||
acpi-ng: $(CLOBJ)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $^
|
$(CC) $(LDFLAGS) -o $@ $^
|
||||||
|
endif
|
||||||
|
|
||||||
# build per-file dependencies - note that -MM may not be supported
|
# build per-file dependencies - note that -MM may not be supported
|
||||||
# in gcc versions older than 2.95.4, but most likely is.
|
# in gcc versions older than 2.95.4, but most likely is.
|
||||||
|
|
|
@ -5,60 +5,50 @@ Usage:
|
||||||
+-------------+
|
+-------------+
|
||||||
|battery graph| <- visual percentage battery remaining
|
|battery graph| <- visual percentage battery remaining
|
||||||
|[:][=] [100%]| <- [:] - on AC (blink when charging) [=] - on battery
|
|[:][=] [100%]| <- [:] - on AC (blink when charging) [=] - on battery
|
||||||
|[00:00] [///]| <- [00:00] time remaining [///] timer mode switch
|
|[00:00] [bX]| <- [00:00] time remaining [bX] battery being monitored.
|
||||||
|status area| <- messages scroll here
|
|status area| <- messages scroll here
|
||||||
+-------------+
|
+-------------+
|
||||||
|
|
||||||
see wmacpi -h for some command line switches
|
see wmacpi -h for some command line switches
|
||||||
|
|
||||||
Timer mode, available only when "on-battery", keeps track how long your laptop
|
**********************************************************************
|
||||||
has been away from AC power. Clicking the button toggles between timer and
|
|
||||||
standard "time remaining" mode.
|
|
||||||
|
|
||||||
******************************************************************************
|
wmacpi is a dockapp ACPI battery monitor for modern kernels (ie,
|
||||||
|
2.4.17 or later, and 2.6 kernels). Basically, it opens various files
|
||||||
|
under /proc/acpi, reads status information from them, and then
|
||||||
|
displays summaries.
|
||||||
|
|
||||||
Implementation of "ACPI" mode:
|
Version 1.99 and later provides full support for multiple
|
||||||
|
batteries. You can tell it to monitor a particular batter with the -m
|
||||||
|
option, which will display the percentage remaining and current status
|
||||||
|
message for that battery. The time remaining and AC/battery status are
|
||||||
|
global - the time remaining is calculated based on all batteries found
|
||||||
|
on the system. When charging, the time displayed is the time remaining
|
||||||
|
until the battery is fully charged - this only works sensibly if your
|
||||||
|
ACPI system is implemented properly (far, far too many laptops have
|
||||||
|
buggered ACPI implementations).
|
||||||
|
|
||||||
As far as I know, there aren't any tools available right now to process battery
|
The displayed time is averaged over 50 samples, each taken every three
|
||||||
statistics provided in /proc/power by ACPI stuff in 2.4.x kernels. This is my
|
seconds (by default). This greatly improves the accuracy of the
|
||||||
attempt to have a usable dockapp battery monitor for ACPI laptop systems.
|
numbers - on my laptop, the time remaining seems to be overstated by a
|
||||||
Since version 1.32 I've added some code to detect multiple batteries. However
|
good hour or so if you only sample once compared to fifty times.
|
||||||
it's not fully implemented yet, and while it will detect and enumerate
|
|
||||||
batteries, the statistics reported are for the first found battery.
|
|
||||||
* Your battery is "Control Method" type
|
|
||||||
* Your ACPI BIOS is supported by current version of ACPI in kernel
|
|
||||||
2.4.17 + intel patches
|
|
||||||
* You applied acpi subsystem patch version 20020214 (from intel.com)
|
|
||||||
|
|
||||||
If you are using kernels or ACPI version older than 2.4.17, keep using
|
Some ACPI implementations are stupid enough to block interrupts while
|
||||||
wmacpi 1.32. This version is only for the latest ACPI code.
|
reading status information from the battery over a slow bus - this
|
||||||
To use ACPI support, just follow "INSTALL" instructions. Makefile has been
|
means that on such b0rken laptops, running an ACPI battery monitor
|
||||||
updated to include -DACPI. If you don't have ACPI, you don't need this version
|
could affect interactivity. To provide a workaround for this, current
|
||||||
of wmacpi. Information below only applies to APM systems, without ACPI support.
|
versions of wmacpi supports setting the sample rate from the command
|
||||||
|
line. The default -s setting is 100, which translates to once every
|
||||||
|
three seconds. -s 10 will sample every 30 seconds, -s 1 every 300
|
||||||
|
seconds. -s 1000 will sample every 0.3 seconds - don't do that unless
|
||||||
|
you're just having fun . . .
|
||||||
|
|
||||||
Implementation of "APM" mode
|
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
|
||||||
|
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
|
||||||
|
this could have adverse effects.
|
||||||
|
|
||||||
This works on all machines that have a standard non-borked APM implementation.
|
Please report bugs to <simon@dreamcraft.com.au>.
|
||||||
For people with broken APM implementations, I added some stuff, which was
|
|
||||||
sent to me by Daniel Pittman <daniel@rimspace.net>, to compensate for some
|
|
||||||
of the stupidity. If you see dumb behaviour from wmapm, consider editing
|
|
||||||
wmapm.c and uncomment one, or both, of these lines (on lines 19 and 20):
|
|
||||||
|
|
||||||
#define RETARDED_APM if your bios thinks the battery is charging all the time
|
Simon Fowler, 2003-11-23.
|
||||||
when it's on AC power. What this will do is stop "charging" process as soon
|
|
||||||
as the battery reaches 100%.
|
|
||||||
|
|
||||||
#define STUPID_APM if your bios shows -1 minutes remaining when AC is plugged
|
|
||||||
in, or when battery is charging.
|
|
||||||
|
|
||||||
If your bios is even dumber than this, and you come up with another special
|
|
||||||
case that needs to be handled, feel free to #ifdef it under <badword>_APM and
|
|
||||||
send me a diff -u. I will include it in the next version. Any of these
|
|
||||||
changes would have to go into acquire_apm_info. Note, I changed format of
|
|
||||||
apminfo structure to get rid of redundancy - now there is only one power state
|
|
||||||
variable, which keeps track whether we are on AC, charging, battery, etc.
|
|
||||||
|
|
||||||
Note, all the *_APM stuff is untested - my laptop has a working BIOS :) If you
|
|
||||||
test this and it doesn't work as advertised, go ahead and send me a fix.
|
|
||||||
|
|
||||||
-timecop
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
2003 November 23 1.99
|
||||||
|
* Expand libacpi to handle everything else under
|
||||||
|
/proc/acpi. Basically, make it into a full ACPI reporting library.
|
||||||
|
|
||||||
|
* Make the command line tool a complete replacement for Grahame
|
||||||
|
Bowland's acpi tool, so that wmacpi won't conflict with it.
|
||||||
|
|
||||||
2003 July 6 0.50
|
2003 July 6 0.50
|
||||||
* Fix the non-deb installation - as it stands, it doesn't even try.
|
* Fix the non-deb installation - as it stands, it doesn't even try.
|
||||||
|
|
||||||
|
|
1
wmacpi/acpi.1
Normal file
1
wmacpi/acpi.1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.so man1/wmacpi.1
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include "libacpi.h"
|
#include "libacpi.h"
|
||||||
|
|
||||||
#define ACPI_NG_VER "0.99"
|
#define ACPI_VER "1.99"
|
||||||
|
|
||||||
global_t *globals;
|
global_t *globals;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void usage(char *name)
|
||||||
|
|
||||||
void print_version(void)
|
void print_version(void)
|
||||||
{
|
{
|
||||||
printf("acpi-ng version %s\n", ACPI_NG_VER);
|
printf("acpi version %s\n", ACPI_VER);
|
||||||
printf(" Using libacpi version %s\n", LIBACPI_VER);
|
printf(" Using libacpi version %s\n", LIBACPI_VER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
.so man1/wmacpi-ng.1
|
|
|
@ -1,21 +1,20 @@
|
||||||
Source: wmacpi-ng
|
Source: wmacpi
|
||||||
Section: x11
|
Section: x11
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Maintainer: Simon Fowler <simon@dreamcraft.com.au>
|
Maintainer: Simon Fowler <simon@dreamcraft.com.au>
|
||||||
Build-Depends: debhelper (>= 4), xlibs-dev
|
Build-Depends: debhelper (>= 4), xlibs-dev
|
||||||
Standards-Version: 3.5.9
|
Standards-Version: 3.5.9
|
||||||
|
|
||||||
Package: wmacpi-ng
|
Package: wmacpi
|
||||||
Architecture: i386
|
Architecture: i386
|
||||||
Depends: ${shlibs:Depends}
|
Depends: ${shlibs:Depends}
|
||||||
Recommends: wmaker
|
Recommends: wmaker
|
||||||
Description: An ACPI battery monitor for WindowMaker
|
Description: An ACPI battery monitor for WindowMaker
|
||||||
This is a battery monitor that uses ACPI to query the battery status. As
|
This is a battery monitor that uses ACPI to query the battery status.
|
||||||
the interface to ACPI changes rather often, this program usually only works
|
This version should work with all recent kernels, both 2.4 and 2.6.
|
||||||
with a very specific kernel version.
|
|
||||||
.
|
.
|
||||||
This is a reworked version to handle kernel version 2.4.21-rc2, done
|
This is a reworked version to handle modern kernels, done by Simon
|
||||||
by Simon Fowler <simon@dreamcraft.com.au>
|
Fowler <simon@dreamcraft.com.au>
|
||||||
.
|
.
|
||||||
Author: Tim Copperfield <timecop@japan.co.jp>
|
Author: Simon Fowler <simon@dreamcraft.com.au>
|
||||||
Homepage: http://www.ne.jp/asahi/linux/timecop/
|
Homepage: http://himi.org/wmacpi-ng/
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
?package(wmacpi-ng):needs=X11 section=Apps/System\
|
?package(wmacpi):needs=X11 section=Apps/System\
|
||||||
title="wmacpi-ng" command="/usr/bin/wmacpi-ng"
|
title="wmacpi" command="/usr/bin/wmacpi"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# Uncomment this to turn on verbose mode.
|
# Uncomment this to turn on verbose mode.
|
||||||
#export DH_VERBOSE=1
|
#export DH_VERBOSE=1
|
||||||
|
|
||||||
INSTALLDIR=$(CURDIR)/debian/wmacpi-ng
|
INSTALLDIR=$(CURDIR)/debian/wmacpi
|
||||||
|
|
||||||
# These are used for cross-compiling and for saving the configure script
|
# These are used for cross-compiling and for saving the configure script
|
||||||
# # from having to guess our platform (since we know it already)
|
# # from having to guess our platform (since we know it already)
|
||||||
|
@ -50,8 +50,8 @@ install: build
|
||||||
dh_installdirs
|
dh_installdirs
|
||||||
|
|
||||||
# Add here commands to install the package into debian/wmacpi.
|
# Add here commands to install the package into debian/wmacpi.
|
||||||
install -o root -g root -m 755 wmacpi-ng $(INSTALLDIR)/usr/bin/
|
install -o root -g root -m 755 wmacpi $(INSTALLDIR)/usr/bin/
|
||||||
install -o root -g root -m 755 acpi-ng $(INSTALLDIR)/usr/bin/
|
# install -o root -g root -m 755 acpi-ng $(INSTALLDIR)/usr/bin/
|
||||||
|
|
||||||
|
|
||||||
# Build architecture-independent files here.
|
# Build architecture-independent files here.
|
||||||
|
@ -70,7 +70,7 @@ binary-arch: build install
|
||||||
# dh_installpam
|
# dh_installpam
|
||||||
# dh_installinit
|
# dh_installinit
|
||||||
# dh_installcron
|
# dh_installcron
|
||||||
dh_installman debian/wmacpi-ng.1 debian/acpi-ng.1
|
dh_installman wmacpi.1 # acpi.1
|
||||||
# dh_installinfo
|
# dh_installinfo
|
||||||
# dh_undocumented
|
# dh_undocumented
|
||||||
dh_installchangelogs ChangeLog
|
dh_installchangelogs ChangeLog
|
||||||
|
|
|
@ -30,7 +30,7 @@ int init_batteries(void)
|
||||||
batt_count = 0;
|
batt_count = 0;
|
||||||
battdir = opendir("/proc/acpi/battery");
|
battdir = opendir("/proc/acpi/battery");
|
||||||
if (battdir == NULL) {
|
if (battdir == NULL) {
|
||||||
fprintf(stderr, "No batteries or ACPI not supported\n");
|
perr("No batteries or ACPI not supported\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
while ((batt = readdir(battdir))) {
|
while ((batt = readdir(battdir))) {
|
||||||
|
@ -68,13 +68,13 @@ int init_batteries(void)
|
||||||
"/proc/acpi/battery/%s/info", names[i]);
|
"/proc/acpi/battery/%s/info", names[i]);
|
||||||
snprintf(batteries[i].state_file, MAX_NAME,
|
snprintf(batteries[i].state_file, MAX_NAME,
|
||||||
"/proc/acpi/battery/%s/state", names[i]);
|
"/proc/acpi/battery/%s/state", names[i]);
|
||||||
eprint(0, "battery detected at %s\n", batteries[i].info_file);
|
pdebug("battery detected at %s\n", batteries[i].info_file);
|
||||||
fprintf(stderr, "found battery %s\n", names[i]);
|
pinfo("found battery %s\n", names[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tell user some info */
|
/* tell user some info */
|
||||||
eprint(0, "%d batteries detected\n", batt_count);
|
pdebug("%d batteries detected\n", batt_count);
|
||||||
fprintf(stderr, "libacpi: found %d batter%s\n", batt_count,
|
pinfo("libacpi: found %d batter%s\n", batt_count,
|
||||||
(batt_count == 1) ? "y" : "ies");
|
(batt_count == 1) ? "y" : "ies");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -92,7 +92,7 @@ int init_ac_adapters(void)
|
||||||
|
|
||||||
acdir = opendir("/proc/acpi/ac_adapter");
|
acdir = opendir("/proc/acpi/ac_adapter");
|
||||||
if (acdir == NULL) {
|
if (acdir == NULL) {
|
||||||
fprintf(stderr, "Unable to open /proc/acpi/ac_adapter -"
|
pfatal("Unable to open /proc/acpi/ac_adapter -"
|
||||||
" are you sure this system supports ACPI?\n");
|
" are you sure this system supports ACPI?\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -102,14 +102,14 @@ int init_ac_adapters(void)
|
||||||
|
|
||||||
if (!strncmp(".", name, 1) || !strncmp("..", name, 2))
|
if (!strncmp(".", name, 1) || !strncmp("..", name, 2))
|
||||||
continue;
|
continue;
|
||||||
fprintf(stderr, "found adapter %s\n", name);
|
pdebug("found adapter %s\n", name);
|
||||||
}
|
}
|
||||||
/* we /should/ only see one filename other than . and .. so
|
/* we /should/ only see one filename other than . and .. so
|
||||||
* we'll just use the last value name acquires . . . */
|
* we'll just use the last value name acquires . . . */
|
||||||
ap->name = strdup(name);
|
ap->name = strdup(name);
|
||||||
snprintf(ap->state_file, MAX_NAME, "/proc/acpi/ac_adapter/%s/state",
|
snprintf(ap->state_file, MAX_NAME, "/proc/acpi/ac_adapter/%s/state",
|
||||||
ap->name);
|
ap->name);
|
||||||
fprintf(stderr, "libacpi: found ac adapter %s\n", ap->name);
|
pinfo("libacpi: found ac adapter %s\n", ap->name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -123,16 +123,16 @@ int power_init(void)
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (!(acpi = fopen("/proc/acpi/info", "r"))) {
|
if (!(acpi = fopen("/proc/acpi/info", "r"))) {
|
||||||
fprintf(stderr, "This system does not support ACPI\n");
|
pfatal("This system does not support ACPI\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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 + 25, NULL, 10);
|
||||||
eprint(0, "ACPI version detected: %d\n", acpi_ver);
|
pinfo("ACPI version detected: %d\n", acpi_ver);
|
||||||
if (acpi_ver < 20020214) {
|
if (acpi_ver < 20020214) {
|
||||||
fprintf(stderr, "This version requires ACPI subsystem version 20020214\n");
|
pfatal("This version requires ACPI subsystem version 20020214\n");
|
||||||
fclose(acpi);
|
fclose(acpi);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ int get_battery_info(int batt_no)
|
||||||
|
|
||||||
if ((file = fopen(info->info_file, "r")) == NULL) {
|
if ((file = fopen(info->info_file, "r")) == NULL) {
|
||||||
/* this is cheating, but string concatenation should work . . . */
|
/* this is cheating, but string concatenation should work . . . */
|
||||||
fprintf(stderr, "Could not open %s:", info->info_file );
|
pfatal("Could not open %s:", info->info_file );
|
||||||
perror(NULL);
|
perror(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ int get_battery_info(int batt_no)
|
||||||
if ((strncmp(val, "yes", 3)) == 0) {
|
if ((strncmp(val, "yes", 3)) == 0) {
|
||||||
info->present = 1;
|
info->present = 1;
|
||||||
} else {
|
} else {
|
||||||
eprint(0, "Battery %s not present\n", info->name);
|
pinfo("Battery %s not present\n", info->name);
|
||||||
info->present = 0;
|
info->present = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ int get_battery_info(int batt_no)
|
||||||
|
|
||||||
|
|
||||||
if ((file = fopen(info->state_file, "r")) == NULL) {
|
if ((file = fopen(info->state_file, "r")) == NULL) {
|
||||||
fprintf(stderr, "Could not open %s:", info->state_file );
|
perr("Could not open %s:", info->state_file );
|
||||||
perror(NULL);
|
perror(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ int get_battery_info(int batt_no)
|
||||||
info->present = 1;
|
info->present = 1;
|
||||||
} else {
|
} else {
|
||||||
info->present = 0;
|
info->present = 0;
|
||||||
eprint(1, "Battery %s no longer present\n", info->name);
|
perr("Battery %s no longer present\n", info->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,13 +341,13 @@ static int calc_remaining_percentage(int batt)
|
||||||
|
|
||||||
/* we use -1 to indicate that the value is unknown . . . */
|
/* we use -1 to indicate that the value is unknown . . . */
|
||||||
if (rcap < 0) {
|
if (rcap < 0) {
|
||||||
eprint(0, "unknown percentage value\n");
|
perr("unknown percentage value\n");
|
||||||
retval = -1;
|
retval = -1;
|
||||||
} else {
|
} else {
|
||||||
if (lfcap <= 0)
|
if (lfcap <= 0)
|
||||||
lfcap = 1;
|
lfcap = 1;
|
||||||
retval = (int)((rcap/lfcap) * 100.0);
|
retval = (int)((rcap/lfcap) * 100.0);
|
||||||
eprint(0, "percent: %d\n", retval);
|
pdebug("percent: %d\n", retval);
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ static int calc_charge_time(int batt)
|
||||||
|
|
||||||
if (binfo->charge_state == CHARGE) {
|
if (binfo->charge_state == CHARGE) {
|
||||||
if (binfo->present_rate == -1) {
|
if (binfo->present_rate == -1) {
|
||||||
eprint(0, "unknown present rate\n");
|
perr("unknown present rate\n");
|
||||||
charge_time = -1;
|
charge_time = -1;
|
||||||
} else {
|
} else {
|
||||||
lfcap = (float)binfo->last_full_cap;
|
lfcap = (float)binfo->last_full_cap;
|
||||||
|
@ -424,7 +424,7 @@ void acquire_batt_info(int batt)
|
||||||
* check if we're at a critical battery level, and calculate
|
* check if we're at a critical battery level, and calculate
|
||||||
* other interesting stuff . . . */
|
* other interesting stuff . . . */
|
||||||
if (binfo->capacity_state == CRITICAL) {
|
if (binfo->capacity_state == CRITICAL) {
|
||||||
eprint(1, "Received critical battery status");
|
pinfo("Received critical battery status");
|
||||||
ap->power = HARD_CRIT;
|
ap->power = HARD_CRIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ void acquire_global_info(void)
|
||||||
if(rtime <= 0)
|
if(rtime <= 0)
|
||||||
rtime = 0;
|
rtime = 0;
|
||||||
out:
|
out:
|
||||||
eprint(0, "time rem: %d\n", rtime);
|
pdebug("time rem: %d\n", rtime);
|
||||||
globals->rtime = rtime;
|
globals->rtime = rtime;
|
||||||
|
|
||||||
/* get the power status.
|
/* get the power status.
|
||||||
|
|
|
@ -92,28 +92,35 @@ typedef struct {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To provide a convenient debugging function . . .
|
* To provide a convenient debugging function . . .
|
||||||
|
*
|
||||||
|
* It's a macro because I'm too lazy to deal with varargs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int verbosity = 0;
|
static int verbosity = 0;
|
||||||
|
|
||||||
#define eprint(level, fmt, arg...) \
|
#define pdebug(fmt, arg...) \
|
||||||
do { \
|
do { \
|
||||||
if (level > verbosity) { \
|
if (verbosity > 2) \
|
||||||
switch (level) { \
|
fprintf(stderr, fmt, ##arg); \
|
||||||
case 0: \
|
|
||||||
break; \
|
|
||||||
case 1: \
|
|
||||||
fprintf(stderr, fmt, ##arg); \
|
|
||||||
break; \
|
|
||||||
default: \
|
|
||||||
fprintf(stderr, "%s: " fmt, __FUNCTION__, ##arg); \
|
|
||||||
fprintf(stderr, "\n"); \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* since these /are/ needed here . . . */
|
#define pinfo(fmt, arg...) \
|
||||||
|
do { \
|
||||||
|
if (verbosity > 1) \
|
||||||
|
fprintf(stderr, fmt, ##arg); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define perr(fmt, arg...) \
|
||||||
|
do { \
|
||||||
|
if (verbosity > 0) \
|
||||||
|
fprintf(stderr, fmt, ##arg); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define pfatal(fmt, arg...) \
|
||||||
|
fprintf(stderr, fmt, ##arg) \
|
||||||
|
|
||||||
|
|
||||||
|
/* Since these /are/ needed here . . . */
|
||||||
battery_t batteries[MAXBATT];
|
battery_t batteries[MAXBATT];
|
||||||
int batt_count;
|
int batt_count;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
.TH WMACPI-NG 1 "July 11, 2003"
|
.TH WMACPI-NG 1 "July 11, 2003"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
wmacpi-ng \- Battery status monitor for systems supporting ACPI
|
wmacpi \- Battery status monitor for systems supporting ACPI
|
||||||
.SH NAME
|
.SH NAME
|
||||||
acpi-ng \- Query battery status for systems supporting ACPI
|
acpi \- Query battery status for systems supporting ACPI
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B wmacpi-ng
|
.B wmacpi
|
||||||
[
|
|
||||||
.RI -b
|
|
||||||
]
|
|
||||||
[
|
[
|
||||||
.RI -c
|
.RI -c
|
||||||
value ]
|
value ]
|
||||||
|
@ -27,13 +24,19 @@ sample rate ]
|
||||||
.RI -n
|
.RI -n
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
.RI -w
|
||||||
|
]
|
||||||
|
[
|
||||||
|
.RI -a
|
||||||
|
samples ]
|
||||||
|
[
|
||||||
.RI -V
|
.RI -V
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
.RI -h
|
.RI -h
|
||||||
]
|
]
|
||||||
.PP
|
.PP
|
||||||
.B acpi-ng
|
.B acpi
|
||||||
[
|
[
|
||||||
.RI -a
|
.RI -a
|
||||||
samples ]
|
samples ]
|
||||||
|
@ -48,10 +51,10 @@ samples ]
|
||||||
]
|
]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
This manual page documents briefly the
|
This manual page documents briefly the
|
||||||
.B wmacpi-ng
|
.B wmacpi
|
||||||
command.
|
command.
|
||||||
.PP
|
.PP
|
||||||
.B wmacpi-ng
|
.B wmacpi
|
||||||
is a program that displays the current battery status in a WindowMaker
|
is a program that displays the current battery status in a WindowMaker
|
||||||
dock app, on systems that support Intel's Advanced Configuration and
|
dock app, on systems that support Intel's Advanced Configuration and
|
||||||
Power Interface specification (ACPI).
|
Power Interface specification (ACPI).
|
||||||
|
@ -65,16 +68,13 @@ and a scrolling message with some hopefully useful information.
|
||||||
Clicking on the window cycles through the batteries that the ACPI
|
Clicking on the window cycles through the batteries that the ACPI
|
||||||
system knows about.
|
system knows about.
|
||||||
.PP
|
.PP
|
||||||
.B acpi-ng
|
.B acpi
|
||||||
queries the battery status from the command line. It prints the power
|
queries the battery status from the command line. It prints the power
|
||||||
status, the percentage remaining for each battery found, and the time
|
status, the percentage remaining for each battery found, and the time
|
||||||
remaining if the system is on battery, or the time remaining for each
|
remaining if the system is on battery, or the time remaining for each
|
||||||
battery to reach full charge if the batteries are charging.
|
battery to reach full charge if the batteries are charging.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.B wmacpi-ng
|
.B wmacpi
|
||||||
.TP
|
|
||||||
.B \-b
|
|
||||||
Make noise when battery is critical low (beep).
|
|
||||||
.TP
|
.TP
|
||||||
.B \-c percentage
|
.B \-c percentage
|
||||||
Set critical low alarm at <value>% (default: 10%).
|
Set critical low alarm at <value>% (default: 10%).
|
||||||
|
@ -94,6 +94,15 @@ translates to once every three seconds. 10 gives once every 30 seconds,
|
||||||
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 \-w
|
||||||
|
Run wmacpi in command line mode - this operates identically to
|
||||||
|
.B acpi
|
||||||
|
..
|
||||||
|
.TP
|
||||||
|
.B \-a num
|
||||||
|
Average the time remaining over num samples. This greatly improves the
|
||||||
|
accuracy of the reported time remaining.
|
||||||
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
Increase the verbosity of the program. Can be used more than once -
|
Increase the verbosity of the program. Can be used more than once -
|
||||||
each successive use increases the verbosity.
|
each successive use increases the verbosity.
|
||||||
|
@ -104,7 +113,7 @@ Print the version information.
|
||||||
.B \-h
|
.B \-h
|
||||||
Display help.
|
Display help.
|
||||||
.TP
|
.TP
|
||||||
.B acpi-ng
|
.B acpi
|
||||||
.TP
|
.TP
|
||||||
.B \-a num
|
.B \-a num
|
||||||
Average the time remaining over num samples. This greatly improves the
|
Average the time remaining over num samples. This greatly improves the
|
||||||
|
@ -112,7 +121,7 @@ accuracy of the reported time remaining.
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
Increase the verbosity of the program, as for
|
Increase the verbosity of the program, as for
|
||||||
.B wmacpi-ng
|
.B wmacpi
|
||||||
.TP
|
.TP
|
||||||
.B \-V
|
.B \-V
|
||||||
Print the version information.
|
Print the version information.
|
||||||
|
@ -125,16 +134,11 @@ Display help.
|
||||||
.br
|
.br
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
.B wmacpi
|
.B wmacpi
|
||||||
as written by Tim Copperfield <timecop@japan.co.jp>.
|
was originally written by Tim Copperfield <timecop@japan.co.jp>, then
|
||||||
.B wmacpi-ng
|
completely rewritten after 1.34 by Simon Fowler <simon@dreamcraft.com.au>.
|
||||||
is a reworking of
|
|
||||||
.B wmacpi 1.34
|
|
||||||
to support recent kernel versions, performed by Simon Fowler
|
|
||||||
<simon@dreamcraft.com.au>.
|
|
||||||
.PP
|
.PP
|
||||||
This manual page was originally written by Simon Richter
|
This manual page was originally written by Simon Richter
|
||||||
<sjr@debian.org> for the Debian GNU/Linux system, and then updated for
|
<sjr@debian.org> for the Debian GNU/Linux system, and then updated by
|
||||||
.B wmacpi-ng
|
Simon Fowler.
|
||||||
by Simon Fowler.
|
|
||||||
.br
|
.br
|
||||||
Last modification by Simon Fowler <simon@dreamcraft.com.au>, 2003-07-11.
|
Last modification by Simon Fowler <simon@dreamcraft.com.au>, 2003-11-23.
|
|
@ -33,9 +33,9 @@
|
||||||
#include <X11/xpm.h>
|
#include <X11/xpm.h>
|
||||||
|
|
||||||
#include "libacpi.h"
|
#include "libacpi.h"
|
||||||
#include "wmacpi-ng.h"
|
#include "wmacpi.h"
|
||||||
|
|
||||||
#define WMACPI_NG_VER "0.99"
|
#define WMACPI_VER "1.99"
|
||||||
|
|
||||||
/* main pixmap */
|
/* main pixmap */
|
||||||
#ifdef LOW_COLOR
|
#ifdef LOW_COLOR
|
||||||
|
@ -59,16 +59,10 @@ typedef struct {
|
||||||
int blink; /* should we blink the LED? (critical battery) */
|
int blink; /* should we blink the LED? (critical battery) */
|
||||||
} Dockapp;
|
} Dockapp;
|
||||||
|
|
||||||
/* for debug printing */
|
|
||||||
#ifdef PRO
|
|
||||||
char *state[] = { "AC", "Charging", "High", "Low", "Crit" };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* globals */
|
/* globals */
|
||||||
Dockapp *dockapp;
|
Dockapp *dockapp;
|
||||||
global_t *globals;
|
global_t *globals;
|
||||||
int count = 0; /* global timer variable */
|
int count = 0; /* global timer variable */
|
||||||
int noisy_critical = 0; /* ring xbell annoyingly if critical? */
|
|
||||||
|
|
||||||
/* Time for scroll updates */
|
/* Time for scroll updates */
|
||||||
#define DEFAULT_UPDATE 150
|
#define DEFAULT_UPDATE 150
|
||||||
|
@ -129,7 +123,6 @@ static void invalid_time_display(void)
|
||||||
static void redraw_window(void)
|
static void redraw_window(void)
|
||||||
{
|
{
|
||||||
if (dockapp->update) {
|
if (dockapp->update) {
|
||||||
eprint(0, "redrawing window");
|
|
||||||
XCopyArea(dockapp->display, dockapp->pixmap, dockapp->iconwin,
|
XCopyArea(dockapp->display, dockapp->pixmap, dockapp->iconwin,
|
||||||
dockapp->gc, 0, 0, 64, 64, 0, 0);
|
dockapp->gc, 0, 0, 64, 64, 0, 0);
|
||||||
XCopyArea(dockapp->display, dockapp->pixmap, dockapp->win,
|
XCopyArea(dockapp->display, dockapp->pixmap, dockapp->win,
|
||||||
|
@ -195,7 +188,7 @@ static void new_window(char *name)
|
||||||
if (XpmCreatePixmapFromData(dockapp->display, dockapp->win,
|
if (XpmCreatePixmapFromData(dockapp->display, dockapp->win,
|
||||||
master_xpm, &dockapp->pixmap,
|
master_xpm, &dockapp->pixmap,
|
||||||
&dockapp->mask, &attr) != XpmSuccess) {
|
&dockapp->mask, &attr) != XpmSuccess) {
|
||||||
fprintf(stderr, "FATAL: Not enough colors for main pixmap!\n");
|
pfatal("FATAL: Not enough colors for main pixmap!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +197,7 @@ static void new_window(char *name)
|
||||||
DefaultDepth(dockapp->display,
|
DefaultDepth(dockapp->display,
|
||||||
dockapp->screen));
|
dockapp->screen));
|
||||||
if (!dockapp->text) {
|
if (!dockapp->text) {
|
||||||
fprintf(stderr, "FATAL: Cannot create text scroll pixmap!\n");
|
pfatal("FATAL: Cannot create text scroll pixmap!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,8 +226,6 @@ static void render_text(char *string)
|
||||||
if (strlen(string) > 53)
|
if (strlen(string) > 53)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
eprint(0, "rendering: %s", string);
|
|
||||||
|
|
||||||
/* prepare the text area by clearing it */
|
/* prepare the text area by clearing it */
|
||||||
for (i = 0; i < 54; i++) {
|
for (i = 0; i < 54; i++) {
|
||||||
XCopyArea(dockapp->display, dockapp->pixmap, dockapp->text,
|
XCopyArea(dockapp->display, dockapp->pixmap, dockapp->text,
|
||||||
|
@ -272,7 +263,7 @@ static int open_display(char *display)
|
||||||
{
|
{
|
||||||
dockapp->display = XOpenDisplay(display);
|
dockapp->display = XOpenDisplay(display);
|
||||||
if (!dockapp->display) {
|
if (!dockapp->display) {
|
||||||
fprintf(stderr, "Unable to open display '%s'\n", display);
|
perr("Unable to open display '%s'\n", display);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -324,8 +315,6 @@ static void display_percentage(int percent)
|
||||||
static unsigned int obar;
|
static unsigned int obar;
|
||||||
unsigned int bar;
|
unsigned int bar;
|
||||||
|
|
||||||
eprint(0, "received: %d\n", percent);
|
|
||||||
|
|
||||||
if (percent == -1)
|
if (percent == -1)
|
||||||
percent = 0;
|
percent = 0;
|
||||||
|
|
||||||
|
@ -383,7 +372,6 @@ static void display_time(int minutes)
|
||||||
if (hour == ohour && min == omin)
|
if (hour == ohour && min == omin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
eprint(0, "redrawing time");
|
|
||||||
tmp = hour / 10;
|
tmp = hour / 10;
|
||||||
copy_xpm_area(tmp * 7 + 1, 76, 6, 11, 7, 32);
|
copy_xpm_area(tmp * 7 + 1, 76, 6, 11, 7, 32);
|
||||||
tmp = hour % 10;
|
tmp = hour % 10;
|
||||||
|
@ -609,15 +597,63 @@ void usage(char *name)
|
||||||
|
|
||||||
void print_version(void)
|
void print_version(void)
|
||||||
{
|
{
|
||||||
printf("wmacpi-ng version %s\n", WMACPI_NG_VER);
|
printf("wmacpi version %s\n", WMACPI_VER);
|
||||||
printf(" Using libacpi version %s\n", LIBACPI_VER);
|
printf(" Using libacpi version %s\n", LIBACPI_VER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cli_wmacpi(int samples)
|
||||||
|
{
|
||||||
|
int i, j, sleep_time;
|
||||||
|
battery_t *binfo;
|
||||||
|
adapter_t *ap;
|
||||||
|
|
||||||
|
sleep_time = 1000000/samples;
|
||||||
|
|
||||||
|
/* we want to acquire samples over some period of time, so . . . */
|
||||||
|
for(i = 0; i < samples + 2; i++) {
|
||||||
|
for(j = 0; j < batt_count; j++)
|
||||||
|
acquire_batt_info(j);
|
||||||
|
acquire_global_info();
|
||||||
|
usleep(sleep_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
ap = &globals->adapter;
|
||||||
|
if(ap->power == AC) {
|
||||||
|
printf("On AC Power");
|
||||||
|
for(i = 0; i < batt_count; i++) {
|
||||||
|
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,
|
||||||
|
binfo->charge_time%60);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
} else if(ap->power == BATT) {
|
||||||
|
printf("On Battery");
|
||||||
|
for(i = 0; i < batt_count; i++) {
|
||||||
|
binfo = &batteries[i];
|
||||||
|
if(binfo->present && (binfo->percentage >= 0))
|
||||||
|
printf(", Battery %s at %d%%", binfo->name,
|
||||||
|
binfo->percentage);
|
||||||
|
}
|
||||||
|
if(globals->rtime >= 0)
|
||||||
|
printf("; %d:%02d remaining", globals->rtime/60,
|
||||||
|
globals->rtime%60);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *display = NULL;
|
char *display = NULL;
|
||||||
char ch;
|
char ch;
|
||||||
int update = 0;
|
int update = 0;
|
||||||
|
int cli = 0, samples = 1;
|
||||||
int samplerate = 100;
|
int samplerate = 100;
|
||||||
battery_t *binfo;
|
battery_t *binfo;
|
||||||
|
|
||||||
|
@ -634,11 +670,8 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
/* parse command-line options */
|
/* parse command-line options */
|
||||||
while ((ch = getopt(argc, argv, "bd:c:m:s:hnvV")) != EOF) {
|
while ((ch = getopt(argc, argv, "d:c:m:s:a:hnwvV")) != EOF) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'b':
|
|
||||||
noisy_critical = 1;
|
|
||||||
break;
|
|
||||||
case 'c':
|
case 'c':
|
||||||
if (optarg) {
|
if (optarg) {
|
||||||
globals->crit_level = atoi(optarg);
|
globals->crit_level = atoi(optarg);
|
||||||
|
@ -691,12 +724,31 @@ int main(int argc, char **argv)
|
||||||
case 'n':
|
case 'n':
|
||||||
dockapp->blink = 0;
|
dockapp->blink = 0;
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
cli = 1;
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
if(optarg != NULL) {
|
||||||
|
samples = atoi(optarg);
|
||||||
|
if(samples > 1000 || samples <= 0) {
|
||||||
|
printf("Please specify a reasonable number of samples\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check for cli mode */
|
||||||
|
if (cli) {
|
||||||
|
cli_wmacpi(samples);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
battery_no--;
|
battery_no--;
|
||||||
|
|
||||||
/* open local or command-line specified display */
|
/* open local or command-line specified display */
|
||||||
|
@ -713,7 +765,7 @@ int main(int argc, char **argv)
|
||||||
acquire_all_info();
|
acquire_all_info();
|
||||||
binfo = &batteries[battery_no];
|
binfo = &batteries[battery_no];
|
||||||
globals->binfo = binfo;
|
globals->binfo = binfo;
|
||||||
fprintf(stderr, "monitoring battery %s\n", binfo->name);
|
pinfo("monitoring battery %s\n", binfo->name);
|
||||||
clear_time_display();
|
clear_time_display();
|
||||||
set_power_panel();
|
set_power_panel();
|
||||||
set_message();
|
set_message();
|
||||||
|
@ -723,7 +775,6 @@ int main(int argc, char **argv)
|
||||||
while (1) {
|
while (1) {
|
||||||
XEvent event;
|
XEvent event;
|
||||||
while (XPending(dockapp->display)) {
|
while (XPending(dockapp->display)) {
|
||||||
eprint(0, "X11 activity");
|
|
||||||
XNextEvent(dockapp->display, &event);
|
XNextEvent(dockapp->display, &event);
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
|
@ -744,7 +795,7 @@ int main(int argc, char **argv)
|
||||||
battery_no = battery_no % batt_count;
|
battery_no = battery_no % batt_count;
|
||||||
globals->binfo = &batteries[battery_no];
|
globals->binfo = &batteries[battery_no];
|
||||||
binfo = globals->binfo;
|
binfo = globals->binfo;
|
||||||
fprintf(stderr, "changing to monitor battery %d\n", battery_no + 1);
|
pinfo("changing to monitor battery %d\n", battery_no + 1);
|
||||||
set_batt_id_area(battery_no);
|
set_batt_id_area(battery_no);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
Loading…
Reference in a new issue