[Pkg-wmaker-commits] [wmacpi] 50/105: Imported Upstream version 2.2~rc1
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Tue Aug 18 01:13:44 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmacpi.
commit cad47148d924b99942ada5677b4ff1636f652ebe
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Mon Nov 24 05:55:12 2014 -0600
Imported Upstream version 2.2~rc1
---
AUTHORS | 2 +-
ChangeLog | 26 ++++++++
Makefile | 6 +-
README | 28 ++++----
TODO | 7 +-
acpi.c | 9 +--
debian/changelog | 147 -----------------------------------------
debian/compat | 1 -
debian/control | 20 ------
debian/copyright | 27 --------
debian/dirs | 1 -
debian/docs | 3 -
debian/menu | 2 -
debian/rules | 90 -------------------------
debian/watch | 2 -
libacpi.c | 27 ++++++--
libacpi.h | 2 +-
wmacpi.1 | 58 ++++++++--------
wmacpi.c | 198 +++++++++++++++++++++++++------------------------------
19 files changed, 194 insertions(+), 462 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 6f804d2..b04df42 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,4 +1,4 @@
-Simon Fowler <simon at dreamcraft.com.au>
+Simon Fowler <simon at himi.or>
Complete rewriting of the code from wmacpi-1.34.
timecop
diff --git a/ChangeLog b/ChangeLog
index dfa719f..8524a1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+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
+ Added a patch from Patrice Dumas to support newer versions of
+ libdockapp.
+
+ Updated email address in AUTHORS and manpages.
+
2005 February 2 2.1
Finalised libdockapp-0.5.0 port - no changes from 2.1rc1.
diff --git a/Makefile b/Makefile
index 4d53ae1..0572999 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ BUILD_CLI = 1
CC := gcc
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
HEADERS := libacpi.h wmacpi.h
@@ -34,7 +34,7 @@ all: $(targets)
WMOBJ := $(patsubst %.c,%.o,$(filter %.c,$(WMSRC)))
# include per-file dependencies
-include $(WMOBJ:.o=.d)
+-include $(WMOBJ:.o=.d)
wmacpi: $(WMOBJ)
$(CC) $(LDFLAGS) -o $@ $^
@@ -44,7 +44,7 @@ wmacpi: $(WMOBJ)
ifdef BUILD_CLI
CLSRC := acpi.c libacpi.c
CLOBJ := $(patsubst %.c,%.o,$(filter %.c,$(CLSRC)))
-include $(CLOBJ:.o=.d)
+-include $(CLOBJ:.o=.d)
acpi: $(CLOBJ)
$(CC) $(LDFLAGS) -o $@ $^
diff --git a/README b/README
index 97fcb19..c3e13e8 100644
--- a/README
+++ b/README
@@ -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
displays summaries.
-Version 1.99 and later provides full support for multiple
-batteries. You can tell it to monitor a particular battery 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
+Version 1.99 and later provides full support for multiple batteries.
+You can tell it to monitor a particular battery 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).
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
could affect interactivity. To provide a workaround for this, current
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 . . .
+line. The --sample-rate option specifies the number of times the
+battery is sampled every minute - the default is 20, and the maximum
+value is 600. Since -s 600 translates to sampling every 0.1 seconds,
+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
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
this could have adverse effects.
-Please report bugs to <simon at dreamcraft.com.au>.
+Please report bugs to <simon at himi.org>
-Simon Fowler, 2003-11-23.
+Simon Fowler, 2007-07-13.
diff --git a/TODO b/TODO
index ef29553..d016ac7 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,9 @@
+2007 July 13 2.2rc1
+ * Make sure that everything works properly on modern kernels.
+
2004 January 18 1.99r3
* 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
* Expand libacpi to handle everything else under
@@ -46,4 +49,4 @@
* Code cleanups . . .
- -- Simon Fowler, <simon at dreamcraft.com.au>
+ -- Simon Fowler, <simon at himi.org>
diff --git a/acpi.c b/acpi.c
index 85a6c84..ffca2cb 100644
--- a/acpi.c
+++ b/acpi.c
@@ -26,7 +26,7 @@
#include "libacpi.h"
-#define ACPI_VER "2.1"
+#define ACPI_VER "2.2rc1"
global_t *globals;
@@ -38,7 +38,8 @@ void usage(char *name)
" 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"
- " v - increase verbosity\n",
+ " V - increase verbosity\n"
+ " v - print version information\n",
name, name);
}
@@ -61,10 +62,10 @@ int main(int argc, char *argv[])
case 'h':
usage(argv[0]);
return 0;
- case 'v':
+ case 'V':
verbosity++;
break;
- case 'V':
+ case 'v':
print_version();
return 0;
case 'a':
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index 5778797..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,147 +0,0 @@
-wmacpi-ng (0.99-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at dreamcraft.com.au> Fri, 26 Sep 2003 13:48:55 +1000
-
-wmacpi-ng (0.92-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at dreamcraft.com.au> Tue, 23 Sep 2003 11:57:09 +1000
-
-wmacpi-ng (0.91-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at dreamcraft.com.au> Wed, 6 Aug 2003 18:32:11 +1000
-
-wmacpi-ng (0.90-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Wed, 16 Jul 2003 18:52:04 +1000
-
-wmacpi-ng (0.50a2-1) unstable; urgency=low
-
- * New alpha upstream version.
-
- -- Simon Fowler <simon at dreamcraft.com.au> Fri, 11 Jul 2003 14:29:44 +1000
-
-wmacpi-ng (0.50a1-1) unstable; urgency=low
-
- * New alpha upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Thu, 10 Jul 2003 11:46:11 +1000
-
-wmacpi-ng (0.50a-1) unstable; urgency=low
-
- * New alpha upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Thu, 10 Jul 2003 00:07:44 +1000
-
-wmacpi-ng (0.50-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Sun, 6 Jul 2003 16:50:59 +1000
-
-wmacpi-ng (0.19-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Wed, 2 Jul 2003 00:55:36 +1000
-
-wmacpi-ng (0.15-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Tue, 24 Jun 2003 00:38:26 +1000
-
-wmacpi-ng (0.14-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Tue, 24 Jun 2003 00:00:26 +1000
-
-wmacpi-ng (0.13-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Mon, 23 Jun 2003 23:49:05 +1000
-
-wmacpi-ng (0.12-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Sat, 21 Jun 2003 12:24:43 +1000
-
-wmacpi-ng (0.11-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at hollie.himi.private> Fri, 30 May 2003 23:42:12 +1000
-
-wmacpi-ng (0.10-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at dreamcraft.com.au> Fri, 30 May 2003 13:35:50 +1000
-
-wmacpi-ng (0.2a-1) unstable; urgency=low
-
- * New upstream version.
-
- -- Simon Fowler <simon at dreamcraft.com.au> Mon, 26 May 2003 22:08:45 +1000
-
-wmacpi-ng (0.2-1) unstable; urgency=low
-
- * New version.
-
- -- Simon Fowler <simon at dreamcraft.com.au> Mon, 26 May 2003 18:59:16 +1000
-
-wmacpi-ng (0.1-1) unstable; urgency=low
-
- * New package, since the current version doesn't work with kernel
- 2.4.21-rc2.
-
- -- Simon Fowler <simon at dreamcraft.com.au> Mon, 26 May 2003 14:01:40 +1000
-
-wmacpi (1.34-1) unstable; urgency=low
-
- * New maintainer.
- * New upstream release (closes: #143387).
- * debian/control:
- - Updated description.
- - Bumped Standards-Version to 3.5.9.
- - Updated build-dependency on debhelper to >= 4.
- - Changed priority to "optional".
- - Added a recommendation on "wmaker".
- * debian/compat:
- - Introduced this file and set its contents to "4".
- * debian/copyright:
- - Updated maintainer and homepage infos.
- * debian/rules:
- - Made some minor modifications to comply with policy.
- * debian/watch:
- - Introduced this file, which seems to be currently useless, though. the
- web server does not allow browsing in the necessary directories.
- * debian/docs:
- - Included AUTHORS.
- * debian/wmacpi.1:
- - Updated man page to reflect current parameters of wmacpi.
-
- -- Sebastian Henschel <shensche at kodeaffe.de> Sat, 19 Apr 2003 17:09:11 +0200
-
-wmacpi (1.33-1) unstable; urgency=low
-
- * New upstream release
-
- -- Simon Richter <sjr at debian.org> Mon, 28 May 2001 01:49:55 +0200
-
-wmacpi (1.31-1) unstable; urgency=low
-
- * Initial Release (Closes: #90347).
-
- -- Simon Richter <Simon.Richter at phobos.fs.tum.de> Mon, 19 Mar 2001 23:26:49 +0100
-
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index b8626c4..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-4
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 8b9e99f..0000000
--- a/debian/control
+++ /dev/null
@@ -1,20 +0,0 @@
-Source: wmacpi
-Section: x11
-Priority: optional
-Maintainer: Simon Fowler <simon at dreamcraft.com.au>
-Build-Depends: debhelper (>= 4), xlibs-dev
-Standards-Version: 3.5.9
-
-Package: wmacpi
-Architecture: i386
-Depends: ${shlibs:Depends}
-Recommends: wmaker
-Description: An ACPI battery monitor for WindowMaker
- This is a battery monitor that uses ACPI to query the battery status.
- This version should work with all recent kernels, both 2.4 and 2.6.
- .
- This is a reworked version to handle modern kernels, done by Simon
- Fowler <simon at dreamcraft.com.au>
- .
- Author: Simon Fowler <simon at dreamcraft.com.au>
- Homepage: http://himi.org/wmacpi-ng/
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index dfd7321..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,27 +0,0 @@
-This package was debianized by Simon Richter <Simon.Richter at phobos.fs.tum.de> on
-Mon, 19 Mar 2001 23:26:49 +0100.
-It was taken over by Sebastian Henschel <shensche at kodeaffe.de> on Sat, 19 Apr 2003 15:31:00 +0200.
-
-It was downloaded from http://www.ne.jp/asahi/linux/timecop/
-
-Upstream Author: Timecop <timecop at japan.co.jp>
-
-Copyright:
-
- This package is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 dated June, 1991.
-
- This package is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this package; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA.
-
-On Debian GNU/Linux systems, the complete text of the GNU General
-Public License can be found in `/usr/share/common-licenses/GPL'.
-
diff --git a/debian/dirs b/debian/dirs
deleted file mode 100644
index e772481..0000000
--- a/debian/dirs
+++ /dev/null
@@ -1 +0,0 @@
-usr/bin
diff --git a/debian/docs b/debian/docs
deleted file mode 100644
index 9bce069..0000000
--- a/debian/docs
+++ /dev/null
@@ -1,3 +0,0 @@
-README
-AUTHORS
-TODO
\ No newline at end of file
diff --git a/debian/menu b/debian/menu
deleted file mode 100644
index 10c6503..0000000
--- a/debian/menu
+++ /dev/null
@@ -1,2 +0,0 @@
-?package(wmacpi):needs=X11 section=Apps/System\
- title="wmacpi" command="/usr/bin/wmacpi"
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 5cc82ce..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/make -f
-# Sample debian/rules that uses debhelper.
-# GNU copyright 1997 to 1999 by Joey Hess.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-INSTALLDIR=$(CURDIR)/debian/wmacpi
-
-# These are used for cross-compiling and for saving the configure script
-# # from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS = "-Wall -g -O0"
-else
- CFLAGS = "-Wall -g -O2"
-endif
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
-
- touch configure-stamp
-
-build: configure-stamp build-stamp
-build-stamp:
- dh_testdir
-
- # Add here commands to compile the package.
- $(MAKE)
-
- touch build-stamp
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
-
- # Add here commands to clean up after the build process.
- -$(MAKE) clean-all
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/wmacpi.
- install -o root -g root -m 755 wmacpi $(INSTALLDIR)/usr/bin/
-# install -o root -g root -m 755 acpi-ng $(INSTALLDIR)/usr/bin/
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
-# dh_installdebconf
- dh_installdocs
-# dh_installexamples
- dh_installmenu
-# dh_installemacsen
-# dh_installpam
-# dh_installinit
-# dh_installcron
- dh_installman wmacpi.1 # acpi.1
-# dh_installinfo
-# dh_undocumented
- dh_installchangelogs ChangeLog
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_makeshlibs
- dh_installdeb
-# dh_perl
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index ff95adf..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,2 +0,0 @@
-version=2
-http://www.ne.jp/asahi/linux/timecop/software/wmacpi-(.*)\.tar\.gz debian uupdate
diff --git a/libacpi.c b/libacpi.c
index 6ea74d6..2a3890d 100644
--- a/libacpi.c
+++ b/libacpi.c
@@ -139,15 +139,20 @@ int power_init(global_t *globals)
char buf[4096];
int acpi_ver = 0;
int retval;
+ unsigned int version_offset = 0;
- if (!(acpi = fopen("/proc/acpi/info", "r"))) {
- pfatal("This system does not support ACPI\n");
- return 1;
+ if (!(acpi = fopen("/sys/module/acpi/parameters/acpica_version", "r"))) {
+ if (!(acpi = fopen("/proc/acpi/info", "r"))) {
+ pfatal("This system does not support ACPI\n");
+ return 1;
+ } else {
+ version_offset = 25;
+ }
}
/* okay, now see if we got the right version */
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);
if (acpi_ver < 20020214) {
pfatal("This version requires ACPI subsystem version 20020214\n");
@@ -169,9 +174,11 @@ int power_reinit(global_t *globals)
FILE *acpi;
int retval;
- if (!(acpi = fopen("/proc/acpi/info", "r"))) {
- pfatal("Could not reopen ACPI info file - does this system support ACPI?\n");
- return 1;
+ if (!(acpi = fopen("/sys/module/acpi/parameters/acpica_version", "r"))) {
+ if (!(acpi = fopen("/proc/acpi/info", "r"))) {
+ pfatal("Could not reopen ACPI info file - does this system support ACPI?\n");
+ return 1;
+ }
}
if (!(retval = reinit_batteries(globals)))
@@ -337,6 +344,12 @@ int get_battery_info(int batt_no)
info->charge_state = CH_ERR;
else if ((strncmp(val, "discharging", 10)) == 0)
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
info->charge_state = CHARGE;
diff --git a/libacpi.h b/libacpi.h
index 7cdaf5d..fd89c2f 100644
--- a/libacpi.h
+++ b/libacpi.h
@@ -2,7 +2,7 @@
#define _LIBACPI_H_
-#define LIBACPI_VER "0.92"
+#define LIBACPI_VER "0.93"
/* Here because we need it for definitions in this file . . . */
#define MAX_NAME 128
diff --git a/wmacpi.1 b/wmacpi.1
index 47c02c5..93cf646 100644
--- a/wmacpi.1
+++ b/wmacpi.1
@@ -1,4 +1,4 @@
-.TH WMACPI 1 "August 15 2004"
+.TH WMACPI 1 "July 13 2007"
.SH NAME
wmacpi \- Battery status monitor for systems supporting ACPI
.SH NAME
@@ -27,13 +27,13 @@ sample rate ]
.RI -n
]
[
-.RI -w
+.RI -x
]
[
.RI -a
samples ]
[
-.RI -V
+.RI -v
]
[
.RI -h
@@ -44,10 +44,10 @@ samples ]
.RI -a
samples ]
[
-.RI -v
+.RI -V
]
[
-.RI -V
+.RI -v
]
]
.RI -b
@@ -85,24 +85,24 @@ battery to reach full charge if the batteries are charging.
.SH OPTIONS
.B wmacpi
.TP
-.B \-c percentage
-Set critical low alarm at <value>% (default: 10%).
+.B \-c, --critical=percentage
+Set critical low alarm at <percentage>% (default: 10%).
.TP
-.B \-d display
+.B \-d, --display=display
Set the X display to open the window on.
.TP
-.B \-m battery number
+.B \-m, --battery=battery number
Set the battery to monitor initially.
.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
minute. Minimum is 1, ie once a minute, default is 20, maximum is 600.
.TP
-.B \-n
+.B \-n, --no-blink
Disable blinking power glyph when charging. Note that it still blinks when
the battery reports its capacity state as critical.
.TP
-.B \-f
+.B \-f, --force-capacity-mode
Force the use of capacity mode for calculating time remaining. By defalt
.B wmacpi
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
rate.
.TP
-.B \-w
+.B \-x, --cmdline
Run wmacpi in command line mode - this operates identically to
.B acpi
..
.TP
-.B \-a num
+.B \-a, --samples=samples
Average the time remaining over num samples. This greatly improves the
accuracy of the reported time remaining.
.TP
-.B \-v
-Increase the verbosity of the program. Can be used more than once -
-each successive use increases the verbosity.
+.B \-V, --verbosity=num
+Increase the verbosity of the program. Setting this to 1 will print extra
+error information; 2 will produce informational output; 3 will produce
+copious debugging output.
.TP
-.B \-V
+.B \-v, --version
Print the version information.
.TP
-.B \-b
-Enable blinking of the power glyph when charging the batteries.
-.TP
-.B \-r
+.B \-r, --no-scroll
Disable scrolling message.
.TP
-.B \-h
+.B \-h, --help
Display help.
.TP
.B acpi
@@ -144,11 +142,15 @@ Display help.
Average the time remaining over num samples. This greatly improves the
accuracy of the reported time remaining.
.TP
-.B \-v
-Increase the verbosity of the program, as for
+.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
+.B \-v
Print the version information.
.TP
.B \-h
@@ -156,10 +158,10 @@ Display help.
.SH AUTHOR
.B wmacpi
was originally written by Tim Copperfield <timecop at japan.co.jp>, then
-completely rewritten after 1.34 by Simon Fowler <simon at dreamcraft.com.au>.
+completely rewritten after 1.34 by Simon Fowler <simon at himi.org>.
.PP
This manual page was originally written by Simon Richter
<sjr at debian.org> for the Debian GNU/Linux system, and then updated by
Simon Fowler.
.br
-Last modification by Simon Fowler <simon at dreamcraft.com.au>, 2004-08-15.
+Last modification by Simon Fowler <simon at himi.org>, 2007-07-13.
diff --git a/wmacpi.c b/wmacpi.c
index 5d44550..241eeb5 100644
--- a/wmacpi.c
+++ b/wmacpi.c
@@ -24,7 +24,6 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#include <getopt.h>
#include <unistd.h>
#include <time.h>
@@ -37,7 +36,7 @@
#include "libacpi.h"
#include "wmacpi.h"
-#define WMACPI_VER "2.1"
+#define WMACPI_VER "2.2rc1"
/* main pixmap */
#ifdef LOW_COLOR
@@ -136,8 +135,11 @@ static void redraw_window(void)
static void new_window(char *display, char *name, int argc, char **argv)
{
+ XSizeHints *hints;
+
/* Initialise the dockapp window and appicon */
- DAInitialize(display, name, 64, 64, argc, argv);
+ DAOpenDisplay(display, argc, argv);
+ DACreateIcon(name, 64, 64, argc, argv);
dockapp->display = DADisplay;
dockapp->win = DAWindow;
@@ -159,6 +161,20 @@ static void new_window(char *display, char *name, int argc, char **argv)
pfatal("FATAL: Cannot create text scroll pixmap!\n");
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();
}
@@ -412,7 +428,7 @@ static void blink_battery_glyph(void)
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;
adapter_t *ap = &globals->adapter;
@@ -561,32 +577,7 @@ void set_batt_id_area(int bno)
copy_xpm_area(sx, sy, w, h, dx, dy);
}
-void usage(char *name)
-{
- printf("%s - help\t\t[simon at 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);
-}
+#define VERSION "wmacpi version " WMACPI_VER "\nUsing libacpi version " LIBACPI_VER
void cli_wmacpi(global_t *globals, int samples)
{
@@ -640,12 +631,11 @@ void cli_wmacpi(global_t *globals, int samples)
int main(int argc, char **argv)
{
char *display = NULL;
- int ch;
int sample_count = 0;
int batt_reinit, ac_reinit;
int batt_count = 0;
int ac_count = 0;
- int cli = 0, samples = 1;
+ int cli = 0, samples = 1, critical = 10;
int samplerate = 20;
int sleep_rate = 10;
int sleep_time = 1000000/sleep_rate;
@@ -655,6 +645,19 @@ int main(int argc, char **argv)
battery_t *binfo;
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));
globals = calloc(1, sizeof(global_t));
@@ -675,84 +678,37 @@ int main(int argc, char **argv)
* are available /before/ we can decide if the battery we want to
* monitor is available. */
/* parse command-line options */
- while ((ch = getopt(argc, argv, "d:c:m:s:a:fhnwbrvV")) != EOF) {
- switch (ch) {
- case 'c':
- if (optarg) {
- globals->crit_level = atoi(optarg);
- if ((globals->crit_level < 0) || (globals->crit_level > 100)) {
- fprintf(stderr, "Please use values between 0 and 100%%\n");
- globals->crit_level = 10;
- fprintf(stderr, "Using default value of 10%%\n");
- }
- }
- break;
- case 'd':
- 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;
- }
-
+ DAParseArguments(argc, argv, options, 10,
+ "A battery monitor dockapp for ACPI based systems",
+ VERSION);
+
+ if (options[0].used)
+ dockapp->scroll = 0;
+ if (options[1].used)
+ dockapp->blink = 0;
+ if (options[2].used)
+ cli = 1;
+ if (options[3].used) {
+ rt_mode = RT_CAP;
+ rt_forced = 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))
/* power_init functions handle printing error messages */
exit(1);
@@ -798,6 +754,8 @@ int main(int argc, char **argv)
/* main loop */
while (1) {
+ Atom atom;
+ Atom wmdelwin;
XEvent event;
while (XPending(dockapp->display)) {
XNextEvent(dockapp->display, &event);
@@ -824,6 +782,28 @@ int main(int argc, char **argv)
set_batt_id_area(battery_no);
dockapp->update = 1;
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;
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmacpi.git
More information about the Pkg-wmaker-commits
mailing list