pax_global_header00006660000000000000000000000064136026167310014517gustar00rootroot0000000000000052 comment=d9ed303e523dadfabd46652af6ef0658ed1fff0a xbattbar-1.4.9/000077500000000000000000000000001360261673100133415ustar00rootroot00000000000000xbattbar-1.4.9/.gitignore000066400000000000000000000001251360261673100153270ustar00rootroot00000000000000debian/xbattbar* .debhelper debian/files xbattbar build-stamp xbattbar-check-apm obj xbattbar-1.4.9/COPYING000066400000000000000000000431011360261673100143730ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program 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; either version 2 of the License, or (at your option) any later version. This program 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 program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. xbattbar-1.4.9/Makefile000066400000000000000000000022511360261673100150010ustar00rootroot00000000000000OS_TYPE ?= linux PROJECT = xbattbar DESTDIR ?= / TARGET = xbattbar APM_CHECK = xbattbar-check-apm CPPFLAGS = -D_FORTIFY_SOURCE=2 CFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security $(CPPFLAGS) LDFLAGS = -Wl,-z,relro all: $(TARGET) $(APM_CHECK) $(TARGET): obj/xbattbar.o gcc -o $@ $< -lX11 $(LDFLAGS) obj/xbattbar.o: xbattbar.c obj/stamp gcc -MMD -o $@ -c $< $(CFLAGS) $(APM_CHECK): obj/xbattbar-check-apm.o gcc -o $@ $< $(LDFLAGS) obj/xbattbar-check-apm.o: xbattbar-check-apm.c obj/stamp gcc -MMD -D$(OS_TYPE) -o $@ -c $< $(CFLAGS) obj/stamp: mkdir obj touch $@ clean: rm -fr obj rm -f $(TARGET) $(APM_CHECK) install: $(TARGET) $(APM_CHECK) install -d -m 0755 $(DESTDIR)/usr/lib/$(PROJECT) install -d -m 0755 $(DESTDIR)/usr/bin install -d -m 0755 $(DESTDIR)/usr/share/man/man1 install -m 0755 $(APM_CHECK) $(DESTDIR)/usr/lib/$(PROJECT)/ install -m 0755 xbattbar-check-acpi $(DESTDIR)/usr/lib/$(PROJECT)/ install -m 0755 xbattbar-check-sys $(DESTDIR)/usr/lib/$(PROJECT)/ install -m 0755 $(TARGET) $(DESTDIR)/usr/bin/ install -m 0644 xbattbar.man $(DESTDIR)/usr/share/man/man1/$(PROJECT).1 include $(wildcard obj/*.d) xbattbar-1.4.9/README000066400000000000000000000044261360261673100142270ustar00rootroot00000000000000RELEASE NOTES Febraury-2-2001 Suguru Yamaguchi This directory contains source for the X11 version of xbattbar (version 1.4.2) which is a (laptop) battery status indicator. * Version The release version of this xbattbar is 1.4.2 Some of command line options of this release are not compatible with its old versions such as 1.1 and 1.2. If you are currently using such old versions of xbattbar, Please consult the manual page of this version. * Supported platform We tested this program on: BSDI's BSD/os 3.0, 3.1 FreeBSD 2.2.x, 3.x, 4.0, 4.1 NetBSD 1.3, 1.3.2 Linux 2.2 * Installation Procedure It's almost the same as cases for normal X window applications: xmkmf -a make make install make install.man * Known bugs and installation hints 1. This program doesn't work well with the virtual desktop environment provided by several window managers such as fvwm; especially in the case that you use an 'EdgeScroll' feature, this program corrupts with it, because this program instead of your window manager catches mouse events to show xbattbar dialogue box. 2. This program may happen to get X protocol error from X servers, and then terminate illeagally. Especially in the case we repeat "launch and kill" of this program very rapidly, this case may happen. I guess this problem is caused by the X server internals. 3. In the standard configuration of FreeBSD 2.x and 3.x, since the APM device /dev/apm is protected by mode 664 with owner "root" and group "operator", this program have to be installed with root.operator and mode 2555 (I prefer to use SetGID operator instead of SUID root for security considerations). 4. In the case you plug off your AC line during battery status window is poped up, the battery status window is not updated, because I do not put any code to sense the battery status during the window is poped up. You may think this is a bug, but I don't care (sorry!). * Comments, Suggestions, and Bug Reports Please send e-mail to Suguru Yamaguchi * Developers Suguru Yamaguchi base development and releasing Akira Kato function enhancements Noriyuki Shigechika function enhancements Susumu Sano FreeBSD porting Hiroshi Ura NetBSD porting Yuji Sekiya Linux porting ------ $Id: README,v 1.8.2.4 2001/02/02 05:25:28 suguru Exp $ xbattbar-1.4.9/copyright000066400000000000000000000014131360261673100152730ustar00rootroot00000000000000/* * Copyright (c) 1998-2001 Suguru Yamaguchi * * This program 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; either version 2 of the License, or (at * your option) any later version. * * This program 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 program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ xbattbar-1.4.9/debian/000077500000000000000000000000001360261673100145635ustar00rootroot00000000000000xbattbar-1.4.9/debian/changelog000066400000000000000000000073061360261673100164430ustar00rootroot00000000000000xbattbar (1.4.9-1) unstable; urgency=medium * Bump major version. * Bump Standards-Version to 4.3.0. * drop dh_clean -k (lintian warning). * add debian/source (lintian warning). -- Dmitry E. Oboukhov Tue, 31 Dec 2019 12:45:44 +0300 xbattbar (1.4.8-2) unstable; urgency=medium * Drop python depends, closes: #945724. -- Dmitry E. Oboukhov Fri, 13 Dec 2019 13:59:21 +0300 xbattbar (1.4.8-1) unstable; urgency=medium * Drop debug symbols. -- Dmitry E. Oboukhov Tue, 15 Sep 2015 10:45:08 +0300 xbattbar (1.4.7-1) unstable; urgency=medium * Fixed regexp in xbattbar-check-acpi. -- Dmitry E. Oboukhov Tue, 15 Sep 2015 10:26:13 +0300 xbattbar (1.4.6-1) unstable; urgency=medium * Indicator works properly if there is fake battery. -- Dmitry E. Oboukhov Mon, 14 Sep 2015 18:08:31 +0300 xbattbar (1.4.5-1) unstable; urgency=medium * Fix FTBFS with Debian/kFreeBSD, closes: #743068, thanks to Steven Chamberlain . * Fix compilation warnings in APM backend, closes: #731217, thanks to Andrew Shadura . -- Dmitry E. Oboukhov Wed, 30 Apr 2014 18:29:35 +0400 xbattbar (1.4.4-1) unstable; urgency=low * Add support for getting battery data from /sys/class/power_supply, thanks to Elena Grandi for script, closes: #684491. * Add option '-r' to use the script. * Update manpage. -- Dmitry E. Oboukhov Thu, 17 Oct 2013 11:19:57 +0400 xbattbar (1.4.3-1) unstable; urgency=low * New maintainer, closes: #524997, #526834; * Upstream version has been incremented. * Upstream make system was rewritten. * Added ACPI support for xbattbar. * Fixed description, closes: #517682. * Unnecessary dependencies have been dropped. * Manpage has been updated. * Standards-Version has been bumped to 3.8.1. * GIT-repo has been created on git.debian.org. -- Dmitry E. Oboukhov Mon, 04 May 2009 09:04:05 +0400 xbattbar (1.4.2-5.1) unstable; urgency=low * Non-maintainer upload. * debian/control: + Add libxext-dev to Build-Depends (Closes: #449121). * debian/menu: + Update to the new menu policy (Closes: #485762). -- Marco Rodrigues Wed, 11 Jun 2008 10:38:15 +0100 xbattbar (1.4.2-5) unstable; urgency=low * New Maintainer (Closes: #366524) * Added references to xbattbar-acpi (Closes: #430609) -- Davide Truffa Sun, 01 Jul 2007 18:15:54 +0200 xbattbar (1.4.2-4) unstable; urgency=high * Build-depend on xutils-dev for the X11R7 transition, and adjust the packaging to use the FHS paths (closes: #366400) * Bumped Standards-Version to 3.7.2 * Bumped debhelper compatibility level to 4.0.0 -- Thomas Seyrat Mon, 8 May 2006 17:32:44 +0200 xbattbar (1.4.2-3.1) unstable; urgency=low * Non-maintainer upload. * Remove Build-Dependency on xlibs-dev (Closes: #346759). * Credit and Big Thanks to Nico Golde for the patch and testing. -- Amaya Rodrigo Sastre Wed, 18 Jan 2006 16:25:54 +0100 xbattbar (1.4.2-3) unstable; urgency=low * Improved description (thanks to Martin Schulze) (closes: #146973) * Previous upload closes: #146517, #146538 -- Thomas Seyrat Tue, 14 May 2002 21:12:13 +0200 xbattbar (1.4.2-2) unstable; urgency=low * Added missing build dependency on xlibs-dev. -- Thomas Seyrat Mon, 13 May 2002 20:38:14 +0200 xbattbar (1.4.2-1) unstable; urgency=low * Initial Release. (closes: #144739) -- Thomas Seyrat Wed, 1 May 2002 18:10:15 +0200 xbattbar-1.4.9/debian/compat000066400000000000000000000000031360261673100157620ustar00rootroot0000000000000012 xbattbar-1.4.9/debian/control000066400000000000000000000020001360261673100161560ustar00rootroot00000000000000Source: xbattbar Section: x11 Priority: optional Maintainer: Dmitry E. Oboukhov Build-Depends: debhelper (>= 12.0.0), libx11-dev Standards-Version: 4.3.0 VCS-Git: https://salsa.debian.org/debian/xbattbar.git VCS-Browser: https://salsa.debian.org/debian/xbattbar Package: xbattbar Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Recommends: acpi Description: Display battery status in X11 Xbattbar displays the current (laptop) battery status in the X window environment. Battery status is obtained through the APM interface. . The battery indicator of this program is very simple: a simple bar at the top/bottom of your display. With its color, it indicates the AC-line status (plugged in or off-line), and battery charging/remaining level. Also, if the mouse cursor enters the indicator window, a popup diagnosis window comes up in the center of your display showing the current AC line status and battery level. . This package supports ACPI and APM checks for battery status. xbattbar-1.4.9/debian/copyright000066400000000000000000000025621360261673100165230ustar00rootroot00000000000000This package was debianized by Thomas Seyrat on Mon, 29 Apr 2002 14:37:09 +0200. The current Debian maintainer is Davide truffa It was downloaded from http://iplab.aist-nara.ac.jp/member/suguru/xbattbar.html It was modified by Dmitry E. Oboukhov Upstream Author: Suguru Yamaguchi Copyright (c) 1998-2001 Suguru Yamaguchi Copyright (c) Dmitry E. Oboukhov License: 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. On Debian systems, the complete text of the GNU General Public License, version 2, can be found in /usr/share/common-licenses/GPL-2. The Debian packaging is (C) 2007, Davide Truffa and is licensed under the GPL, see above. xbattbar-1.4.9/debian/docs000066400000000000000000000000071360261673100154330ustar00rootroot00000000000000README xbattbar-1.4.9/debian/menu000066400000000000000000000001701360261673100154500ustar00rootroot00000000000000?package(xbattbar):needs="X11" section="Applications/System/Monitoring"\ title="Xbattbar" command="/usr/bin/xbattbar" xbattbar-1.4.9/debian/rules000077500000000000000000000017651360261673100156540ustar00rootroot00000000000000#!/usr/bin/make -f #export DH_VERBOSE=1 build: build-stamp build-stamp: dh_testdir $(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp $(MAKE) clean dh_clean install: build dh_testdir dh_testroot dh_installdirs $(MAKE) install OS_TYPE=linux DESTDIR=$(CURDIR)/debian/xbattbar build-arch: build-stamp build-indep: build-stamp binary-indep: build install binary-arch: build install dh_testdir dh_testroot dh_installmenu dh_installdocs dh_installchangelogs dh_link dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb package_version := $(shell dpkg-parsechangelog \ |grep ^Version|awk '{print $$2}'|sed 's/-.*//') tarball: test -d ../xbattbar-$(package_version) cd .. && tar --exclude=debian --exclude=.git -czvf \ xbattbar_$(package_version).orig.tar.gz \ xbattbar-$(package_version) binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure xbattbar-1.4.9/debian/source/000077500000000000000000000000001360261673100160635ustar00rootroot00000000000000xbattbar-1.4.9/debian/source/format000066400000000000000000000000141360261673100172710ustar00rootroot000000000000003.0 (quilt) xbattbar-1.4.9/xbattbar-check-acpi000077500000000000000000000035771360261673100170770ustar00rootroot00000000000000#!/usr/bin/perl # ************************************************************************* # * * # * Copyright (C) 2009 Dmitry E. Oboukhov * # * * # * This program 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, either version 3 of the License, or * # * (at your option) any later version. * # * * # * This program 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 program. If not, see . * # * * # ************************************************************************* use warnings; use strict; my $acpi; die "Can not start acpi: $!\n" unless open $acpi, '-|', 'acpi', '-b', '-a'; my @acpi = <$acpi>; my @battery = grep { defined ($_) and /^\d+$/ } map { s/^.*\s+(\d+)\%.*/$1/s; $_ } grep /Battery\s+\d+:/, @acpi; die "Can not get battery level\n" unless @battery; my $battery = 0; $battery += $_ for @battery; $battery /= scalar(grep { $_ } @battery) || 1; my $ac = grep /Adapter.*on-line/, @acpi; printf "battery=%d\nac_line=%s\n", $battery, $ac?"on":"off"; xbattbar-1.4.9/xbattbar-check-apm.c000066400000000000000000000147071360261673100171530ustar00rootroot00000000000000/* * Copyright (c) 1998-2001 Suguru Yamaguchi * * This program 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; either version 2 of the License, or (at * your option) any later version. * * This program 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 program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Modified 2009 by Dmitry E. Oboukhov : * SRC has been split to two parts: bar and battery-check * This part contains APM battery-check part of xbattbar */ #include #include #include static int ac_line = -1; /* AC line status */ static int battery_level = -1; /* battery level */ void battery_check(void); int main(int argc, char **argv) { battery_check(); if (battery_level == -1) { fprintf(stderr, "Can not get battery level\n"); return 1; } printf("battery=%d\nac_line=%s\n", battery_level, ac_line?"on":"off"); return 0; } #ifdef __bsdi__ #include #include int first = 1; void battery_check(void) { int fd; struct apmreq ar ; ar.func = APM_GET_POWER_STATUS ; ar.dev = APM_DEV_ALL ; if ((fd = open(_PATH_DEVAPM, O_RDONLY)) < 0) { perror(_PATH_DEVAPM) ; exit(1) ; } if (ioctl(fd, PIOCAPMREQ, &ar) < 0) { fprintf(stderr, "xbattbar: PIOCAPMREQ: APM_GET_POWER_STATUS error 0x%x\n", ar.err); } close (fd); if (first || ac_line != ((ar.bret >> 8) & 0xff) || battery_level != (ar.cret&0xff)) { first = 0; ac_line = (ar.bret >> 8) & 0xff; battery_level = ar.cret&0xff; } } #endif /* __bsdi__ */ #if defined __FreeBSD__ || defined __FreeBSD_kernel__ #include #include #define APMDEV21 "/dev/apm0" #define APMDEV22 "/dev/apm" #define APM_STAT_UNKNOWN 255 #define APM_STAT_LINE_OFF 0 #define APM_STAT_LINE_ON 1 #define APM_STAT_BATT_HIGH 0 #define APM_STAT_BATT_LOW 1 #define APM_STAT_BATT_CRITICAL 2 #define APM_STAT_BATT_CHARGING 3 int first = 1; void battery_check(void) { int fd, r, p; struct apm_info info; if ((fd = open(APMDEV21, O_RDWR)) == -1 && (fd = open(APMDEV22, O_RDWR)) == -1) { fprintf(stderr, "xbattbar: cannot open apm device\n"); exit(1); } if (ioctl(fd, APMIO_GETINFO, &info) == -1) { fprintf(stderr, "xbattbar: ioctl APMIO_GETINFO failed\n"); exit(1); } close (fd); /* get current status */ if (info.ai_batt_life == APM_STAT_UNKNOWN) { switch (info.ai_batt_stat) { case APM_STAT_BATT_HIGH: r = 100; break; case APM_STAT_BATT_LOW: r = 40; break; case APM_STAT_BATT_CRITICAL: r = 10; break; default: /* expected to be APM_STAT_UNKNOWN */ r = 100; } } else if (info.ai_batt_life > 100) { /* some APM BIOSes return values slightly > 100 */ r = 100; } else { r = info.ai_batt_life; } /* get AC-line status */ if (info.ai_acline == APM_STAT_LINE_ON) { p = APM_STAT_LINE_ON; } else { p = APM_STAT_LINE_OFF; } if (first || ac_line != p || battery_level != r) { first = 0; ac_line = p; battery_level = r; } } #endif /* __FreeBSD__ */ #ifdef __NetBSD__ #include #define _PATH_APM_SOCKET "/var/run/apmdev" #define _PATH_APM_CTLDEV "/dev/apmctl" #define _PATH_APM_NORMAL "/dev/apm" int first = 1; void battery_check(void) { int fd, r, p; struct apm_power_info info; if ((fd = open(_PATH_APM_NORMAL, O_RDONLY)) == -1) { fprintf(stderr, "xbattbar: cannot open apm device\n"); exit(1); } if (ioctl(fd, APM_IOC_GETPOWER, &info) != 0) { fprintf(stderr, "xbattbar: ioctl APM_IOC_GETPOWER failed\n"); exit(1); } close(fd); /* get current remoain */ if (info.battery_life > 100) { /* some APM BIOSes return values slightly > 100 */ r = 100; } else { r = info.battery_life; } /* get AC-line status */ if (info.ac_state == APM_AC_ON) { p = APM_AC_ON; } else { p = APM_AC_OFF; } if (first || ac_line != p || battery_level != r) { first = 0; ac_line = p; battery_level = r; } } #endif /* __NetBSD__ */ #ifdef __linux__ #include #include #define APM_PROC "/proc/apm" #define APM_STAT_LINE_OFF 0 #define APM_STAT_LINE_ON 1 typedef struct apm_info { const char driver_version[10]; int apm_version_major; int apm_version_minor; int apm_flags; int ac_line_status; int battery_status; int battery_flags; int battery_percentage; int battery_time; int using_minutes; } apm_info; int first = 1; void battery_check(void) { int r,p; FILE *pt; struct apm_info i; char buf[100]; /* get current status */ errno = 0; if ( (pt = fopen( APM_PROC, "r" )) == NULL) { fprintf(stderr, "xbattbar: Can't read proc info: %s\n", strerror(errno)); _exit(1); } if (fgets(buf, sizeof(buf) - 1, pt) == NULL) { fprintf(stderr, "xbattbar: Can't read proc info: %s\n", strerror(errno)); _exit(1); } buf[ sizeof( buf ) - 1 ] = '\0'; sscanf( buf, "%s %d.%d %x %x %x %x %d%% %d %d\n", &i.driver_version[0], &i.apm_version_major, &i.apm_version_minor, &i.apm_flags, &i.ac_line_status, &i.battery_status, &i.battery_flags, &i.battery_percentage, &i.battery_time, &i.using_minutes ); fclose (pt); /* some APM BIOSes return values slightly > 100 */ if ( (r = i.battery_percentage) > 100 ){ r = 100; } /* get AC-line status */ if ( i.ac_line_status == APM_STAT_LINE_ON) { p = APM_STAT_LINE_ON; } else { p = APM_STAT_LINE_OFF; } if (first || ac_line != p || battery_level != r) { first = 0; ac_line = p; battery_level = r; } } #endif /* linux */ xbattbar-1.4.9/xbattbar-check-sys000077500000000000000000000013201360261673100167610ustar00rootroot00000000000000#!/usr/bin/perl use strict; unless (-r '/sys/class/power_supply/AC/online') { die "not found '/sys/class/power_supply/AC/online'\n"; } my $ac = 'off'; if (int `cat /sys/class/power_supply/AC/online`) { $ac = 'on'; } my @bats; { for $b (glob '/sys/class/power_supply/BAT?') { next unless -d $b; next unless -r "$b/energy_now"; next unless -r "$b/energy_full"; my $full = int `cat $b/energy_full`; my $now = int `cat $b/energy_now`; next unless $full and $now; push @bats => $now * 100.0 / $full; } } if (@bats) { my $total = 0; $total += $_ for @bats; printf "battery=%d\n", $total / @bats; } print "ac_line=$ac\n"; xbattbar-1.4.9/xbattbar.c000066400000000000000000000355211360261673100153220ustar00rootroot00000000000000/* * $Id: xbattbar.c,v 1.16.2.4 2001/02/02 05:25:29 suguru Exp $ * * xbattbar: yet another battery watcher for X11 */ /* * Copyright (c) 1998-2001 Suguru Yamaguchi * * This program 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; either version 2 of the License, or (at * your option) any later version. * * This program 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 program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Modified 2009 by Dmitry E. Oboukhov : * SRC has been split to two parts: bar and battery-check * This part contains bar part of xbattbar */ static char *ReleaseVersion="1.4.2"; #include #include #include #include #include #include #include #include #include #include #include #include #include #define PollingInterval 10 /* APM polling interval in sec */ #define BI_THICKNESS 3 /* battery indicator thickness in pixels */ #define BI_Bottom 0 #define BI_Top 1 #define BI_Left 2 #define BI_Right 3 #define BI_Horizontal ((bi_direction & 2) == 0) #define BI_Vertical ((bi_direction & 2) == 2) #define myEventMask (ExposureMask|EnterWindowMask|LeaveWindowMask|VisibilityChangeMask) #define DefaultFont "fixed" #define DiagXMergin 20 #define DiagYMergin 5 /* * Global variables */ int ac_line = -1; /* AC line status */ int battery_level = -1; /* battery level */ unsigned long onin, onout; /* indicator colors for AC online */ unsigned long offin, offout; /* indicator colors for AC offline */ int elapsed_time = 0; /* for battery remaining estimation */ /* indicator default colors */ char *ONIN_C = "green"; char *ONOUT_C = "olive drab"; char *OFFIN_C = "blue"; char *OFFOUT_C = "red"; char *EXTERNAL_CHECK = "/usr/lib/xbattbar/xbattbar-check-apm"; char *EXTERNAL_CHECK_ACPI = "/usr/lib/xbattbar/xbattbar-check-acpi"; char *EXTERNAL_CHECK_SYS = "/usr/lib/xbattbar/xbattbar-check-sys"; int alwaysontop = False; struct itimerval IntervalTimer; /* APM polling interval timer */ int bi_direction = BI_Bottom; /* status bar location */ int bi_height; /* height of Battery Indicator */ int bi_width; /* width of Battery Indicator */ int bi_x; /* x coordinate of upper left corner */ int bi_y; /* y coordinate of upper left corner */ int bi_thick = BI_THICKNESS; /* thickness of Battery Indicator */ int bi_interval = PollingInterval; /* interval of polling APM */ Display *disp; Window winbar; /* bar indicator window */ Window winstat = -1; /* battery status window */ GC gcbar; GC gcstat; unsigned int width,height; XEvent theEvent; /* * function prototypes */ void InitDisplay(void); Status AllocColor(char *, unsigned long *); void battery_check(void); void plug_proc(int); void battery_proc(int); void redraw(void); void showdiagbox(void); void disposediagbox(void); void usage(char **); void about_this_program(void); void estimate_remain(void); /* * usage of this command */ void about_this_program() { fprintf(stderr, "This is xbattbar version %s, " " Copyright (c) 1998-2001 Suguru Yamaguchi\n" " modified 2009 by Dmitry E. Oboukhov \n", ReleaseVersion); } void usage(char **argv) { fprintf(stderr, "\n" "usage:\t%s [-a] [-h|v] [-p sec] [-t thickness]\n" "\t\t[-I color] [-O color] [-i color] [-o color]\n" "\t\t[ top | bottom | left | right ]\n" "-a: always on top.\n" "-v, -h: show this message.\n" "-t: bar (indicator) thickness. [def: 3 pixels]\n" "-p: polling interval. [def: 10 sec.]\n" "-I, -O: bar colors in AC on-line. [def: \"green\" & \"olive drab\"]\n" "-i, -o: bar colors in AC off-line. [def: \"blue\" and \"red\"]\n" "top, bottom, left, right: bar localtion. [def: \"bottom\"]\n" "\n" "-c: use ACPI checker for getting battery status\n" "-s script: use external script for getting battery status\n", argv[0]); _exit(0); } /* * AllocColor: * convert color name to pixel value */ Status AllocColor(char *name, unsigned long *pixel) { XColor color,exact; int status; status = XAllocNamedColor(disp, DefaultColormap(disp, 0), name, &color, &exact); *pixel = color.pixel; return(status); } /* * InitDisplay: * create small window in top or bottom */ void InitDisplay(void) { Window root; int x,y; unsigned int border,depth; XSetWindowAttributes att; if((disp = XOpenDisplay(NULL)) == NULL) { fprintf(stderr, "xbattbar: can't open display.\n"); _exit(1); } if(XGetGeometry(disp, DefaultRootWindow(disp), &root, &x, &y, &width, &height, &border, &depth) == 0) { fprintf(stderr, "xbattbar: can't get window geometry\n"); _exit(1); } if (!AllocColor(ONIN_C,&onin) || !AllocColor(OFFOUT_C,&offout) || !AllocColor(OFFIN_C,&offin) || !AllocColor(ONOUT_C,&onout)) { fprintf(stderr, "xbattbar: can't allocate color resources\n"); _exit(1); } switch (bi_direction) { case BI_Top: /* (0,0) - (width, bi_thick) */ bi_width = width; bi_height = bi_thick; bi_x = 0; bi_y = 0; break; case BI_Bottom: bi_width = width; bi_height = bi_thick; bi_x = 0; bi_y = height - bi_thick; break; case BI_Left: bi_width = bi_thick; bi_height = height; bi_x = 0; bi_y = 0; break; case BI_Right: bi_width = bi_thick; bi_height = height; bi_x = width - bi_thick; bi_y = 0; } winbar = XCreateSimpleWindow(disp, DefaultRootWindow(disp), bi_x, bi_y, bi_width, bi_height, 0, BlackPixel(disp,0), WhitePixel(disp,0)); /* make this window without its titlebar */ att.override_redirect = True; XChangeWindowAttributes(disp, winbar, CWOverrideRedirect, &att); XMapWindow(disp, winbar); gcbar = XCreateGC(disp, winbar, 0, 0); } main(int argc, char **argv) { extern char *optarg; extern int optind; int ch; about_this_program(); while ((ch = getopt(argc, argv, "at:f:hI:i:O:o:p:vs:cr")) != -1) switch (ch) { case 'c': EXTERNAL_CHECK = EXTERNAL_CHECK_ACPI; break; case 'r': EXTERNAL_CHECK = EXTERNAL_CHECK_SYS; break; case 's': EXTERNAL_CHECK = optarg; break; case 'a': alwaysontop = True; break; case 't': case 'f': bi_thick = atoi(optarg); break; case 'I': ONIN_C = optarg; break; case 'i': OFFIN_C = optarg; break; case 'O': ONOUT_C = optarg; break; case 'o': OFFOUT_C = optarg; break; case 'p': bi_interval = atoi(optarg); break; case 'h': case 'v': usage(argv); break; } argc -= optind; argv += optind; if (argc > 0) { if (strcasecmp(*argv, "top") == 0) bi_direction = BI_Top; else if (strcasecmp(*argv, "bottom") == 0) bi_direction = BI_Bottom; else if (strcasecmp(*argv, "left") == 0) bi_direction = BI_Left; else if (strcasecmp(*argv, "right") == 0) bi_direction = BI_Right; } /* * set APM polling interval timer */ if (!bi_interval) { fprintf(stderr,"xbattbar: can't set interval timer\n"); _exit(1); } alarm(bi_interval); /* * X Window main loop */ InitDisplay(); signal(SIGALRM, (void *)(battery_check)); battery_check(); XSelectInput(disp, winbar, myEventMask); while (1) { XWindowEvent(disp, winbar, myEventMask, &theEvent); switch (theEvent.type) { case Expose: /* we redraw our window since our window has been exposed. */ redraw(); break; case EnterNotify: /* create battery status message */ showdiagbox(); break; case LeaveNotify: /* destroy status window */ disposediagbox(); break; case VisibilityNotify: if (alwaysontop) XRaiseWindow(disp, winbar); break; default: /* for debugging */ fprintf(stderr, "xbattbar: unknown event (%d) captured\n", theEvent.type); } } } void redraw(void) { if (ac_line) { plug_proc(battery_level); } else { battery_proc(battery_level); } estimate_remain(); } void showdiagbox(void) { XSetWindowAttributes att; XFontStruct *fontp; XGCValues theGC; int pixw, pixh; int boxw, boxh; char diagmsg[64]; /* compose diag message and calculate its size in pixels */ sprintf(diagmsg, "AC %s-line: battery level is %d%%", ac_line ? "on" : "off", battery_level); fontp = XLoadQueryFont(disp, DefaultFont); pixw = XTextWidth(fontp, diagmsg, strlen(diagmsg)); pixh = fontp->ascent + fontp->descent; boxw = pixw + DiagXMergin * 2; boxh = pixh + DiagYMergin * 2; /* create status window */ if(winstat != -1) disposediagbox(); winstat = XCreateSimpleWindow(disp, DefaultRootWindow(disp), (width-boxw)/2, (height-boxh)/2, boxw, boxh, 2, BlackPixel(disp,0), WhitePixel(disp,0)); /* make this window without time titlebar */ att.override_redirect = True; XChangeWindowAttributes(disp, winstat, CWOverrideRedirect, &att); XMapWindow(disp, winstat); theGC.font = fontp->fid; gcstat = XCreateGC(disp, winstat, GCFont, &theGC); XDrawString(disp, winstat, gcstat, DiagXMergin, fontp->ascent+DiagYMergin, diagmsg, strlen(diagmsg)); } void disposediagbox(void) { if ( winstat != -1 ) { XDestroyWindow(disp, winstat); winstat = -1; } } void battery_proc(int left) { int pos; if (BI_Horizontal) { pos = width * left / 100; XSetForeground(disp, gcbar, offin); XFillRectangle(disp, winbar, gcbar, 0, 0, pos, bi_thick); XSetForeground(disp, gcbar, offout); XFillRectangle(disp, winbar, gcbar, pos, 0, width, bi_thick); } else { pos = height * left / 100; XSetForeground(disp, gcbar, offin); XFillRectangle(disp, winbar, gcbar, 0, height-pos, bi_thick, height); XSetForeground(disp, gcbar, offout); XFillRectangle(disp, winbar, gcbar, 0, 0, bi_thick, height-pos); } XFlush(disp); } void plug_proc(int left) { int pos; if (BI_Horizontal) { pos = width * left / 100; XSetForeground(disp, gcbar, onin); XFillRectangle(disp, winbar, gcbar, 0, 0, pos, bi_thick); XSetForeground(disp, gcbar, onout); XFillRectangle(disp, winbar, gcbar, pos+1, 0, width, bi_thick); } else { pos = height * left / 100; XSetForeground(disp, gcbar, onin); XFillRectangle(disp, winbar, gcbar, 0, height-pos, bi_thick, height); XSetForeground(disp, gcbar, onout); XFillRectangle(disp, winbar, gcbar, 0, 0, bi_thick, height-pos); } XFlush(disp); } /* * estimating time for battery remaining / charging */ #define CriticalLevel 5 void estimate_remain() { static int battery_base = -1; int diff; int remain; /* static value initialize */ if (battery_base == -1) { battery_base = battery_level; return; } diff = battery_base - battery_level; if (diff == 0) return; /* estimated time for battery remains */ if (diff > 0) { remain = elapsed_time * (battery_level - CriticalLevel) / diff ; remain = remain * bi_interval; /* in sec */ if (remain < 0 ) remain = 0; printf("battery remain: %2d hr. %2d min. %2d sec.\n", remain / 3600, (remain % 3600) / 60, remain % 60); elapsed_time = 0; battery_base = battery_level; return; } /* estimated time of battery charging */ remain = elapsed_time * (battery_level - 100) / diff; remain = remain * bi_interval; /* in sec */ printf("charging remain: %2d hr. %2d min. %2d sec.\n", remain / 3600, (remain % 3600) / 60, remain % 60); elapsed_time = 0; battery_base = battery_level; } #define TEMP_BUFFER_SIZE 4096 int read_pipe(int pipe, char *buffer) { int rd = read(pipe, buffer, TEMP_BUFFER_SIZE - 1); if (rd == -1) { perror("read pipe"); return 0; } buffer[rd] = 0; return rd; } #define BATTERY_STRING "battery=" #define AC_LINE_STRING "ac_line=" void print_script_error(void) { fprintf(stderr, "\nExternal script must print two strings:\n" "\t" BATTERY_STRING "value between 0 and 100\n" "\t" AC_LINE_STRING "on|off\n" "example 1:\n" "\t" BATTERY_STRING "25\n" "\t" AC_LINE_STRING "on\n" "example 2:\n" "\t" BATTERY_STRING "75\n" "\t" AC_LINE_STRING "off\n" ); } void battery_check(void) { int p[2], pid; char buffer[TEMP_BUFFER_SIZE]; if (pipe(p) != 0) { perror("error create pipe"); goto exit_check; } pid = fork(); if (pid == -1) { perror("fork error"); close(p[0]); close(p[1]); goto exit_check; } if (pid) { /* parent */ int len, status; close(p[1]); char *str, *end; pid = waitpid(pid, &status, 0); if (pid == -1) { perror("waitpid"); close(p[0]); goto exit_check; } if (status != 0) { fprintf(stderr, "child process (%s) has returned " "non-zero code: %d\n", EXTERNAL_CHECK, WEXITSTATUS(status)); len = read_pipe(p[0], buffer); if (len > 0) printf("%s\n", buffer); close(p[0]); goto exit_check; } len = read_pipe(p[0], buffer); close(p[0]); if (!len) { print_script_error(); goto exit_check; } str = strstr(buffer, BATTERY_STRING); if (!str) { print_script_error(); goto exit_check; } str += sizeof(BATTERY_STRING) - 1; if (!*str) { print_script_error(); goto exit_check; } status = strtol(str, &end, 10); if ((*end != '\n' && *end != '.' && *end != '\0' && *end != ' ' && *end != '%') || end == str) { print_script_error(); goto exit_check; } battery_level = status; if (battery_level > 100) fprintf(stderr, "Incorrect battery level " " has been received: %d%%\n", battery_level); if (strstr(buffer, AC_LINE_STRING "on")) ac_line = 1; else ac_line = 0; /* printf("Received battery level: %d%%, ac_line: %s\n", */ /* battery_level, ac_line?"on":"off"); */ } else { /* child */ char *argv[] = { EXTERNAL_CHECK, NULL }; close(p[0]); if (dup2(p[1], fileno(stdout)) == -1) { perror("dup2 error"); _exit(errno); } execvp(EXTERNAL_CHECK, argv); fprintf(stderr, "Exec %s error: %s\n", EXTERNAL_CHECK, strerror(errno)); _exit(-1); } exit_check: elapsed_time++; redraw(); signal(SIGALRM, (void *)(battery_check)); alarm(bi_interval); } xbattbar-1.4.9/xbattbar.man000066400000000000000000000065011360261673100156470ustar00rootroot00000000000000.\" .\" $Id: xbattbar.man,v 1.13.2.1 2001/02/02 05:25:29 suguru Exp $ .\" .\" Copyright (c) 1998-2001 Suguru Yamaguchi .\" .\" This program 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; either version 2 of the License, or (at .\" your option) any later version. .\" .\" This program 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 program; if not, write to the Free Software .\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. .\" .Dd December 5, 1998 .Dt XBATTBAR 1 .Os .Sh NAME .Nm xbattbar .Nd show battery status in X Window .Sh SYNOPSIS .Nm xbattbar .Op Fl a .Op Fl t Ar thickness .Op Fl p Ar interval .Op Fl I Ar color .Op Fl O Ar color .Op Fl i Ar color .Op Fl o Ar color .Op Fl c .Op Fl r .Op Fl s Ar script-name .Op Ar top | bottom | left | right .Sh DESCRIPTION .Nm xbattbar shows the current (laptop) battery status in the X window environment. Battery status is obtained through the APM kernel module. The APM kernel module depends on your UNIX platform, therefore, consult your documentation for its detail. .Pp .Nm xbattbar shows its battery status in a simple bar indicator. .Nm -a option makes the indicator window keep always on top of your screen. The thickness of the indicator is 3 pixels in default and you can set the thickness as a parameter of .Nm -t option. This indicator is appeared in the bottom of the display, as its default. The option .Nm top, .Nm left, or .Nm right forces the status indicator to be at the top, left, and right of the display, respectively. Though it's a default, you can also use .Nm buttom as the option. .Pp In the case the AC line is on-line (plugged in), its color of the bar indicator consists of "green" and "olive drab" portions. The "green" portion shows its battery charging level. These colors can be changed by .Nm -I and .Nm -O options. In the other case (AC line is off-line), the "blue" portion of the bar indicator shows the percentage of its remaining battery level. The color conbination for the AC off-line case can be changed by .Nm -i and .Nm -o options. .Pp .Nm xbattbar tries to know its battery status in every 10 seconds in default. This is achived by APM polling. .Pp If it is used with option .Nm -c then ACPI polling will be used. .Pp If it is used with option .Nm -r then sysfs polling will be used (thanks to Elena Grandi for the script). .Pp You can use your external script for check battery status. It must print two lines to .Nm STDOUT .Nm 'battery=value' and .Nm 'ac_line=on|off .Pp .Nm -p option sets the polling interval in second. .Pp If the mouse cursor enters in the status indicator, the diagnosis window appears in the center of the display, which shows both AC line status and battery remaining level. This diagnosis window disappears if the mouse cursor leaves from the status indicator. .Sh AUTHOR Suguru Yamaguchi , Akira Kato , Noriyuki Shigechika , Dmitry E. Oboukhov