apmd-3.2.2.orig/0000755001167100001440000000000010044353073013331 5ustar cphusers00000000000000apmd-3.2.2.orig/apm.10000644001167100001440000000553107775760270014216 0ustar cphusers00000000000000.\" apm.1 -- .\" Created: Wed Jan 10 14:54:03 1996 by r.faith@ieee.org .\" Revised: Sun Apr 21 16:37:43 1996 by r.faith@ieee.org .\" Copyright 1996 Rickard E. Faith (r.faith@ieee.org) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .TH APM 1 "January 2004" "" "" .SH NAME apm \- interface with the APM subsystem .SH SYNOPSIS .B apm [ \-VvmMsSdin ] .SH DESCRIPTION This command requires the Advanced Power Management subsystem. If run without arguments it reads .I /proc/apm and presents the output in a human-readable format. .P Given a .B \-S or .B \-s option it requests that the machine be put into the APM standby or the APM suspend state, respectively. For a brief description of these states, see .BR apmd (8). .SH OPTIONS .TP .B \-V, \-\-version Print the version of the program and exit. .TP .B \-v, \-\-verbose Also print version information for the APM subsystem. The APM subsystem consists of power-management hardware, firmware usually referred to as the APM BIOS and a driver in the operating system kernel. .TP .B \-m, \-\-minutes Print the time remaining as a number of minutes. The default is to print the time remaining in "hours:minutes" format. .TP .B \-M, \-\-monitor Continuously monitor and update the status information. Assumes that the standard output is a terminal. .TP .B \-S, \-\-standby Request that the machine be put into the APM standby state. .TP .B \-s, \-\-suspend Request that the machine be put into the APM suspend state. .TP .B \-d, \-\-debug Print APM status information in a format more useful for debugging. Implies \-v. .SH FILES .I /proc/apm .SH AUTHOR This program was written by Rik Faith (faith@cs.unc.edu) and may be freely distributed under the terms of the GNU General Public License. There is ABSOLUTELY NO WARRANTY for this program. The current maintainer is Avery Pennarun (apenwarr@worldvisions.ca). .SH "SEE ALSO" .BR xapm (1), .BR apmd (8). apmd-3.2.2.orig/COPYING0000644001167100001440000004311007775741511014402 0ustar cphusers00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 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) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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) year 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. apmd-3.2.2.orig/abilitize/0000755001167100001440000000000007775742465015335 5ustar cphusers00000000000000apmd-3.2.2.orig/abilitize/stephen-disenable-patch0000644001167100001440000001343707077236425021744 0ustar cphusers00000000000000From worldvisions@worldvisions.ca Wed Apr 19 00:05:03 2000 Received: from worldvisions by insight.worldvisions.ca with local (Exim 3.12 #1 (Debian)) id 12hljb-0005DV-00; Wed, 19 Apr 2000 00:05:03 -0400 Received: from localhost [127.0.0.1] (apenwarr) by insight.worldvisions.ca with esmtp (Exim 3.12 #1 (Debian)) id 12hljb-0005DP-00; Wed, 19 Apr 2000 00:05:03 -0400 Received: from www.bond.net by localhost with POP3 (fetchmail-5.2.3) for worldvisions@localhost (single-drop); Wed, 19 Apr 2000 00:05:03 -0400 (EDT) Received: from front.linuxcare.com.au (root@linuxcare.com.au [203.29.91.49]) by ns4.bond.net (8.9.3/8.9.3) with ESMTP id AAA19564 for ; Wed, 19 Apr 2000 00:04:46 -0400 (EDT) Received: from elm.linuxcare.com.au (elm.linuxcare.com.au [10.61.2.17]) by front.linuxcare.com.au (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id OAA12011 for ; Wed, 19 Apr 2000 14:04:43 +1000 Received: from linuxcare.com (localhost [127.0.0.1]) by elm.linuxcare.com.au (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id OAA03706 for ; Wed, 19 Apr 2000 14:04:41 +1000 Message-Id: <200004190404.OAA03706@elm.linuxcare.com.au> X-Authentication-Warning: elm.linuxcare.com.au: Host localhost [127.0.0.1] claimed to be linuxcare.com To: apenwarr@worldvisions.ca Subject: apmd patch for --{dis,en}able MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3703.956117081.1@linuxcare.com> Date: Wed, 19 Apr 2000 14:04:41 +1000 From: Stephen Rothwell X-UIDL: pdhd9Yh5e9P6]!!Sn+!! Sender: Status: RO X-Status: A Content-Length: 4242 Lines: 170 Hi Avery, Since I am adding stuff to the kernel apm driver, I figured I might as well patch apmd at the same time. So here is my first apmd patch. Please feel free to modify it to your own style etc ... Cheers, Stephen -- Stephen Rothwell, Open Source Project Engineer, Linuxcare, Inc. +61-2-62628990 tel, +61-2-62628991 fax sfr@linuxcare.com, http://www.linuxcare.com/ Linuxcare. Support for the revolution. diff -ruN apmd-3.0final/apm.c apmd-3.0final-sfr/apm.c --- apmd-3.0final/apm.c Mon Oct 18 14:37:48 1999 +++ apmd-3.0final-sfr/apm.c Tue Apr 18 15:26:21 2000 @@ -51,8 +51,12 @@ case IGNORE: case NOIGNORE: error = apm_set_ignore(fd, mode); - apm_close(fd); - return; + break; +#endif +#ifdef APM_IOC_ENABLE + case ENABLE: + case DISABLE: + error = apm_enable(fd, mode == ENABLE); break; #endif default: @@ -60,9 +64,15 @@ break; } - if (error != 0) - perror("apm"); - else + if (error != 0) { +#ifdef APM_IOC_LAST_ERROR + if (errno == EIO) + fprintf(stderr, "apm: %s\n", + apm_error_name(apm_last_error(fd))); + else +#endif + perror("apm"); + } else time(&now); apm_close(fd); @@ -71,11 +81,21 @@ void usage(void) { fprintf(stderr, - "usage: apm [-vmsSin] [--verbose] [--minutes] [--suspend] [--standby]"); -#ifdef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */ - fprintf(stderr, " [--ignore] [--noignore]"); + "usage: apm [-vmsS" +#ifdef APM_IOC_IGNORE + "in" +#endif +#ifdef APM_IOC_ENABLE + "ED" +#endif + "] [--verbose] [--minutes] [--suspend] [--standby]" +#ifdef APM_IOC_IGNORE + " [--ignore] [--noignore]" +#endif +#ifdef APM_IOC_ENABLE + " [--disable] [--enable]" #endif - fprintf(stderr, "\n"); + "\n"); exit(1); } @@ -99,31 +119,44 @@ {"ignore", 0, 0, 'i'}, {"noignore", 0, 0, 'n'}, #endif +#ifdef APM_IOC_ENABLE + {"enable", 0, 0, 'E'}, + {"disable", 0, 0, 'D'}, +#endif {NULL, 0, 0, 0} }; + char options[20]; extern int opterr; - opterr = 0; -#ifndef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */ - while ((c = getopt_long(argc, argv, "VvsSdm", longopts, NULL)) != -1) -#else - while ((c = getopt_long(argc, argv, "VvsSdmin", longopts, NULL)) != -1) + strcpy(options, "VvsSdm"); +#ifdef APM_IOC_IGNORE + strcat(options, "in"); #endif +#ifdef APM_IOC_ENABLE + strcat(options, "DE"); +#endif + opterr = 0; + while ((c = getopt_long(argc, argv, options, longopts, NULL)) != -1) switch (c) { case 'V': fprintf(stderr, "apm version %s\n", VERSION); exit(0); - break; +#ifdef APM_IOC_ENABLE + case 'E': + change_state(ENABLE); + exit(0); + case 'D': + change_state(DISABLE); + exit(0); +#endif #ifdef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */ case 'i': change_state(IGNORE); exit(0); - break; case 'n': change_state(NOIGNORE); exit(0); - break; #endif case 'v': ++verbose; diff -ruN apmd-3.0final/apm.h apmd-3.0final-sfr/apm.h --- apmd-3.0final/apm.h Tue Jul 6 08:31:11 1999 +++ apmd-3.0final-sfr/apm.h Tue Apr 18 14:40:07 2000 @@ -57,6 +57,7 @@ extern int apm_suspend(int fd); extern int apm_standby(int fd); extern int apm_set_ignore(int fd, int mode); +extern int apm_enable(int fd, int mode); extern unsigned int apm_last_error(int fd); extern const char *apm_error_name( unsigned int err ); extern int apm_reject(int fd); @@ -69,6 +70,8 @@ #define STANDBY 1 #define IGNORE 2 #define NOIGNORE 3 +#define ENABLE 4 +#define DISABLE 5 /* Linux Kernel APM drivers version 1.10 and higher permit suspend rejections. */ diff -ruN apmd-3.0final/apmlib.c apmd-3.0final-sfr/apmlib.c --- apmd-3.0final/apmlib.c Tue Aug 3 14:26:43 1999 +++ apmd-3.0final-sfr/apmlib.c Tue Apr 18 15:01:46 2000 @@ -364,6 +364,13 @@ } #endif +#ifdef APM_IOC_ENABLE +int apm_enable(int fd, int mode) +{ + return ioctl(fd, APM_IOC_ENABLE, &mode); +} +#endif + /* Return a string describing the event. From p. 16 of the Intel/Microsoft * Advanded Power Management (APM) BIOS Interface Specification, Revision * 1.1 (September 1993). Intel Order Number: 241704-001. Microsoft Part apmd-3.2.2.orig/apm.c0000644001167100001440000001526607775737534014315 0ustar cphusers00000000000000/* apm.c -- Simple APM interface * Created: Mon Jan 8 10:28:16 1996 by faith@acm.org * Revised: Fri Dec 26 20:34:25 1997 by faith@acm.org * Copyright 1996, 1997 Rickard E. Faith (faith@acm.org) * * 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, 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. * */ #include #include #include #include #include #include #include #include #include #include #include "apm.h" static int verbose = 0; /* mode codes for change_state() */ #define SUSPEND 0 #define STANDBY 1 #define IGNORE 2 #define NOIGNORE 3 void change_state(int mode) { int fd; time_t then, now; int error; fd = open(APM_DEVICE, O_WRONLY); if (fd < 0) { fprintf(stderr, "Cannot open APM device: %s\n", strerror(errno)); exit(1); } time(&then); switch (mode) { case SUSPEND: error = apm_suspend(fd); break; case STANDBY: error = apm_standby(fd); break; #ifdef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */ case IGNORE: case NOIGNORE: error = apm_set_ignore(fd, mode); apm_close(fd); return; break; #endif default: error = 0; break; } if (error != 0) perror("apm"); else time(&now); apm_close(fd); } void usage(void) { fprintf(stderr, "usage: apm [-VvmMsSd"); #ifdef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */ fprintf(stderr, "in"); #endif fprintf(stderr, "] [--verbose] [--minutes] [--monitor] [--suspend] [--standby]"); #ifdef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */ fprintf(stderr, " [--ignore] [--noignore]"); #endif fprintf(stderr, "\n"); exit(1); } int main(int argc, char **argv) { apm_info i; int suspend = 0; int standby = 0; int debug = 0; int displayMinutes = 0; int monitor = 0; int c; struct option longopts[] = { {"version", 0, 0, 'V'}, {"verbose", 0, 0, 'v'}, {"suspend", 0, 0, 's'}, {"standby", 0, 0, 'S'}, {"debug", 0, 0, 'd'}, {"minutes", 0, 0, 'm'}, {"monitor", 0, 0, 'M'}, #ifdef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */ {"ignore", 0, 0, 'i'}, {"noignore", 0, 0, 'n'}, #endif {NULL, 0, 0, 0} }; extern int opterr; opterr = 0; #ifndef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */ while ((c = getopt_long(argc, argv, "VvsSdmM", longopts, NULL)) != -1) #else while ((c = getopt_long(argc, argv, "VvsSdmMin", longopts, NULL)) != -1) #endif switch (c) { case 'V': fprintf(stderr, "apm version %s\n", VERSION); exit(0); break; #ifdef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */ case 'i': change_state(IGNORE); exit(0); break; case 'n': change_state(NOIGNORE); exit(0); break; #endif case 'v': ++verbose; break; case 's': ++suspend; break; case 'S': ++standby; break; case 'd': ++debug; ++verbose; break; case 'm': ++displayMinutes; break; case 'M': ++monitor; break; default: usage(); break; } switch (apm_exists()) { case 1: fprintf(stderr, "No APM support in kernel\n"); exit(1); case 2: fprintf(stderr, "Old APM support in kernel\n"); exit(2); } if (suspend && standby) usage(); if (suspend || standby) { change_state((suspend ? SUSPEND : STANDBY)); exit(0); } if (apm_read(&i)) { fprintf(stderr, "Cannot read APM information\n"); exit(1); } if (verbose) printf("APM BIOS %d.%d (kernel driver %s)\n", i.apm_version_major, i.apm_version_minor, i.driver_version); if (monitor) { int secs, q = 0; char battery[32], output[128] = "", buf[128] = ""; while(1) { apm_read(&i); secs = i.using_minutes ? i.battery_time * 60 : i.battery_time; if(displayMinutes) sprintf(battery, "%d min", secs / 60); else sprintf(battery, "%s", apm_time(secs)); sprintf(output, "Line : %s \nBattery: %d%% (%s) ", i.ac_line_status == 0 ? "off" : "on ", i.battery_percentage, battery); if(q == 0 || !strcmp(buf, output)) { printf("\e[H\e[J%s\n", output); q = 1; } strcpy(buf, output); sleep(1); } } if (!(i.apm_flags & APM_32_BIT_SUPPORT)) { fprintf(stderr, "32-bit APM interface not supported\n"); exit(1); } if (verbose && (i.apm_flags & 0x10)) printf("APM BIOS Power Management is currently disabled\n"); if (verbose && (i.apm_flags & 0x20)) printf("APM BIOS Power Management is currently disengaged\n"); switch (i.ac_line_status) { case 0: printf("Off-line"); break; case 1: printf("On-line"); break; case 2: printf("On backup power"); break; } if (i.battery_flags != 0xff /* Have a 1.1 BIOS and a system battery. */ && i.battery_flags & 0x80) { printf(", no system battery"); } else { /* Even if battery_flags == 0xff, some 1.0 * BIOSs provide this information. If we * have it, use it. */ switch (i.battery_status) { case 0: printf(", battery status high"); break; case 1: printf(", battery status low"); break; case 2: printf(", battery status critical"); break; case 3: printf(", battery charging"); break; } if (i.battery_percentage >= 0) printf(": %d%%", i.battery_percentage); if (i.battery_time >= 0) { int secs = i.using_minutes ? i.battery_time * 60 : i.battery_time; if (displayMinutes) printf(" (%d min)", secs / 60); else printf(" (%s)", apm_time(secs)); } } printf("\n"); if (debug) { printf("Using device 0x%04lx, %s: %d.%d\n", (unsigned long) apm_dev(), i.driver_version, i.apm_version_major, i.apm_version_minor); printf("APM Flags = 0x%02x; Line Status = 0x%02x\n", i.apm_flags, i.ac_line_status); printf("Battery Status = 0x%02x; Battery Flags = 0x%02x\n", i.battery_status, i.battery_flags); printf("Battery %%age = %4d; Battery Time = %4d, use_mins=%d\n", i.battery_percentage, i.battery_time, i.using_minutes); } return 0; } apmd-3.2.2.orig/apmd.c0000644001167100001440000007270310044353073014427 0ustar cphusers00000000000000/* apmd.c -- APM event-monitoring daemon * Copyright 1996, 1997 Rickard E. Faith (faith@acm.org) * * 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, 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. */ #include #include #include #include #include #include #include #include #include #include #include #include "apm.h" #include #include #include #include #include #ifndef DEFAULT_PROXY_NAME #define DEFAULT_PROXY_NAME /etc/apmd_proxy #endif #ifndef DEFAULT_PROXY_TIMEOUT #define DEFAULT_PROXY_TIMEOUT 30 #endif #ifndef DEFAULT_CHECK_INTERVAL #define DEFAULT_CHECK_INTERVAL 30 #endif #ifndef DEFAULT_VERBOSITY #define DEFAULT_VERBOSITY LOG_NOTICE #endif /* Rate calcs over shorter times than this are bogus */ #ifndef MINIMUM_RATE_CALC_TIME #define MINIMUM_RATE_CALC_TIME 120 #endif /* * For the verbosity level feature to be useful, * we rely on the fact that syslog.h assigns adjacent * integer values to the following log level macros: * LOG_NOTICE * LOG_INFO * LOG_DEBUG * and we also assume that * LOG_ALERT * LOG_ERR * LOG_WARNING * are *less* than any of the above. */ #if ((defined (__STDC_VERSION__)) && (__STDC_VERSION__ >= 199901L)) #define APMD_SYSLOG(lev, ...) do \ { \ if ((lev) <= verbosity) syslog((lev), __VA_ARGS__); \ } while(0) #else #ifdef __GNUC__ #define APMD_SYSLOG(lev, args...) do \ { \ if ((lev) <= verbosity) syslog((lev), args); \ } while(0) #endif /* __GNUC__ */ #endif /* __STDC_VERSION__ >= 199901L */ #define APMD_TRACE0(lev, fmt) \ APMD_SYSLOG ((lev), "%s(): " fmt, __FUNCTION__) #define APMD_TRACE1(lev, fmt, arg) \ APMD_SYSLOG ((lev), "%s(): " fmt, __FUNCTION__, arg) #define PID_FILE _PATH_VARRUN "apmd.pid" #define MAX_EVENTS 8 /* Maximum events we accept from BIOS driver */ #define RESUME_HOURS 6 /* If resuming after N hours, show as days */ /* * These are events generated by APMD itself. The benefit is * that we can do a simple lookup into the event dispatch * table. (We're trusting that the APM BIOS spec doesn't get * updated to use these particular "reserved" codes for * anything...) */ #define APMD_START 0xad00 #define APMD_STOP 0xad01 #define APMD_PSEUDO_EVENT 0xad03 /* * This table defines how events are handled. For each event type * there is a flag indicating whether the proxy should be run, * and a flag indicating whether the event should be logged. */ struct action { apm_event_t event; int call_proxy; int log; }; /* * These actions are listed here in the order * in which they will be processed when several * of them are received at the same time * * N.B. CRITICAL_SUSPEND and UPDATE_TIME may not be sent * to us by the APM subsystem, for performance reasons. */ static struct action actions[] = { {APMD_START, 1, 1}, /* Generated by apmd */ /* APM_CRITICAL_SUSPEND omitted */ {APM_CRITICAL_RESUME, 1, 1}, {APM_STANDBY_RESUME, 1, 1}, {APM_NORMAL_RESUME, 1, 1}, #ifdef APM_CAPABILITY_CHANGE {APM_CAPABILITY_CHANGE, 1, 1}, #endif {APM_POWER_STATUS_CHANGE, 1, 1}, {APM_LOW_BATTERY, 1, 1}, {APM_SYS_STANDBY, 1, 1}, {APM_USER_STANDBY, 1, 1}, {APM_UPDATE_TIME, 1, 1}, #if doing_something_on_pseudo_events {APMD_PSEUDO_EVENT, 0, 0}, /* Generated by apmd */ #endif {APM_SYS_SUSPEND, 1, 1}, {APM_USER_SUSPEND, 1, 1}, {APMD_STOP, 1, 1} /* Generated by apmd */ }; #define NUM_ACTIONS (sizeof(actions)/sizeof(struct action)) /* From parsing the command line: */ static char *proxy_name = DEFAULT_PROXY_NAME; static int proxy_timeout = -1; /* -1=never */ static int wall; /* = 0 */ static int check_interval = -1; /* -1=infinity */ static int ignore_bios_batlow; /* = 0 */ static int percent_change = 5; static int quiet_bios_batlow; /* = 0 */ static int verbosity = DEFAULT_VERBOSITY; static int warn_level = 10; static uid_t apmd_uid = 0; static int apmd_fd = -1; #ifndef abs #define abs(a) ((a)<0?(-(a)):(a)) #endif #define IS_CHARGING(i) ( \ ((i).battery_status == BATTERY_STATUS_CHARGING) \ || ((i).battery_flags & BATTERY_FLAGS_CHARGING) \ ) #define IS_LOW(i) ( \ ((i).battery_status == BATTERY_STATUS_LOW) \ || ((i).battery_flags & BATTERY_FLAGS_LOW) \ ) #define IS_ABSENT(i) ( \ ((i).battery_status == BATTERY_STATUS_ABSENT) \ || ((i).battery_flags & BATTERY_FLAGS_ABSENT) \ ) #define ISNT_ON_LINE(i) ((i).ac_line_status == AC_LINE_STATUS_OFF) static void option_barf(FILE *fd) { fprintf( fd, "apmd: Try `apmd --help' for usage information.\n" ); } static void usage(FILE *fd) { fprintf( fd, "Usage: apmd [-TVWciqv] [-P cmd] [-T seconds] [-c seconds]" " [-p percent] [-v level] [-w percent] [--help]\n" ); } /* * call_proxy() is a generic outcalling dispatcher. It calls a * proxy program named by proxy_name which can do further event * processing. Returns the code returned by the proxy program, * which is meant to signal rejection of a suspend request * (except that such rejection isn't supported by the kernel yet). */ static int call_proxy(apm_event_t event) { const char *argv[4] = {NULL, NULL, NULL, NULL}; int i, fds[2]; pid_t pid; char line[256]; APMD_TRACE1(LOG_DEBUG, "0x%04x", event); if (!strlen(proxy_name)) { /* Proxy name set to null string */ return 0; } for (i=0; i 0) { line[len] = 0; APMD_SYSLOG(LOG_INFO, "+ %s", line); } retval = waitpid(pid, &status, WNOHANG); if (retval == pid) goto proxy_done; if (retval < 0) { APMD_TRACE1(LOG_ERR, "waitpid() failed: %s", strerror(errno)); status = __W_EXITCODE(0, SIGTERM) | __WCOREFLAG; goto proxy_done; } sleep(1); } while ( (time(0) < time_limit) || (proxy_timeout < 0) ); APMD_SYSLOG(LOG_NOTICE, "Proxy has been running more than %d seconds; killing it", proxy_timeout); kill(pid, SIGTERM); time_limit = time(0) + 5; do { retval = waitpid(pid, &status, WNOHANG); if (retval == pid) goto proxy_done; if (retval < 0) { APMD_TRACE1(LOG_ERR, "waitpid() failed: %s", strerror(errno)); status = __W_EXITCODE(0, SIGTERM) | __WCOREFLAG; goto proxy_done; } sleep(1); } while (time(0) < time_limit); kill(pid, SIGKILL); status = __W_EXITCODE(0, SIGKILL); proxy_done: /* Flush any remaining data */ while ((len = read(fds[0], line, sizeof(line)-1)) > 0) { line[len] = 0; APMD_SYSLOG(LOG_INFO, "+ %s", line); } close(fds[0]); /* Collect the exit code */ if (WIFEXITED(status)) { APMD_SYSLOG( WEXITSTATUS(status) ? LOG_NOTICE : LOG_DEBUG, "Proxy exited with status %d", WEXITSTATUS(status) ); return WEXITSTATUS(status); } else { APMD_SYSLOG(LOG_NOTICE, "Proxy exited on signal %d", WTERMSIG(status)); return 0; } } } static inline int apmd_time(apm_info * apmi) { return (apmi->battery_time * (apmi->using_minutes ? 60 : 1)); } static char *ac_line_status_descr (int status) { if (status == AC_LINE_STATUS_OFF) return "battery"; else if (status == AC_LINE_STATUS_ON) return "line"; else if (status == AC_LINE_STATUS_BACKUP) return "backup"; else return "?"; } static const char *battery_status_descr (apm_info * apmi) { return IS_ABSENT(*apmi) ? "absent" : IS_CHARGING(*apmi) ? "charging" : ISNT_ON_LINE(*apmi) ? "discharging" : "not charging"; } /* * Generic logging function. Depending on the event type * and actions table, the event may or may not be logged. */ static void apmd_log_event(apm_event_t event, char *msg) { int i; for (i=0; ibattery_percentage; ioctl(apmd_fd, APM_IOC_SUSPEND, NULL); break; case APMD_START: /* Initialise */ call_proxy(event); last_marked_time = time(0); last_marked_content = apmi->battery_percentage; last_logged_content = -1; last_ac_line_status = apmi->ac_line_status; last_battery_charging = IS_CHARGING(*apmi); last_battery_absent = IS_ABSENT(*apmi); suppress_bios_batlow = 0; suppress_apmd_batlow = 0; return; /* Yes, return */ case APM_SYS_SUSPEND: case APM_USER_SUSPEND: switch (event) { case APM_SYS_SUSPEND: apmd_log_event(event, "System Suspend"); break; case APM_USER_SUSPEND: apmd_log_event(event, "User Suspend"); break; } do_suspend = 1; if (call_proxy(event)) { APMD_SYSLOG(LOG_NOTICE, "Suspend rejected by proxy"); if (apm_reject(apmd_fd) == -EINVAL) { APMD_SYSLOG(LOG_INFO, "Rejection is not supported by the apm subsystem. Proceeding with suspend."); } else { /* Rejection succeeded */ do_suspend = 0; } } do_log_batstatus = 1; do_mark = 1; break; case APM_SYS_STANDBY: case APM_USER_STANDBY: switch (event) { case APM_SYS_STANDBY: apmd_log_event(event, "System Standby"); break; case APM_USER_STANDBY: apmd_log_event(event, "User Standby"); break; } do_standby = 1; if (call_proxy(event)) { APMD_SYSLOG(LOG_NOTICE, "Standby rejected by proxy"); if (apm_reject(apmd_fd) == -EINVAL) { APMD_SYSLOG(LOG_INFO, "Rejection is not supported by the apm subsystem. Proceeding with standby."); } else { /* Rejection succeeded */ do_standby = 0; } } do_log_batstatus = 1; do_mark = 1; break; case APM_CRITICAL_RESUME: case APM_NORMAL_RESUME: case APM_STANDBY_RESUME: switch(event) { case APM_CRITICAL_RESUME: apmd_log_event(event, "Critical Resume"); break; case APM_NORMAL_RESUME: apmd_log_event(event, "Normal Resume"); break; case APM_STANDBY_RESUME: apmd_log_event(event, "Standby Resume"); break; } call_proxy(event); do_log_batstatus = 1; do_mark = 1; suppress_bios_batlow = 0; suppress_apmd_batlow = 0; break; case APM_UPDATE_TIME: apmd_log_event(event, "Update Time"); call_proxy(event); do_mark = 1; break; case APM_POWER_STATUS_CHANGE: /* * With some APM BIOSes, power status changes can happen a LOT, * e.g., for each change of estimated battery life (minutes, * seconds, percent) when charging or discharging, battery full, * empty, add/remove battery, etc. Invoking the proxy on every * such event could be wasteful. Therefore, we just check * (below) for power source changes. */ /* apmd_log_event(event, "Power Status Change"); */ sleep(1); /* Wait for info to be updated after the change */ if(apm_read(apmi)) return; break; case APM_LOW_BATTERY: if (!ignore_bios_batlow && !suppress_bios_batlow && !suppress_apmd_batlow) { if (!quiet_bios_batlow) do_notify_batlow = 1; do_proxy_batlow = 1; } suppress_bios_batlow = 1; break; #ifdef APM_CAPABILITY_CHANGE case APM_CAPABILITY_CHANGE: apmd_log_event(event, "Capability Change"); call_proxy(event); break; #endif case APMD_PSEUDO_EVENT: #if doing_something_on_pseudo_events apmd_log_event(event, "Performing APM status check"); call_proxy(event); #endif break; default: /* These aren't errors; see the APM BIOS 1.2 spec. * 0x000d-0x00ff reserved system events * 0x0100-0x01ff reserved device events * 0x0200-0x02ff OEM-defined * 0x0300-0xffff reserved */ APMD_SYSLOG(LOG_ERR, "Received unknown event 0x%04x!!", event); break; } /* switch */ /* * Check for power source or charging changes. * * The main use for this is to give the proxy program the * opportunity to reduce power consumption when running * on batteries or charging them. */ if ( apmi->ac_line_status != last_ac_line_status || IS_CHARGING(*apmi) != last_battery_charging ) { sprintf( msg, "Using %s power%s%s%s", ac_line_status_descr(apmi->ac_line_status), ISNT_ON_LINE(*apmi) ? "" : "; ", ISNT_ON_LINE(*apmi) ? "" : battery_status_descr(apmi), ISNT_ON_LINE(*apmi) ? "" : " battery" ); apmd_log_event(APM_POWER_STATUS_CHANGE, msg); call_proxy(APM_POWER_STATUS_CHANGE); do_log_batstatus = 1; do_mark = 1; suppress_bios_batlow = 0; suppress_apmd_batlow = 0; last_ac_line_status = apmi->ac_line_status; last_battery_charging = IS_CHARGING(*apmi); } /* * Check for battery insertion or removal */ if ( IS_ABSENT(*apmi) != last_battery_absent ) { do_log_batstatus = 1; last_battery_absent = IS_ABSENT(*apmi); } /* * Some BIOSes fail to generate LOW BATTERY events, * so we generate our own. */ if (!ignore_bios_batlow) { if ( IS_LOW(*apmi) && !IS_CHARGING(*apmi) && ISNT_ON_LINE(*apmi) ) { if (!suppress_bios_batlow && !suppress_apmd_batlow) { if (!quiet_bios_batlow) do_notify_batlow = 1; do_proxy_batlow = 1; } suppress_bios_batlow = 1; } else { suppress_bios_batlow = 0; } } if ( warn_level >= 0 && apmi->battery_percentage >= 0 && apmi->battery_percentage <= 100 ) { if ( apmi->battery_percentage <= warn_level && !IS_CHARGING(*apmi) && ISNT_ON_LINE(*apmi) ) { if (!suppress_bios_batlow && !suppress_apmd_batlow) { do_notify_batlow = 1; do_proxy_batlow = 1; } suppress_apmd_batlow = 1; } else { suppress_apmd_batlow = 0; } } if ( do_notify_batlow ) { FILE *str; syslog(LOG_ALERT, "Warning: %s", "BATTERY IS LOW"); /* Details will be given below if available */ if (wall) { str = popen("wall", "w"); fprintf(str, "Warning: %s\n", "BATTERY IS LOW"); pclose(str); } } if ( do_proxy_batlow ) { call_proxy(APM_LOW_BATTERY); } /* * If battery is now full or empty, reset charge rate calcs */ if ( (apmi->battery_percentage == 0 && last_marked_content != 0) || (apmi->battery_percentage == 100 && last_marked_content != 100) ) do_mark = 1; do_warn_batlow = do_notify_batlow; if ( (apmi->battery_percentage >= 0 && apmi->battery_percentage <= 100) && apmi->battery_percentage != last_logged_content && apmi->battery_percentage <= warn_level && !IS_CHARGING(*apmi) && ISNT_ON_LINE(*apmi) ) do_warn_batlow = 1; if ( (apmi->battery_percentage >= 0 && apmi->battery_percentage <= 100) && apmi->battery_percentage != last_logged_content && ( apmi->battery_percentage == 0 || apmi->battery_percentage == 100 ) ) do_log_batstatus = 1; if ( (apmi->battery_percentage >= 0 && apmi->battery_percentage <= 100) && apmi->battery_percentage != last_logged_content && abs(apmi->battery_percentage - last_logged_content) >= percent_change ) do_log_batstatus = 1; if ( IS_ABSENT(*apmi) ) { /* Battery absent */ len = sprintf( msg, "Battery: %s", battery_status_descr(apmi) ); } else if (apmi->battery_percentage < 0 || apmi->battery_percentage > 100) { /* Battery content value invalid */ len = sprintf( msg, "Battery: ?%%, %s", battery_status_descr(apmi) ); } else { /* Current battery content percentage value OK */ int dt = time(0) - last_marked_time; int dp = apmi->battery_percentage - last_marked_content; int do_estimate_rate = last_marked_time > 0 && dt > 0 && last_marked_content >= 0 && last_marked_content <= 100; len = sprintf( msg, "Battery: %d%%, %s", apmi->battery_percentage, battery_status_descr(apmi) ); if ( event == APM_CRITICAL_RESUME || event == APM_NORMAL_RESUME || event == APM_STANDBY_RESUME ) { /* We are resuming */ if ( do_estimate_rate ) { if ( dt > (60 * 60 * RESUME_HOURS) && !IS_CHARGING(*apmi) && dp < 0 ) { /* * Suspend lasted a long time, so print the * discharge rate in percentage points per day */ len += sprintf( msg + len, " (%+.2f%%/day over %s)", 60 * 60 * 24 * (double)dp / (double)dt, apm_time(dt) ); } else { /* * Suspend didn't last a long time, so just print * the change in content */ len += sprintf( msg + len, " (%+d%% over %s)", dp, apm_time(dt) ); } } } else { /* We are not resuming */ double ppm = dt ? (60. * (double)dp / (double)dt) : -1; if ( do_estimate_rate && dt >= MINIMUM_RATE_CALC_TIME && ( (dp > 0 && IS_CHARGING(*apmi)) || (dp < 0 && !IS_CHARGING(*apmi)) ) && ppm <= 10. /* Battery charging faster than 10%/min? Bogus! */ ) { len += sprintf( msg + len, " (%+.2f%%/min over %s)", ppm, apm_time(dt) ); } len += sprintf( msg + len, ", %s", apm_time(apmd_time(apmi)) ); if ( do_estimate_rate && dt >= MINIMUM_RATE_CALC_TIME && dp > 0 && IS_CHARGING(*apmi) ) { len += sprintf( msg + len, " to empty (%s to full)", apm_time((int)( (100 - apmi->battery_percentage) * (double)dt/dp )) ); } else if ( do_estimate_rate && dt >= MINIMUM_RATE_CALC_TIME && dp < 0 && !IS_CHARGING(*apmi) ) { len += sprintf( msg + len, " (%s) to empty", apm_time((int)( apmi->battery_percentage * (double)dt/-dp )) ); } else { /* Rate is not valid */ len += sprintf( msg + len, " to empty" ); } } } if (do_warn_batlow) { syslog(LOG_ALERT, "Warning: %s", msg); last_logged_content = apmi->battery_percentage; } else if (do_log_batstatus) { APMD_SYSLOG(LOG_INFO, "%s", msg); last_logged_content = apmi->battery_percentage; } if (do_mark) { last_marked_time = time(0); last_marked_content = apmi->battery_percentage; } if (do_suspend) apmd_suspend(); if (do_standby) apmd_standby(); return; } static void sig_handler(int sig) { APMD_SYSLOG(LOG_INFO, "Exiting"); call_proxy(APMD_STOP); unlink(PID_FILE); exit(0); } int main(int argc, char **argv) { int c; int pid; FILE *str; apm_info apminfo; apm_event_t events[MAX_EVENTS]; static struct option longopts[] = { {"proxy", required_argument, NULL, 'P'}, {"apmd-proxy", required_argument, NULL, 'P'}, {"apmd_proxy", required_argument, NULL, 'P'}, {"proxy-timeout", optional_argument, NULL, 'T'}, {"proxy_timeout", optional_argument, NULL, 'T'}, {"apmd-proxy-timeout", optional_argument, NULL, 'T'}, {"apmd_proxy_timeout", optional_argument, NULL, 'T'}, {"version", no_argument, NULL, 'V'}, {"wall", no_argument, NULL, 'W'}, {"check", optional_argument, NULL, 'c'}, {"ignore-bios-battery-low", no_argument, NULL, 'i'}, {"ignore_bios_battery_low", no_argument, NULL, 'i'}, {"percentage", required_argument, NULL, 'p'}, {"quiet-bios-battery-low", no_argument, NULL, 'q'}, {"quiet_bios_battery_low", no_argument, NULL, 'q'}, {"verbose", optional_argument, NULL, 'v'}, {"warn", required_argument, NULL, 'w'}, {"help", no_argument, NULL, 'h'}, {0, 0, 0, 0} }; switch (apm_exists()) { case 1: fprintf(stderr, "No APM support in kernel\n"); exit(1); case 2: fprintf(stderr, "Old APM support in kernel\n"); exit(2); } /* switch */ opterr = 1; /* Switch on getopt() error message */ while ((c=getopt_long(argc, argv, "P:T::VWc::ip:quv::w:", longopts, NULL)) != -1) { switch (c) { case 'P': if (optarg) proxy_name = optarg; break; case 'T': if (optarg) { proxy_timeout = atoi(optarg); } else if ( optind=LOG_DEBUG)?LOG_PERROR:0 | LOG_PID | LOG_CONS, LOG_DAEMON); /* Set up signal handler */ if (signal(SIGINT, SIG_IGN) != SIG_IGN) signal(SIGINT, sig_handler); if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) signal(SIGQUIT, sig_handler); if (signal(SIGTERM, SIG_IGN) != SIG_IGN) signal(SIGTERM, sig_handler); /* Write the pidfile */ if ((pid = fork())) { /* parent */ if (pid < 0) { APMD_TRACE0(LOG_ERR, "fork() failed: %m"); unlink(PID_FILE); exit(1); } /* We forked */ if ((str = fopen(PID_FILE, "w"))) { fprintf(str, "%d\n", pid); fclose(str); } exit(0); } /* * child * * Follow the daemon rules in W. Richard Stevens, * _Advanced Programming in the UNIX Environment_, * Addison-Wesley Publishing Co., 1992, p. 417. */ if (setsid() < 0) { APMD_TRACE0(LOG_ERR, "setsid() failed: %m"); unlink(PID_FILE); exit(1); } chdir("/"); close(0); close(1); if (verbosity < LOG_DEBUG) close(2); umask(0); apmd_fd = open(APM_DEVICE, O_RDWR); if (apmd_fd < 0) { APMD_TRACE0(LOG_ERR, "open() failed: %m"); unlink(PID_FILE); exit(1); } /* apmd_fd is good */ if (apm_read(&apminfo)) { APMD_TRACE0(LOG_ERR, "apm_read() failed: %m"); unlink(PID_FILE); exit(1); } /* apm_read() works */ APMD_SYSLOG( LOG_NOTICE, "apmd %s interfacing with apm driver %s and APM BIOS %d.%d", VERSION, apminfo.driver_version, apminfo.apm_version_major, apminfo.apm_version_minor ); APMD_SYSLOG( LOG_INFO, "apmd operating parameters: -T %d, -c %d, -p %d, -v %d, -w %d", proxy_timeout, check_interval, percent_change, verbosity, warn_level ); handle_event(APMD_START, &apminfo); for (;;) { int num_events = apm_get_events(apmd_fd, check_interval, events, MAX_EVENTS); int e, a; apm_read(&apminfo); if (num_events == 0) { /* The call timed out */ handle_event(APMD_PSEUDO_EVENT, &apminfo); continue; } /* num_events > 0 */ for (a = 0; a < NUM_ACTIONS; a++) /* Process events in actions-table order */ for (e = 0; e < num_events; e++) /* ... and then in order received */ { apm_event_t event = events[e]; if (event != actions[a].event) continue; APMD_SYSLOG( LOG_DEBUG, "APM event 0x%04x: %s", event, apm_event_name(event) ); handle_event(event, &apminfo); } /* for for */ } /* for */ return 0; } apmd-3.2.2.orig/xbattery/0000755001167100001440000000000007556326371015212 5ustar cphusers00000000000000apmd-3.2.2.orig/xbattery/Makefile0000644001167100001440000005014506751375403016653 0ustar cphusers00000000000000# Makefile generated by imake - do not edit! # $TOG: imake.c /main/97 1997/06/20 20:23:51 kaleb $ # ---------------------------------------------------------------------- # Makefile generated from "Imake.tmpl" and # $TOG: Imake.tmpl /main/245 1997/05/20 10:05:47 kaleb $ # # # # # $XFree86: xc/config/cf/Imake.tmpl,v 3.32.2.8 1998/02/08 11:19:24 dawes Exp $ # Debian: changed InstIncFlags, InstManFlags, InstDatFlags from 0444 to 0644 # ---------------------------------------------------------------------- all:: .SUFFIXES: .i # $TOG: Imake.cf /main/28 1997/06/25 08:31:36 barstow $ # $XFree86: xc/config/cf/Imake.cf,v 3.34.2.4 1998/05/22 16:38:18 dawes Exp $ # ----------------------------------------------------------------------- # site-specific configuration parameters that need to come before # the platform-specific parameters - edit site.def to change # site: $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $ # site: $XFree86: xc/config/cf/site.def,v 3.17.2.1 1997/06/22 10:32:21 dawes Exp $ # Debian: added define TermcapLibrary -lncurses # $XFree86: xc/config/cf/xf86site.def,v 3.101.2.15 1998/02/24 19:05:42 hohndel Exp $ # Debian: define HasTk 1 # changed TkLibDir, TkIncDir, TkLibName # define HasTcl 1 # changed TclLibDir, TclIncDir, TclLibName # define XserverNeedsSetUID 0 # define JoystickSupport 1 (except for m68k) # define WacomSupport 1 # define ElographicsSupport 1 # define SummaSketchSupport 1 # define BuildDynamicLoading 1 # define ForceNormalLib 1 # ---------------------------------------------------------------------- # platform-specific configuration parameters - edit linux.cf to change # platform: $TOG: linux.cf /main/36 1997/06/16 22:21:03 kaleb $ # platform: $XFree86: xc/config/cf/linux.cf,v 3.57.2.12 1998/03/01 01:57:10 dawes Exp $ # Debian: added -D_REENTRANT to StandardDefines # added define SetTtyGroup 1 # added define HasZlib 1 # operating system: Linux 2.2.10 i586 [ELF] (2.2.10) # libc: (6.0.7) # binutils: (29) # $XConsortium: lnxLib.rules /main/13 1996/09/28 16:11:01 rws $ # $XFree86: xc/config/cf/lnxLib.rules,v 3.28.2.3 1997/06/22 10:32:20 dawes Exp $ # Debian: define BaseShLibReqs -lc, argument below # added -lc to SharedLibraryLoadFlags # removed ExtraLoadFlags # $XFree86: xc/config/cf/xfree86.cf,v 3.129.2.22 1998/02/24 19:05:43 hohndel Exp $ # $XConsortium: xfree86.cf /main/34 1996/12/06 11:45:18 rws $ LINKKITDIR = $(USRLIBDIR)/Server XF98LINKKITDIR = $(USRLIBDIR)/Server XF86SRC = $(SERVERSRC)/hw/xfree86 XF86ACCELSRC = $(XF86SRC)/accel XF86COMSRC = $(XF86SRC)/common XF86CONFIGSRC = $(XF86COMSRC) XF86HWSRC = $(XF86SRC)/common_hw XF86OSSRC = $(XF86SRC)/os-support VGADRIVERSRC = $(XF86SRC)/vga256/drivers VGA16DRIVERSRC = $(XF86SRC)/vga16/drivers VGA2DRIVERSRC = $(XF86SRC)/vga2/drivers MONODRIVERSRC = $(XF86SRC)/mono/drivers S3DRIVERSRC = $(XF86SRC)/accel/s3/drivers S3VDRIVERSRC = $(XF86SRC)/accel/s3_virge/drivers XF68SRC = $(SERVERSRC)/hw/xfree68 XF68COMSRC = $(XF68SRC)/common XF68CONFIGSRC = $(XF68COMSRC) XF68OSSRC = $(XF68SRC)/os-support XF98SRC = $(SERVERSRC)/hw/xfree98 XF98ACCELSRC = $(XF98SRC)/accel XF98COMSRC = $(XF98SRC)/common XF98CONFIGSRC = $(XF98COMSRC) XF98HWSRC = $(XF98SRC)/common_hw/generic XF98HWNECSRC = $(XF98SRC)/common_hw/nec XF98HWPWSKBSRC = $(XF98SRC)/common_hw/pwskb XF98HWPWLBSRC = $(XF98SRC)/common_hw/pwlb XF98HWGA968SRC = $(XF98SRC)/common_hw/ga968 XF98OSSRC = $(XF98SRC)/os-support XF98VGADRIVERSRC = $(XF98SRC)/vga256/drivers XF98VGA16DRIVERSRC = $(XF98SRC)/vga16/drivers XF98VGA2DRIVERSRC = $(XF98SRC)/vga2/drivers XF98MONODRIVERSRC = $(XF98SRC)/mono/drivers XF98NECS3DRIVERSRC = $(XF98SRC)/accel/s3nec/drivers XF98PWSKBDRIVERSRC = $(XF98SRC)/accel/s3pwskb/drivers XF98PWLBDRIVERSRC = $(XF98SRC)/accel/s3pwlb/drivers XF98GA968DRIVERSRC = $(XF98SRC)/accel/s3ga968/drivers XFREE86DOCDIR = $(LIBDIR)/doc XFREE86PSDOCDIR = $(XFREE86DOCDIR)/PostScript XFREE86HTMLDOCDIR = $(XFREE86DOCDIR)/html XFREE86JAPANESEDOCDIR = $(XFREE86DOCDIR)/Japanese # $XConsortium: xf86.rules /main/9 1996/10/31 14:54:26 kaleb $ # $XFree86: xc/config/cf/xf86.rules,v 3.16.2.1 1997/05/18 12:00:01 dawes Exp $ # ---------------------------------------------------------------------- # site-specific configuration parameters that go after # the platform-specific parameters - edit site.def to change # site: $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $ # site: $XFree86: xc/config/cf/site.def,v 3.17.2.1 1997/06/22 10:32:21 dawes Exp $ # Debian: added define TermcapLibrary -lncurses # --------------------------------------------------------------------- # Imake rules for building libraries, programs, scripts, and data files # rules: $TOG: Imake.rules /main/222 1997/07/17 20:04:40 kaleb $ # rules: $XFree86: xc/config/cf/Imake.rules,v 3.33.2.7 1998/02/06 09:02:17 dawes Exp $ _NULLCMD_ = @ echo -n TKLIBNAME = tk8.0 TKLIBDIR = /usr/lib TCLLIBNAME = tcl8.0 TCLIBDIR = /usr/lib PATHSEP = / SHELL = /bin/sh TOP = . CURRENT_DIR = . IMAKE = imake DEPEND = gccmakedep MKDIRHIER = mkdir -p EXPORTLISTGEN = CONFIGSRC = $(TOP)/config IMAKESRC = $(CONFIGSRC)/imake DEPENDSRC = $(CONFIGSRC)/util INCROOT = /usr/X11R6/include USRLIBDIR = /usr/X11R6/lib VARLIBDIR = /var/lib SHLIBDIR = /usr/X11R6/lib LINTLIBDIR = $(USRLIBDIR)/lint MANPATH = /usr/X11R6/man MANSOURCEPATH = $(MANPATH)/man MANDIR = $(MANSOURCEPATH)1 LIBMANDIR = $(MANSOURCEPATH)3 FILEMANDIR = $(MANSOURCEPATH)5 AR = ar clq BOOTSTRAPCFLAGS = CC = gcc AS = as .SUFFIXES: .cc CXX = c++ CXXFILT = c++filt CXXLIB = CXXDEBUGFLAGS = -O2 -fno-strength-reduce CXXDEPENDINCLUDES = CXXEXTRA_DEFINES = CXXEXTRA_INCLUDES = CXXSTD_DEFINES = -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -D_REENTRANT $(CXXPROJECT_DEFINES) CXXOPTIONS = CXXINCLUDES = $(INCLUDES) $(TOP_INCLUDES) $(CXXEXTRA_INCLUDES) CXXDEFINES = $(CXXINCLUDES) $(CXXSTD_DEFINES) $(THREADS_CXXDEFINES) $(CXXEXTRA_DEFINES) $(DEFINES) CXXFLAGS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(THREADS_CXXFLAGS) $(CXXDEFINES) COMPRESS = compress GZIPCMD = gzip CPP = /lib/cpp $(STD_CPP_DEFINES) PREPROCESSCMD = gcc -E $(STD_CPP_DEFINES) INSTALL = install INSTALLFLAGS = -c LD = ld LEX = flex -l LEXLIB = -lfl YACC = bison -y CCYACC = bison -y LINT = lint LINTLIBFLAG = -C LINTOPTS = -axz LN = ln -s MAKE = make MV = mv -f CP = cp RANLIB = ranlib RANLIBINSTFLAGS = RM = rm -f MANSUFFIX = 1x LIBMANSUFFIX = 3x FILEMANSUFFIX = 5x TROFF = psroff NROFF = nroff MSMACROS = -ms MANMACROS = -man TBL = tbl EQN = eqn NEQN = neqn COL = col DVIPS = dvips LATEX = latex STD_INCLUDES = STD_CPP_DEFINES = -traditional -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -D_REENTRANT $(PROJECT_DEFINES) STD_DEFINES = -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE=500L -D_BSD_SOURCE -D_SVID_SOURCE -D_REENTRANT $(PROJECT_DEFINES) EXTRA_LOAD_FLAGS = EXTRA_LDOPTIONS = EXTRA_LIBRARIES = TAGS = ctags PARALLELMFLAGS = SHAREDCODEDEF = SHLIBDEF = SHLIBLDFLAGS = -shared PICFLAGS = -fPIC CXXPICFLAGS = -fPIC PROTO_DEFINES = -DFUNCPROTO=15 -DNARROWPROTO INSTPGMFLAGS = -s INSTBINFLAGS = -m 0755 INSTUIDFLAGS = -m 4711 INSTLIBFLAGS = -m 0644 INSTINCFLAGS = -m 0644 INSTMANFLAGS = -m 0644 INSTDATFLAGS = -m 0644 INSTKMEMFLAGS = -m 4711 PROJECTROOT = /usr/X11R6 CDEBUGFLAGS = -O2 -fno-strength-reduce CCOPTIONS = ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES) ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES) CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(ALLDEFINES) LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES) LDPRELIB = -L$(USRLIBDIR) LDPOSTLIB = LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS) CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS) LDLIBS = $(LDPOSTLIBS) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) CCLINK = $(CC) CXXLINK = $(CXX) LDSTRIPFLAGS = -x LDCOMBINEFLAGS = -r DEPENDFLAGS = # Not sure this belongs here TKLIBDIR = /usr/lib TKINCDIR = /usr/include/tk TKLIBNAME = tk8.0 TKLIBRARY = -L$(TKLIBDIR) -l$(TKLIBNAME) TCLLIBDIR = /usr/lib TCLINCDIR = /usr/include/tcl TCLLIBNAME = tcl8.0 TCLLIBRARY = -L$(TCLLIBDIR) -l$(TCLLIBNAME) MACROFILE = linux.cf RM_CMD = $(RM) IMAKE_DEFINES = IRULESRC = $(CONFIGDIR) IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/X11.tmpl $(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) $(IRULESRC)/xfree86.cf $(IRULESRC)/xf86.rules $(IRULESRC)/xf86site.def $(IRULESRC)/host.def $(EXTRA_ICONFIGFILES) # $TOG: X11.rules /main/4 1997/04/30 15:23:24 kaleb $ # ---------------------------------------------------------------------- # X Window System Build Parameters and Rules # $TOG: X11.tmpl /main/292 1997/05/20 10:05:59 kaleb $ # # # # # $XFree86: xc/config/cf/X11.tmpl,v 1.8.2.4 1998/01/23 12:35:08 dawes Exp $ # Debian: added clean target # ----------------------------------------------------------------------- # X Window System make variables; these need to be coordinated with rules XTOP = $(TOP) BINDIR = /usr/X11R6/bin BUILDINCROOT = $(TOP)/exports BUILDINCDIR = $(BUILDINCROOT)/include BUILDINCTOP = ../.. BUILDLIBDIR = $(TOP)/exports/lib BUILDLIBTOP = ../.. BUILDBINDIR = $(TOP)/exports/bin BUILDBINTOP = ../.. XBUILDINCROOT = $(XTOP)/exports XBUILDINCDIR = $(XBUILDINCROOT)/include/X11 XBUILDINCTOP = ../../.. XBUILDBINDIR = $(XBUILDINCROOT)/bin INCDIR = $(INCROOT) ADMDIR = /usr/adm LIBDIR = $(USRLIBDIR)/X11 TOP_X_INCLUDES = -I$(XPROJECTROOT)/include VARDIR = /var/X11 FONTDIR = $(LIBDIR)/fonts XINITDIR = $(LIBDIR)/xinit XDMDIR = $(LIBDIR)/xdm XDMVARDIR = $(VARLIBDIR)/xdm TWMDIR = $(LIBDIR)/twm XSMDIR = $(LIBDIR)/xsm NLSDIR = $(LIBDIR)/nls XLOCALEDIR = $(LIBDIR)/locale PEXAPIDIR = $(LIBDIR)/PEX LBXPROXYDIR = $(LIBDIR)/lbxproxy PROXYMANAGERDIR = $(LIBDIR)/proxymngr XPRINTDIR = $(LIBDIR) XAPPLOADDIR = $(LIBDIR)/app-defaults FONTCFLAGS = -t INSTAPPFLAGS = $(INSTDATFLAGS) RGB = rgb FONTC = bdftopcf MKFONTDIR = mkfontdir DOCUTILSRC = $(XTOP)/doc/util CLIENTSRC = $(TOP)/clients DEMOSRC = $(TOP)/demos XDOCMACROS = $(DOCUTILSRC)/macros.t XIDXMACROS = $(DOCUTILSRC)/indexmacros.t PROGRAMSRC = $(TOP)/programs LIBSRC = $(XTOP)/lib FONTSRC = $(XTOP)/fonts INCLUDESRC = $(BUILDINCROOT)/include XINCLUDESRC = $(INCLUDESRC)/X11 SERVERSRC = $(XTOP)/programs/Xserver CONTRIBSRC = $(XTOP)/../contrib UNSUPPORTEDSRC = $(XTOP)/unsupported DOCSRC = $(XTOP)/doc RGBSRC = $(XTOP)/programs/rgb BDFTOPCFSRC = $(PROGRAMSRC)/bdftopcf MKFONTDIRSRC = $(PROGRAMSRC)/mkfontdir FONTSERVERSRC = $(PROGRAMSRC)/xfs FONTINCSRC = $(XTOP)/include/fonts EXTINCSRC = $(XTOP)/include/extensions TRANSCOMMSRC = $(LIBSRC)/xtrans TRANS_INCLUDES = -I$(TRANSCOMMSRC) XENVLIBDIR = $(USRLIBDIR) CLIENTENVSETUP = LD_LIBRARY_PATH=$(XENVLIBDIR) # $XConsortium: lnxLib.tmpl,v 1.5 95/01/11 21:44:44 kaleb Exp $ # $XFree86: xc/config/cf/lnxLib.tmpl,v 3.9 1996/02/24 04:32:52 dawes Exp $ XLIBSRC = $(LIBSRC)/X11 SOXLIBREV = 6.1 DEPXONLYLIB = XONLYLIB = -lX11 LINTXONLY = $(LINTLIBDIR)/llib-lX11.ln XLIBONLY = $(XONLYLIB) XEXTLIBSRC = $(LIBSRC)/Xext SOXEXTREV = 6.3 DEPEXTENSIONLIB = EXTENSIONLIB = -lXext LINTEXTENSION = $(LINTLIBDIR)/llib-lXext.ln LINTEXTENSIONLIB = $(LINTEXTENSION) DEPXLIB = $(DEPEXTENSIONLIB) $(DEPXONLYLIB) XLIB = $(EXTENSIONLIB) $(XONLYLIB) LINTXLIB = $(LINTXONLYLIB) XSSLIBSRC = $(LIBSRC)/Xss DEPXSSLIB = $(USRLIBDIR)/libXss.a XSSLIB = -lXss LINTXSS = $(LINTLIBDIR)/llib-lXss.ln XXF86MISCLIBSRC = $(LIBSRC)/Xxf86misc DEPXXF86MISCLIB = $(USRLIBDIR)/libXxf86misc.a XXF86MISCLIB = -lXxf86misc LINTXXF86MISC = $(LINTLIBDIR)/llib-lXxf86misc.ln XXF86VMLIBSRC = $(LIBSRC)/Xxf86vm DEPXXF86VMLIB = $(USRLIBDIR)/libXxf86vm.a XXF86VMLIB = -lXxf86vm LINTXXF86VM = $(LINTLIBDIR)/llib-lXxf86vm.ln XXF86DGALIBSRC = $(LIBSRC)/Xxf86dga DEPXXF86DGALIB = $(USRLIBDIR)/libXxf86dga.a XXF86DGALIB = -lXxf86dga LINTXXF86DGA = $(LINTLIBDIR)/llib-lXxf86dga.ln XDPMSLIBSRC = $(LIBSRC)/Xdpms DEPXDPMSLIB = $(USRLIBDIR)/libXdpms.a XDPMSLIB = -lXdpms LINTXDPMS = $(LINTLIBDIR)/llib-lXdpms.ln XAUTHSRC = $(LIBSRC)/Xau DEPXAUTHLIB = $(USRLIBDIR)/libXau.a XAUTHLIB = -lXau LINTXAUTH = $(LINTLIBDIR)/llib-lXau.ln XDMCPLIBSRC = $(LIBSRC)/Xdmcp DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a XDMCPLIB = -lXdmcp LINTXDMCP = $(LINTLIBDIR)/llib-lXdmcp.ln XMUSRC = $(LIBSRC)/Xmu SOXMUREV = 6.0 DEPXMULIB = XMULIB = -lXmu LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln OLDXLIBSRC = $(LIBSRC)/oldX DEPOLDXLIB = $(USRLIBDIR)/liboldX.a OLDXLIB = -loldX LINTOLDX = $(LINTLIBDIR)/llib-loldX.ln XPLIBSRC = $(LIBSRC)/Xp SOXPREV = 6.2 DEPXPLIB = XPLIB = -lXp LINTXP = $(LINTLIBDIR)/llib-lXp.ln TOOLKITSRC = $(LIBSRC)/Xt SOXTREV = 6.0 DEPXTOOLONLYLIB = XTOOLONLYLIB = -lXt LINTXTOOLONLY = $(LINTLIBDIR)/llib-lXt.ln DEPXTOOLLIB = $(DEPXTOOLONLYLIB) $(DEPSMLIB) $(DEPICELIB) XTOOLLIB = $(XTOOLONLYLIB) $(SMLIB) $(ICELIB) LINTXTOOLLIB = $(LINTXTOOLONLYLIB) XALIBSRC = $(LIBSRC)/Xa SOXAREV = 1.0 DEPXALIB = XALIB = -lXa LINTXA = $(LINTLIBDIR)/llib-lXa.ln AWIDGETSRC = $(LIBSRC)/Xaw SOXAWREV = 6.1 DEPXAWLIB = XAWLIB = -lXaw LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln XILIBSRC = $(LIBSRC)/Xi SOXINPUTREV = 6.0 DEPXILIB = XILIB = -lXi LINTXI = $(LINTLIBDIR)/llib-lXi.ln XTESTLIBSRC = $(LIBSRC)/Xtst SOXTESTREV = 6.1 DEPXTESTLIB = XTESTLIB = -lXtst LINTXTEST = $(LINTLIBDIR)/llib-lXtst.ln PEXLIBSRC = $(LIBSRC)/PEX5 SOPEXREV = 6.0 DEPPEXLIB = PEXLIB = -lPEX5 LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln XIELIBSRC = $(LIBSRC)/XIE SOXIEREV = 6.0 DEPXIELIB = XIELIB = -lXIE LINTXIE = $(LINTLIBDIR)/llib-lXIE.ln PHIGSLIBSRC = $(LIBSRC)/PHIGS DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a PHIGSLIB = -lphigs LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a XBSDLIB = -lXbsd LINTXBSD = $(LINTLIBDIR)/llib-lXbsd.ln ICESRC = $(LIBSRC)/ICE SOICEREV = 6.3 DEPICELIB = ICELIB = -lICE LINTICE = $(LINTLIBDIR)/llib-lICE.ln SMSRC = $(LIBSRC)/SM SOSMREV = 6.0 DEPSMLIB = SMLIB = -lSM LINTSM = $(LINTLIBDIR)/llib-lSM.ln XKEYSRC = $(LIBSRC)/Xkey SOXKEYREV = 6.0 DEPXKEYLIB = XKEYLIB = -lXkey LINTXKEY = $(LINTLIBDIR)/llib-lXkey.ln FSLIBSRC = $(LIBSRC)/FS DEPFSLIB = $(USRLIBDIR)/libFS.a FSLIB = -lFS LINTFS = $(LINTLIBDIR)/llib-lFS.ln FONTLIBSRC = $(LIBSRC)/font DEPFONTLIB = $(USRLIBDIR)/libfont.a FONTLIB = -lfont LINTFONT = $(LINTLIBDIR)/llib-lfont.ln XPMLIBSRC = $(LIBSRC)/Xpm DEPXPMLIB = $(USRLIBDIR)/libXpm.a XPMLIB = -lXpm LINTXPM = $(LINTLIBDIR)/llib-lXpm.ln XKBFILELIBSRC = $(LIBSRC)/xkbfile DEPXKBFILELIB = $(USRLIBDIR)/libxkbfile.a XKBFILELIB = -lxkbfile LINTXKBFILE = $(LINTLIBDIR)/llib-lxkbfile.ln XKBCOMPCMD = xkbcomp XKBUILIBSRC = $(LIBSRC)/xkbui DEPXKBUILIB = $(USRLIBDIR)/libxkbui.a XKBUILIB = -lxkbui LINTXKBUI = $(LINTLIBDIR)/llib-lxkbui.ln DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) DEPLIBS1 = $(DEPLIBS) DEPLIBS2 = $(DEPLIBS) DEPLIBS3 = $(DEPLIBS) DEPLIBS4 = $(DEPLIBS) DEPLIBS5 = $(DEPLIBS) DEPLIBS6 = $(DEPLIBS) DEPLIBS7 = $(DEPLIBS) DEPLIBS8 = $(DEPLIBS) DEPLIBS9 = $(DEPLIBS) DEPLIBS10 = $(DEPLIBS) clean:: $(RM) subdir.dir XMULIBONLY = -lXmu XMULIB = $(XMULIBONLY) $(XTOOLLIB) $(XLIB) CONFIGDIR = $(LIBDIR)/config USRLIBDIRPATH = $(USRLIBDIR) LDPRELIBS = -L$(USRLIBDIR) LDPOSTLIBS = TOP_INCLUDES = -I$(INCROOT) $(TOP_X_INCLUDES) PROJECT_DEFINES = CXXPROJECT_DEFINES = # ---------------------------------------------------------------------- # start of Imakefile # Copyright (C) 1999 Nathan Sidwell # $Id: Imakefile,v 1.1 1999/08/02 20:08:10 apenwarr Exp $ # This file is available under the GNU General Public License # $Format: "VERSION = $ReleaseMajorVersion$.$ReleaseMinorVersion$"$ VERSION = nathan.0 # $Format: "APP = $Project$"$ APP = xbattery # compiler options EXTRACCOPTIONS = -I.. -Wall -Wpointer-arith -Wwrite-strings -Wtraditional NDEBUG = -DNDEBUG CDEBUGFLAGS = -g -O2 DEFINES = $(EXTRACCOPTIONS) $(NDEBUG) LOCAL_LIBRARIES = ../libapm.a $(XAWLIB) $(XTOOLLIB) $(XMULIB) $(XLIB) $(MATHSLIB) DEPLIBS = $(DEPXLIB) HDRS = BatteryGauge.h BatteryGaugeP.h SRCS = BatteryGauge.c xbattery.c FILES = Imakefile README xbattery.man OBJS = $(SRCS:.c=.o) ALLFILES = $(FILES) $(HDRS) $(SRCS) all :: xbattery @#keep gnumake happy xbattery: $(OBJS) $(DEPLIBS) $(RM) $@ $(CCLINK) -o $@ $(LDOPTIONS) $(OBJS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) clean:: $(RM) xbattery install:: xbattery @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \ else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi $(INSTALL) $(INSTALLFLAGS) $(INSTPGMFLAGS) $(INSTWIDOWFLAGS) xbattery $(DESTDIR)$(BINDIR)/xbattery install.man:: xbattery.man @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \ else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi $(INSTALL) $(INSTALLFLAGS) $(INSTMANFLAGS) xbattery.man $(DESTDIR)$(MANDIR)/xbattery.$(MANSUFFIX) clean :: $(RM) $(OBJS) tarball: @echo Tarring \& feathering into $(APP).$(VERSION).tgz $(LN) . $(APP)-$(VERSION) tar cf $(APP)-$(VERSION).tar $(ALLFILES:%=$(APP)-$(VERSION)/%) $(RM) $(APP)-$(VERSION) gzip $(APP)-$(VERSION).tar $(MV) $(APP)-$(VERSION).tar.gz $(APP)-$(VERSION).tgz depend:: $(DEPEND) $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS) .DONE : @echo "Hurrah!" .FAILED : @echo "Bummer!" # ---------------------------------------------------------------------- # common rules for all Makefiles - do not edit .c.i: $(RM) $@ $(CC) -E $(CFLAGS) $(_NOOP_) $*.c > $@ emptyrule:: clean:: $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut "#"* Makefile:: -@if [ -f Makefile ]; then set -x; \ $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ else exit 0; fi $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) tags:: $(TAGS) -w *.[ch] $(TAGS) -xw *.[ch] > TAGS man_keywords:: # ---------------------------------------------------------------------- # empty rules for directories that do not have SUBDIRS - do not edit install:: @echo "install in $(CURRENT_DIR) done" install.man:: @echo "install.man in $(CURRENT_DIR) done" install.linkkit:: @echo "install.linkkit in $(CURRENT_DIR) done" Makefiles:: includes:: depend:: # ---------------------------------------------------------------------- # dependencies generated by makedepend apmd-3.2.2.orig/xbattery/Imakefile0000644001167100001440000000256206751375423017026 0ustar cphusers00000000000000#ifndef XCOMM #define XCOMM # #endif XCOMM Copyright (C) 1999 Nathan Sidwell XCOMM $Id: Imakefile,v 1.2 1999/08/02 20:09:55 apenwarr Exp $ XCOMM This file is available under the GNU General Public License XCOMM $Format: "VERSION = $ReleaseMajorVersion$.$ReleaseMinorVersion$"$ VERSION = nathan.0 XCOMM $Format: "APP = $Project$"$ APP = xbattery XCOMM compiler options #if HasGcc EXTRACCOPTIONS = -I.. -Wall -Wpointer-arith -Wwrite-strings -Wtraditional #endif /* HasGcc */ NDEBUG = -DNDEBUG CDEBUGFLAGS = -g -O2 DEFINES = $(EXTRACCOPTIONS) $(NDEBUG) LOCAL_LIBRARIES = ../libapm.a $(XAWLIB) $(XTOOLLIB) $(XMULIB) $(XLIB) $(MATHSLIB) DEPLIBS = $(DEPXLIB) HDRS = BatteryGauge.h BatteryGaugeP.h SRCS = BatteryGauge.c xbattery.c FILES = Imakefile README xbattery.man OBJS = $(SRCS:.c=.o) ALLFILES = $(FILES) $(HDRS) $(SRCS) all :: xbattery @#keep gnumake happy NormalProgramTarget(xbattery,$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES),) InstallProgramWithFlags(xbattery,$(BINDIR),$(INSTWIDOWFLAGS)) InstallManPage(xbattery,$(MANDIR)) clean :: $(RM) $(OBJS) tarball: @echo Tarring \& feathering into $(APP).$(VERSION).tgz $(LN) . $(APP)-$(VERSION) tar cf $(APP)-$(VERSION).tar $(ALLFILES:%=$(APP)-$(VERSION)/%) $(RM) $(APP)-$(VERSION) gzip $(APP)-$(VERSION).tar $(MV) $(APP)-$(VERSION).tar.gz $(APP)-$(VERSION).tgz DependTarget() .DONE : @echo "Hurrah!" .FAILED : @echo "Bummer!" apmd-3.2.2.orig/xbattery/BatteryGaugeP.h0000644001167100001440000000435206751375252020070 0ustar cphusers00000000000000/* Copyright (C) 1999 Nathan Sidwell * $Id: BatteryGaugeP.h,v 1.1 1999/08/02 20:08:10 apenwarr Exp $ * This file is available under the GNU General Public License. */ #ifndef BatteryGaugeP_h #define BatteryGaugeP_h #include #include "BatteryGauge.h" /*{{{ structs*/ /*{{{ typedef struct _BatteryGaugeClass*/ typedef struct _BatteryGaugeClass { int unused; } BatteryGaugeClassPart; /*}}}*/ /*{{{ typedef struct _BatteryGaugeClassRec*/ typedef struct _BatteryGaugeClassRec { CoreClassPart core_class; SimpleClassPart simple_class; BatteryGaugeClassPart batteryGauge_class; } BatteryGaugeClassRec; /*}}}*/ /*{{{ typedef struct _BatteryGaugePart*/ typedef struct _BatteryGaugePart { /* resources */ XtOrientation orientation; /* horizontal or vertical */ Pixel criticalColor; /* critical color */ Pixel lowColor; /* low color */ Pixel highColor; /* high color */ Pixel chargingColor; /* charging color */ int flashDelay; /* flash delay */ int updateDelay; /* update delay */ Dimension length; /* length of widget */ Dimension thickness; /* height of widget */ int criticalLevel; /* override BIOS's idea */ int level; /* current percent level */ int status; /* current status */ int lifetime; /* current lifetime */ /* private state */ GC gc; /* my (unshared) gc */ int position; /* position current level */ int inverted; /* drawn inverted */ int flash; /* flash on and off */ int notified; /* notified of flashing */ Widget popup; /* popup widget */ Widget label; /* label widget */ int popped; /* popped up */ XtIntervalId flashTimeout; /* flasher timeout id */ XtIntervalId updateTimeout; /* update timeout id */ } BatteryGaugePart; /*}}}*/ /*{{{ typedef struct _BatteryGaugeRec*/ typedef struct _BatteryGaugeRec { CorePart core; SimplePart simple; BatteryGaugePart batteryGauge; } BatteryGaugeRec; /*}}}*/ /*}}}*/ extern BatteryGaugeClassRec batteryGaugeClassRec; #endif /* BatteryGaugeP_h */ apmd-3.2.2.orig/xbattery/BatteryGauge.c0000644001167100001440000005367006751375252017752 0ustar cphusers00000000000000/* Copyright (C) 1999 Nathan Sidwell * $Id: BatteryGauge.c,v 1.1 1999/08/02 20:08:10 apenwarr Exp $ * This file is available under the GNU General Public License. */ /*{{{ includes*/ #include #include #include #include #include #include #include "BatteryGaugeP.h" #include /*}}}*/ /*{{{ resources*/ static XtResource resources[] = { {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation), XtOffsetOf(BatteryGaugeRec, batteryGauge.orientation), XtRImmediate, (XtPointer)XtorientVertical}, {XtNlength, XtCLength, XtRDimension, sizeof(Dimension), XtOffsetOf(BatteryGaugeRec, batteryGauge.length), XtRImmediate, (XtPointer)0}, {XtNthickness, XtCThickness, XtRDimension, sizeof(Dimension), XtOffsetOf(BatteryGaugeRec, batteryGauge.thickness), XtRImmediate, (XtPointer)0}, {XtNflash, XtCDelay, XtRInt, sizeof(int), XtOffsetOf(BatteryGaugeRec, batteryGauge.flashDelay), XtRImmediate, (XtPointer)250}, {XtNupdate, XtCDelay, XtRInt, sizeof(int), XtOffsetOf(BatteryGaugeRec, batteryGauge.updateDelay), XtRImmediate, (XtPointer)15}, {XtNlowColor, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(BatteryGaugeRec, batteryGauge.lowColor), XtRString, (XtPointer)"orange"}, {XtNhighColor, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(BatteryGaugeRec, batteryGauge.highColor), XtRString, (XtPointer)"green"}, {XtNcriticalColor, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(BatteryGaugeRec, batteryGauge.criticalColor), XtRString, (XtPointer)"red"}, {XtNchargingColor, XtCBackground, XtRPixel, sizeof(Pixel), XtOffsetOf(BatteryGaugeRec, batteryGauge.chargingColor), XtRString, (XtPointer)"blue"}, {XtNcriticalLevel, XtCValue, XtRInt, sizeof(int), XtOffsetOf(BatteryGaugeRec, batteryGauge.criticalLevel), XtRImmediate, (XtPointer)0}, {XtNlevel, XtCValue, XtRInt, sizeof(int), XtOffsetOf(BatteryGaugeRec, batteryGauge.level), XtRImmediate, (XtPointer)0}, {XtNstatus, XtCValue, XtRInt, sizeof(int), XtOffsetOf(BatteryGaugeRec, batteryGauge.status), XtRImmediate, (XtPointer)-1}, {XtNlifetime, XtCValue, XtRInt, sizeof(int), XtOffsetOf(BatteryGaugeRec, batteryGauge.lifetime), XtRImmediate, (XtPointer)0}, }; /*}}}*/ /*{{{ translations*/ static char translations[] ="\ : Notify()\n\ : Release()\n\ "; /*}}}*/ /*{{{ prototypes*/ /*{{{ methods*/ static void ClassInitialize(void); static void Destroy(Widget); static void Initialize(Widget, Widget, ArgList, Cardinal *); static void Realize(Widget, XtValueMask *, XSetWindowAttributes *); static void Redisplay(Widget, XEvent *, Region); static void Resize(Widget); static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *); /*}}}*/ /*{{{ actions*/ static void Notify(Widget, XEvent *, String *, Cardinal *); static void Release(Widget, XEvent *, String *, Cardinal *); /*}}}*/ /*{{{ helpers*/ static void redraw(BatteryGaugeWidget me); static int setPosition(BatteryGaugeWidget me, int); static void setFlashTimeout(BatteryGaugeWidget me); static void flashTimeout(XtPointer, XtIntervalId *); static void updateLabel(BatteryGaugeWidget); static void updateTimeout(XtPointer, XtIntervalId *); /*}}}*/ /*}}}*/ /*{{{ actions*/ static XtActionsRec actions[] = { {"Notify", Notify}, {"Release", Release}, }; /*}}}*/ #define SuperClass (&simpleClassRec) /*{{{ BatteryGaugeClassRec batteryGaugeClassRec =*/ BatteryGaugeClassRec batteryGaugeClassRec = { /*{{{ core class part*/ { (WidgetClass)SuperClass, /* superclass */ "BatteryGauge", /* class_name */ sizeof(BatteryGaugeRec), /* size */ ClassInitialize, /* class_initialize */ NULL, /* class_part_initialize */ False, /* class_inited */ Initialize, /* initialize */ NULL, /* initialize_hook */ Realize, /* realize */ actions, /* actions */ XtNumber(actions), /* num_actions */ resources, /* resources */ XtNumber(resources), /* num_resources */ NULLQUARK, /* xrm_class */ True, /* compress_motion */ XtExposeCompressMultiple, /* compress_exposure */ True, /* compress_enterleave */ False, /* visible_interest */ Destroy, /* destroy */ Resize, /* resize */ Redisplay, /* expose */ SetValues, /* set_values */ NULL, /* set_values_hook */ XtInheritSetValuesAlmost, /* set_values_almost */ NULL, /* get_values_hook */ XtInheritAcceptFocus, /* accept_focus */ XtVersion, /* version */ NULL, /* callback_private */ translations, /* default_translations */ XtInheritQueryGeometry, /* query_geometry */ XtInheritDisplayAccelerator, /* display_accelerator */ NULL, /* extension */ }, /*}}}*/ /*{{{ simple class part*/ { XtInheritChangeSensitive /* change_sensitive */ }, /*}}}*/ /*{{{ batteryGauge class part*/ { }, /*}}}*/ }; /*}}}*/ WidgetClass batteryGaugeWidgetClass = (WidgetClass)&batteryGaugeClassRec; /*{{{ methods*/ /*{{{ static void ClassInitialize()*/ static void ClassInitialize() /* register the orientation resource converter */ { XtAddConverter(XtRString, XtROrientation, XmuCvtStringToOrientation, (XtConvertArgList)NULL, (Cardinal)0); return; } /*}}}*/ /*{{{ static void Destroy(Widget w)*/ static void Destroy(Widget w) /* removes pending timeouts and workprocs */ { BatteryGaugeWidget me; me = (BatteryGaugeWidget)w; if(me->batteryGauge.updateTimeout != (XtIntervalId)0) XtRemoveTimeOut(me->batteryGauge.updateTimeout); if(me->batteryGauge.flashTimeout != (XtIntervalId)0) XtRemoveTimeOut(me->batteryGauge.flashTimeout); if(XtIsRealized((Widget)me)) XFreeGC(XtDisplay((Widget)me), me->batteryGauge.gc); if(me->batteryGauge.popup) XtDestroyWidget(me->batteryGauge.popup); return; } /*}}}*/ /*{{{ static void Initialize(Widget request_w, Widget new_w, ArgList args, Cardinal *num_args)*/ static void Initialize(Widget request_w, Widget new_w, ArgList args, Cardinal *num_args) /* initializes an instance of the batteryGauge widget * set the width and height from the thickness and length */ { BatteryGaugeWidget request_me; BatteryGaugeWidget new_me; new_me = (BatteryGaugeWidget)new_w; request_me = (BatteryGaugeWidget)request_w; if(!new_me->batteryGauge.thickness) new_me->batteryGauge.thickness = 8; if(!new_me->batteryGauge.length) new_me->batteryGauge.length = new_me->batteryGauge.thickness; if(new_me->batteryGauge.orientation != XtorientHorizontal) { if(!new_me->core.width) new_me->core.width = new_me->batteryGauge.thickness; if(!new_me->core.height) new_me->core.height = new_me->batteryGauge.length; new_me->batteryGauge.length = new_me->core.height; new_me->batteryGauge.thickness = new_me->core.width; } else { if(!new_me->core.width) new_me->core.width = new_me->batteryGauge.length; if(!new_me->core.height) new_me->core.height = new_me->batteryGauge.thickness; new_me->batteryGauge.length = new_me->core.width; new_me->batteryGauge.thickness = new_me->core.height; } new_me->batteryGauge.inverted = new_me->batteryGauge.flash = new_me->batteryGauge.notified = 0; new_me->batteryGauge.popup = new_me->batteryGauge.label = NULL; new_me->batteryGauge.updateTimeout = new_me->batteryGauge.flashTimeout = (XtIntervalId)0; new_me->batteryGauge.popped = 0; return; } /*}}}*/ /*{{{ static void Realize(Widget w, XtValueMask *valueMask, XSetWindowAttributes *attributes)*/ static void Realize(Widget w, XtValueMask *valueMask, XSetWindowAttributes *attributes) /* realizes the batteryGauge widget * it is at this point that the GC is allocated * set the idle cursor * clip the limits and value * set the batteryGauge position, but don't paint it */ { BatteryGaugeWidget me; me = (BatteryGaugeWidget)w; SuperClass->core_class.realize((Widget)me, valueMask, attributes); /*{{{ create the gc*/ { XGCValues gcValues; XtGCMask mask; unsigned depth; depth = 1; gcValues.function = GXcopy; gcValues.foreground = 0; /* filled prior to drawing */ gcValues.background = 0; gcValues.fill_style = FillSolid; mask = GCForeground | GCFunction | GCFillStyle; me->batteryGauge.gc = XCreateGC(XtDisplay((Widget)me), XtWindow((Widget)me), mask, &gcValues); } /*}}}*/ updateTimeout((XtPointer)me, NULL); return; } /*}}}*/ /*{{{ static void Redisplay(Widget w, XEvent *event, Region region)*/ static void Redisplay(Widget w, XEvent *event, Region region) { BatteryGaugeWidget me; me = (BatteryGaugeWidget)w; redraw(me); return; } /*}}}*/ /*{{{ static void Resize(Widget w)*/ static void Resize(Widget w) /* * get the length and thickness from width and height */ { BatteryGaugeWidget me; me = (BatteryGaugeWidget)w; if(me->batteryGauge.orientation != XtorientHorizontal) { me->batteryGauge.length = me->core.height; me->batteryGauge.thickness = me->core.width; } else { me->batteryGauge.length = me->core.width; me->batteryGauge.thickness = me->core.height; } setPosition(me, -1); return; } /*}}}*/ /*{{{ static Boolean SetValues(Widget current_w, Widget request_w, Widget new_w, ArgList args, Cardinal *num_args)*/ static Boolean SetValues(Widget current_w, Widget request_w, Widget new_w, ArgList args, Cardinal *num_args) /* if thickness, length or orientation changed, then request * new geometry */ { BatteryGaugeWidget current_me; /* this is how we look now */ BatteryGaugeWidget request_me; /* this is what we were asked for */ BatteryGaugeWidget new_me; /* this is what we'll end up with */ Boolean repaint; current_me = (BatteryGaugeWidget)current_w; request_me = (BatteryGaugeWidget)request_w; new_me = (BatteryGaugeWidget)new_w; repaint = False; /*{{{ orientation changed?*/ if(new_me->batteryGauge.orientation != current_me->batteryGauge.orientation) { repaint = True; new_me->core.width = new_me->batteryGauge.orientation != XtorientHorizontal ? new_me->batteryGauge.thickness : new_me->batteryGauge.length; new_me->core.height = new_me->batteryGauge.orientation != XtorientHorizontal ? new_me->batteryGauge.length : new_me->batteryGauge.thickness; } /*}}}*/ /*{{{ length changed?*/ if(new_me->batteryGauge.length != current_me->batteryGauge.length) { if(new_me->batteryGauge.orientation != XtorientHorizontal) new_me->core.height = new_me->batteryGauge.length; else new_me->core.width = new_me->batteryGauge.length; repaint = True; } /*}}}*/ /*{{{ thickness changed?*/ if(new_me->batteryGauge.thickness != current_me->batteryGauge.thickness) { if(new_me->batteryGauge.orientation != XtorientHorizontal) new_me->core.width = new_me->batteryGauge.thickness; else new_me->core.height = new_me->batteryGauge.thickness; repaint = True; } /*}}}*/ /* we have to reset length and thickness to current dimensions, * in case we never get resized */ if(new_me->batteryGauge.orientation != XtorientHorizontal) { new_me->batteryGauge.length = current_me->core.height; new_me->batteryGauge.thickness = current_me->core.width; } else { new_me->batteryGauge.length = current_me->core.width; new_me->batteryGauge.thickness = current_me->core.height; } if(XtIsRealized((Widget)new_me)) { new_me->batteryGauge.level = current_me->batteryGauge.level; new_me->batteryGauge.status = current_me->batteryGauge.status; new_me->batteryGauge.lifetime = current_me->batteryGauge.lifetime; repaint = setPosition(new_me, current_me->batteryGauge.status); if(new_me->batteryGauge.highColor != current_me->batteryGauge.highColor || new_me->batteryGauge.lowColor != current_me->batteryGauge.lowColor || new_me->batteryGauge.criticalColor != current_me->batteryGauge.criticalColor || new_me->batteryGauge.chargingColor != current_me->batteryGauge.chargingColor) repaint = True; setFlashTimeout(new_me); } return repaint; } /*}}}*/ /*}}}*/ /*{{{ actions*/ /*{{{ static void Notify(Widget w, XEvent *event, String *params, Cardinal *num_params)*/ static void Notify(Widget w, XEvent *event, String *params, Cardinal *num_params) /* notify of flashing */ { BatteryGaugeWidget me; me = (BatteryGaugeWidget)w; me->batteryGauge.notified = me->batteryGauge.flash; if(me->batteryGauge.flashTimeout != (XtIntervalId)0) { XtRemoveTimeOut(me->batteryGauge.flashTimeout); me->batteryGauge.flashTimeout = (XtIntervalId)0; } if(me->batteryGauge.inverted) { me->batteryGauge.inverted = 0; redraw(me); } if(!me->batteryGauge.popup) /*{{{ create popup*/ { me->batteryGauge.popup = XtCreatePopupShell("popup", overrideShellWidgetClass, (Widget)me, NULL, 0); me->batteryGauge.label = XtCreateManagedWidget("label", labelWidgetClass, me->batteryGauge.popup, NULL, 0); } /*}}}*/ updateLabel(me); /*{{{ position popup*/ { /*{{{ static Arg setArgs[] =*/ static Arg setArgs[] = { {XtNx, 0}, {XtNy, 0}, }; /*}}}*/ /*{{{ static Arg getArgs[] =*/ static Arg getArgs[] = { {XtNwidth, 0}, {XtNheight, 0}, }; /*}}}*/ int x, y; Dimension w, h; int got; int screenW; /*{{{ get position from event*/ switch(event->type) { case ButtonPress: case ButtonRelease: x = event->xbutton.x_root; y = event->xbutton.y_root; got = 1; break; case MotionNotify: x = event->xmotion.x_root; y = event->xmotion.y_root; got = 1; break; case EnterNotify: case LeaveNotify: x = event->xcrossing.x_root; y = event->xcrossing.y_root; got = 1; break; default: x = y = 0; got = 0; } /*}}}*/ XtRealizeWidget(me->batteryGauge.popup); getArgs[0].value = (XtArgVal)&w; getArgs[1].value = (XtArgVal)&h; XtGetValues(me->batteryGauge.popup, getArgs, 2); y -= h + 4; x -= w / 2; screenW = WidthOfScreen(XtScreen((Widget)me)); if(x < 0) x = 0; if(y < 0) y = 0; if(x > (int)(screenW - w)) x = (int)(screenW - w); setArgs[0].value = (XtArgVal)x; setArgs[1].value = (XtArgVal)y; XtSetValues(me->batteryGauge.popup, setArgs, 2); } /*}}}*/ XtPopup(me->batteryGauge.popup, XtGrabNone); me->batteryGauge.popped = 1; return; } /*}}}*/ /*{{{ static void Release(Widget w, XEvent *event, String *params, Cardinal *num_params)*/ static void Release(Widget w, XEvent *event, String *params, Cardinal *num_params) { BatteryGaugeWidget me; me = (BatteryGaugeWidget)w; if(me->batteryGauge.popup) XtPopdown(me->batteryGauge.popup); me->batteryGauge.popped = 0; return; } /*}}}*/ /*}}}*/ /*{{{ helpers*/ /*{{{ static void redraw(BatteryGaugeWidget me)*/ static void redraw(BatteryGaugeWidget me) /* Draw the batteryGauge position. If charging then background color is * charging color, otherwise it's normal background. If value <= emptyValue, * foreground is emptyColor, else if value >= warningValue, foreground is * normalColor, else foreground is warning foreground. If inverted then swap * foreground and background. */ { Pixel foreground; Pixel background; XRectangle foreRect; XRectangle backRect; background = me->core.background_pixel; /*{{{ set foreground color*/ switch(me->batteryGauge.status) { case 0: foreground = me->batteryGauge.inverted ? me->batteryGauge.chargingColor : me->batteryGauge.highColor; break; case 1: foreground = me->batteryGauge.inverted ? background : me->batteryGauge.lowColor; break; case 2: foreground = me->batteryGauge.criticalColor; if(me->batteryGauge.inverted) { foreground = background; background = me->batteryGauge.criticalColor; } break; case 3: foreground = me->batteryGauge.inverted ? me->batteryGauge.highColor : me->batteryGauge.chargingColor; break; default: foreground = background; } /*}}}*/ foreRect.x = backRect.x = 0; foreRect.y = backRect.y = 0; foreRect.width = backRect.width = me->core.width; foreRect.height = backRect.height = me->core.height; if(me->batteryGauge.orientation == XtorientHorizontal) /*{{{ horizontal*/ { foreRect.width = me->batteryGauge.position; backRect.width -= me->batteryGauge.position; backRect.x = foreRect.width; } /*}}}*/ else /*{{{ vertical*/ { foreRect.height = me->batteryGauge.position; backRect.height -= me->batteryGauge.position; foreRect.y = backRect.height; } /*}}}*/ XSetForeground(XtDisplay((Widget)me), me->batteryGauge.gc, foreground); XFillRectangle(XtDisplay((Widget)me), XtWindow((Widget)me), me->batteryGauge.gc, foreRect.x, foreRect.y, foreRect.width, foreRect.height); XSetForeground(XtDisplay((Widget)me), me->batteryGauge.gc, background); XFillRectangle(XtDisplay((Widget)me), XtWindow((Widget)me), me->batteryGauge.gc, backRect.x, backRect.y, backRect.width, backRect.height); return; } /*}}}*/ /*{{{ static int setPosition(BatteryGaugeWidget me, int oldStatus)*/ static int setPosition(BatteryGaugeWidget me, int oldStatus) { int changed = 0; int pos; int flash; if(me->batteryGauge.level < 0) me->batteryGauge.level = 0; if(me->batteryGauge.level > 100) me->batteryGauge.level = 100; pos = (me->batteryGauge.length * me->batteryGauge.level + 50) / 100; changed |= me->batteryGauge.position != pos; me->batteryGauge.position = pos; if(me->batteryGauge.level <= me->batteryGauge.criticalLevel && me->batteryGauge.status != 3) me->batteryGauge.status = 2; changed |= me->batteryGauge.status != oldStatus; flash = me->batteryGauge.flash; if(me->batteryGauge.status == 2 && oldStatus != 2) /*{{{ gone critical*/ { me->batteryGauge.notified = 0; flash = -1; } /*}}}*/ else if(me->batteryGauge.status == 1 && oldStatus != 1) /*{{{ gone low*/ { me->batteryGauge.notified = 0; flash = 1; } /*}}}*/ else if(flash < 1 && me->batteryGauge.level == 100 && (me->batteryGauge.status == 3 || (me->batteryGauge.status == 0 && oldStatus == 3))) /*{{{ charged*/ { flash = 1; me->batteryGauge.notified = 0; } /*}}}*/ else if(me->batteryGauge.level != 100 && me->batteryGauge.status != 2 && me->batteryGauge.status != 1) /*{{{ stop flashing*/ { flash = 0; } /*}}}*/ if(!flash) { changed |= me->batteryGauge.inverted; me->batteryGauge.inverted = 0; } me->batteryGauge.flash = flash; return changed; } /*}}}*/ /*{{{ static void setFlashTimeout(BatteryGaugeWidget me)*/ static void setFlashTimeout(BatteryGaugeWidget me) { if(!me->batteryGauge.flashTimeout && me->batteryGauge.flash != me->batteryGauge.notified) me->batteryGauge.flashTimeout = XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)me), (unsigned long)me->batteryGauge.flashDelay, flashTimeout, (XtPointer)me); return; } /*}}}*/ /*{{{ static void flashTimeout(XtPointer client, XtIntervalId *id)*/ static void flashTimeout(XtPointer client, XtIntervalId *id) { BatteryGaugeWidget me; me = (BatteryGaugeWidget)client; me->batteryGauge.flashTimeout = (XtIntervalId)0; if(me->batteryGauge.flash) { me->batteryGauge.inverted ^= 1; redraw(me); setFlashTimeout(me); } return; } /*}}}*/ /*{{{ static void updateLabel(BatteryGaugeWidget me)*/ static void updateLabel(BatteryGaugeWidget me) { if(me->batteryGauge.label) { static char buffer[24]; static char const *states[] = {"high", "low", "critical", "charging"}; static Arg arg = {XtNlabel, (XtArgVal)buffer}; if(me->batteryGauge.lifetime < 0) sprintf(buffer, "%d%% (%s)", me->batteryGauge.level, states[me->batteryGauge.status]); else sprintf(buffer, "%d%% %s (%s)", me->batteryGauge.level, apm_time_nosec(me->batteryGauge.lifetime), states[me->batteryGauge.status]); XtSetValues(me->batteryGauge.label, &arg, 1); } } /*}}}*/ /*{{{ static void updateTimeout(XtPointer client, XtIntervalId *id)*/ static void updateTimeout(XtPointer client, XtIntervalId *id) { BatteryGaugeWidget me = (BatteryGaugeWidget)client; apm_info info; int oldStatus = me->batteryGauge.status; unsigned long delay; me->batteryGauge.updateTimeout = 0; apm_read(&info); me->batteryGauge.level = info.battery_percentage; me->batteryGauge.status = info.battery_status; me->batteryGauge.lifetime = info.battery_time < 0 ? -1 : info.using_minutes ? info.battery_time * 60 : info.battery_time; if(setPosition(me, oldStatus) && XtIsRealized((Widget)me)) { redraw(me); setFlashTimeout(me); } if(me->batteryGauge.popped) updateLabel(me); delay = me->batteryGauge.updateDelay * 100; if(me->batteryGauge.status & 1) delay *= 10; me->batteryGauge.updateTimeout = XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)me), delay + 500, updateTimeout, (XtPointer)me); } /*}}}*/ /*}}}*/ apmd-3.2.2.orig/xbattery/xbattery.man0000644001167100001440000000727306672517315017560 0ustar cphusers00000000000000.\" xbattery.man -- .\" Created: Mon Mar 1 1999 by nathan@acm.org .\" Copyright 1999 Nathan Sidwell .\" Portions of this manual Copyright 1996 Rickard E. Faith (r.faith@ieee.org) .\" Derrived from xapm.1 by Rickard E. Faith (r.faith@ieee.org) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .TH XBATTERY 1 "1 Mar 1999" "" "Linux Programmer's Manual" .SH NAME xbattery \- display Advanced Power Management (APM) BIOS information .SH SYNOPSIS .B xbattery [ ... ] .SH DESCRIPTION .B xbattery puts up an X window that displays the remaining battery life. A simple strip gauge shows the remaining battery power, and the color shows battery status. When power goes low or critical, the whole gauge flashes. When charging is completed, the gauge also flashes. Clicking on the gauge pops up a textual status window, and will stop it flashing. .B xbattery integrates well into fvwm's button box, and should behave similarly in other window manager's equivalents. .SH "OPTIONS AND RESOURCES" In addition to standard Xt options, the following options are available: .TP .BI \-highColor " color" The color of the bar when the battery status is high. Defaults to "green". (*highColor) .TP .BI \-lowColor " color" The color of the bar when the battery status is low. Defaults to "orange". (*lowColor) .TP .BI \-criticalColor " color" The color of the bar when the battery status is critical. Defaults to "red". (*criticalColor) .TP .BI \-chargingColor " color" The color of the bar when the battery is charging. Defaults to "blue". (*chargingColor) .TP .BI \-update " delay" Sets the number of seconds delay between each update. When the battery status is low or critical, the status is checked 10 times faster, at most once per second. The default is 20. (*update) .TP .BI \-criticalLevel " level" Set the level at which the battery is deemed critical. Although apm provides a critical status level, there is generally insufficient time for you to do anything before a BIOS enforced suspend or shutdown is imposed. You can set a higher percentage with this flag. If you set a lower percentage than apm considers critical, this level is ignored. The default is 0. (*criticalLevel) .TP .BI \-flash " delay" Sets the number of milliseconds between flashes. The gauge is flashed whenever the status goes low or critcal, or charging completes. The default is 250. (*flash) .TP .BI \-orientation " orientation" Sets the orientation of the gauge. Defaults to vertical. (*orientation) .SH FILES .I /proc/apm .SH AUTHOR This program was written by Nathan Sidwell (nathan@acm.org) and may be freely distributed under the terms of the GNU General Public License. There is ABSOLUTELY NO WARANTY for this program. .SH "SEE ALSO" .BR apm "(1), "xapm "(1), "apmd "(8)" apmd-3.2.2.orig/xbattery/xbattery.c0000644001167100001440000000346406751375252017225 0ustar cphusers00000000000000/* Copyright (C) Nathan Sidwell 1999 * $Id: xbattery.c,v 1.1 1999/08/02 20:08:10 apenwarr Exp $ * * This file is available under the GNU General Public License. * This is inspired by the xapm application by Rickard E Faith * (r.faith@ieee.org). This is just a launcher for a BatteryGauge widget. * Read that widget's documentation for use. */ /*{{{ includes*/ #include #include #include #include #include "BatteryGauge.h" #include /*}}}*/ /*{{{ static XrmOptionDescRec options[] =*/ static XrmOptionDescRec options[] = { {"-delay", "*update", XrmoptionSepArg, NULL}, {"-update", "*update", XrmoptionSepArg, NULL}, {"-criticalColor", "*criticalColor", XrmoptionSepArg, NULL}, {"-lowColor", "*warningColor", XrmoptionSepArg, NULL}, {"-highColor", "*normalColor", XrmoptionSepArg, NULL}, {"-chargingColor", "*chargingColor", XrmoptionSepArg, NULL}, {"-criticalLevel", "*criticalLevel", XrmoptionSepArg, NULL}, {"-flash", "*flash", XrmoptionSepArg, NULL}, {"-orientation", "*orientation", XrmoptionSepArg, NULL}, }; /*}}}*/ /*{{{ int main(int argc, char **argv)*/ int main(int argc, char **argv) { XtAppContext context; Widget topLevel; Widget gauge; /*{{{ check APM support*/ switch(apm_exists()) { case 1: fprintf(stderr, "xbattery:No APM support available\n"); exit(1); case 2: fprintf(stderr, "xbattery:Obsolete APM support in kernel\n"); exit(1); } /*}}}*/ topLevel = XtAppInitialize(&context, "XBattery", options, XtNumber(options), &argc, argv, NULL, NULL, 0); gauge = XtCreateManagedWidget("gauge", batteryGaugeWidgetClass, topLevel, NULL, 0); XtRealizeWidget(topLevel); XtAppMainLoop(context); return 0; } /*}}}*/ apmd-3.2.2.orig/xbattery/BatteryGauge.h0000644001167100001440000000403106751375252017742 0ustar cphusers00000000000000/* Copyright (C) 1999 Nathan Sidwell * $Id: BatteryGauge.h,v 1.1 1999/08/02 20:08:10 apenwarr Exp $ * This file is available under the GNU General Public License. */ #ifndef BatteryGauge_h #define BatteryGauge_h #include #include /*{{{ BatteryGauge widget resources*/ /* * A subclass of the Simple widget Name Class RepType Default Value ---- ----- ------- ------------- length Length Dimension 1 orientation Orientation XtOrientation XtorientVertical thickness Thickness Dimension 14 highColor Foreground Color green lowColor Foreground Color orange criticalColor Foreground Color red chargingColor Background Color blue flash Delay int 250 update Delay int 15 criticalLevel Value int 0 level Value int 0 lifetime Value int 0 status Value int 0 */ /*}}}*/ /*{{{ new resource names*/ #ifndef XtNlowColor #define XtNlowColor "lowColor" #endif #ifndef XtNcriticalColor #define XtNcriticalColor "criticalColor" #endif #ifndef XtNhighColor #define XtNhighColor "highColor" #endif #ifndef XtNchargingColor #define XtNchargingColor "chargingColor" #endif #ifndef XtNflash #define XtNflash "flash" #endif #ifndef XtNupdate #define XtNupdate "update" #endif #ifndef XtCDelay #define XtCDelay "Delay" #endif #ifndef XtNcriticalLevel #define XtNcriticalLevel "criticalLevel" #endif #ifndef XtNlevel #define XtNlevel "level" #endif #ifndef XtNstatus #define XtNstatus "status" #endif #ifndef XtNlifetime #define XtNlifetime "lifetime" #endif /*}}}*/ extern WidgetClass batteryGaugeWidgetClass; typedef struct _BatteryGaugeClassRec* BatteryGaugeWidgetClass; typedef struct _BatteryGaugeRec* BatteryGaugeWidget; #endif /* BatteryGauge_h */ apmd-3.2.2.orig/xbattery/README0000644001167100001440000000155406706402164016066 0ustar cphusers00000000000000Nathan Sidwell March 13 1999 This little application and widget show the battery status of your laptop. It'll start flashing, when you're low on power. To build it, do the following, xmkmf make make install make install.man Then all you need to do is configure your window manager to start it. I have the following in my .fvwm2rc file, *FvwmButtons(1x1, Swallow(UseOld) "XBattery" \ 'Exec xbattery -bg grey -xrm "xbattery*popup*background:white" &') which adds it to the button box. As the widget and application are separate, you can put the widget directly into another application, if you want to. All the files are available under the terms of the GNU General Public License version 2 or later. See the file COPYING-2.0 for the terms and conditions. If you do use this in an application or library, drop me an email, so I am aware of it. apmd-3.2.2.orig/Makefile0000644001167100001440000000626107775745436015027 0ustar cphusers00000000000000# Makefile -- # Copyright 1996, 1997 Rickard E. Faith # Copyright 1999 Avery Pennarun # # 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, 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. # # $Id: Makefile,v 1.30 2001/11/25 22:46:16 apenwarr Exp $ # VERSION=3.2.1 LIB_VERSION=1:0 ifneq (,) This makefile requires GNU Make. endif .SUFFIXES: OBJS=apmlib.o EXES=apm apmd xapm apmsleep HEADERS=apm.h PREFIX=/usr MANDIR=$(PREFIX)/man BINDIR=$(PREFIX)/bin SBINDIR=$(PREFIX)/sbin LIBDIR=$(PREFIX)/lib INCDIR=$(PREFIX)/include PROXY_DIR=/etc DESTDIR= CC=gcc CFLAGS=-O -g XTRACFLAGS=-Wall -pipe -I. -I/usr/src/linux/include \ -I/usr/src/linux-2.2/include -I /usr/src/linux-2.0/include \ -DVERSION=\"$(VERSION)\" \ -DDEFAULT_PROXY_NAME=\"$(PROXY_DIR)/apmd_proxy\" LDFLAGS= LIBAPM=libapm.la LIBAPM_FLAGS=-rpath $(LIBDIR) -version-info $(LIB_VERSION) XLDFLAGS=-L/usr/X11R6/lib XLIBS=-lXaw -lXmu -lXt -lXext -lSM -lICE -lX11 RANLIB=ranlib # Uncomment these lines for a production compile #CFLAGS=-O3 -m486 -fomit-frame-pointer #LDFLAGS=-s LIBTOOL=libtool --quiet LT_COMPILE = $(LIBTOOL) --mode=compile $(CC) LT_LINK = $(LIBTOOL) --mode=link $(CC) LT_INSTALL = $(LIBTOOL) --mode=install install LT_CLEAN = $(LIBTOOL) --mode=clean rm all: $(EXES) $(OBJS): $(HEADERS) %.o: %.c $(LT_COMPILE) -c $(CPPFLAGS) $(CFLAGS) $(XTRACFLAGS) $< %: %.o $(LIBAPM) $(LT_LINK) -o $@ $< $(LDFLAGS) $(LIBAPM) xapm.o: xapm.c $(LT_COMPILE) -c $(CPPFLAGS) $(CFLAGS) $(XTRACFLAGS) -DNARROWPROTO $< apmd: apmd.o apmsleep: apmsleep.o apmexists: apmexists.o xapm: xapm.o $(LIBAPM) $(LT_LINK) -o $@ $< $(LDFLAGS) $(LIBAPM) $(XLDFLAGS) $(XLIBS) $(LIBAPM): apmlib.lo $(LT_LINK) -o $@ $< $(LIBAPM_FLAGS) $(LDFLAGS) apmlib.lo: apmlib.c apm.h $(LT_COMPILE) -c $(CPPFLAGS) $(CFLAGS) $(XTRACFLAGS) $< .PHONY: ChangeLog ChangeLog: -rm -f ChangeLog rcs2log > ChangeLog install: $(EXES) [ -d $(DESTDIR)$(BINDIR) ] || install -d $(DESTDIR)$(BINDIR) [ -d $(DESTDIR)$(SBINDIR) ] || install -d $(DESTDIR)$(SBINDIR) [ -d $(DESTDIR)$(LIBDIR) ] || install -d $(DESTDIR)$(LIBDIR) [ -d $(DESTDIR)$(INCDIR) ] || install -d $(DESTDIR)$(INCDIR) $(LT_INSTALL) -m 644 $(LIBAPM) $(DESTDIR)$(LIBDIR) $(LT_INSTALL) apm $(DESTDIR)$(BINDIR) $(LT_INSTALL) apmd $(DESTDIR)$(SBINDIR) $(LT_INSTALL) xapm $(DESTDIR)$(BINDIR) $(LT_INSTALL) apmsleep $(DESTDIR)$(BINDIR) install on_ac_power $(DESTDIR)$(BINDIR) install -m 644 apm.h $(DESTDIR)$(INCDIR) .PHONY: clean distclean distclean clean: -$(LT_CLEAN) -f $(LIBAPM) $(EXES) *.lo -rm -f *.o *.s *~ core a.out build-stamp apmd-3.2.2.orig/apmd_proxy0000644001167100001440000000441207775745414015464 0ustar cphusers00000000000000#!/bin/sh # # apmd_proxy - program dispatcher for APM daemon # # Craig Markwardt (craigm@lheamail.gsfc.nasa.gov) 21 May 1999 # David Brownell (db@post.harvard.edu) 9 June 1999 # # This shell script is called by the APM daemon (apmd) when the state # of any power management function has changed. The exact events that # trigger the calling of apmd_proxy depend on how apmd was configured # at compile time. # # Within this script the system administrator should put any commands # or actions which should be performed upon state transitions. # # apmd_proxy is called with specific arguments that describe the event # that has occurred. It is this script's responsibility to query the # hardware or the APM service (via /proc/apm) for more information # and to take the appropriate action. # # For example, apmd will call "apmd_proxy suspend system" just before # the system is scheduled to go into suspend mode. The administrator # may wish to perform site-specific actions like unloading drivers or # disabling the network interface. When the system is resumed later, # apmd will call "apmd_proxy resume normal", at which time those actions # should be reversed. # # Here are the calling sequences for apmd_proxy: # # apmd_proxy start - APM daemon has started # apmd_proxy stop - APM daemon is shutting down # apmd_proxy suspend system - APM system has requested suspend mode # apmd_proxy suspend critical - APM system indicates critical suspend (*) # apmd_proxy standby system - APM system has requested standby mode # apmd_proxy suspend user - User has requested suspend mode # apmd_proxy standby user - User has requested standby mode # apmd_proxy resume suspend - System has resumed from suspend mode # apmd_proxy resume standby - System has resumed from standby mode # apmd_proxy resume critical - System has resumed from critical suspend # apmd_proxy change battery - APM system reported low battery # apmd_proxy change power - APM system reported AC/battery change # apmd_proxy change time - APM system reported need for time update (*) # apmd_proxy change capability - APM system reported config. change (+) # # (*) - APM daemon may be modified to call these sequences # (+) - Available if kernel APM driver supports it apmd-3.2.2.orig/apmsleep.10000644001167100001440000000767107775757466015273 0ustar cphusers00000000000000.\" apmsleep.1 .\" .TH APMSLEEP 1 "January 2004" "" "" .SH NAME apmsleep \- go into suspend or standby mode and wake-up later .SH SYNOPSIS .B apmsleep [\-sSnwhVd] [\-\-suspend] [\-\-standby] [\-\-noapm] [\-\-wait] [\-\-precise] [\-\-help] [\-\-version] [\-\-debug] [+]hh:mm .SH DESCRIPTION Some computers, especially laptops, can wake-up from a low-power suspend to DRAM mode using the Real-time-clock (RTC) chip. .B Apmsleep can be used to set the alarm time in the RTC and to go into suspend or standby mode. An interrupt from the RTC causes the computer to wake-up. The program detects this event, by waiting for a leap in the kernel time and terminates successfully. If no time leap occurs within one minute, or something goes wrong, the exit value will be non-zero. .PP The wake-up time can be specified in two formats: .PP .B +hh:mm specifies a relative offset to the current time. The computer will suspend for exactly hh hours and mm minutes plus a few seconds to wake up. On some laptops, the timing is not completely accurate so it may be a few minutes (or more?) late. .PP .B hh:mm specifies absolute .B local time in 24-hour format. The time stored in the RTC is not important. You may change the time zone used, with the TZ environment variable as usual. Daylight saving time is not obeyed in this version, but might be in a future release. .B WARNING: Do not close cover of laptop after suspending the laptop with apmsleep. Most laptops overheat when running with closed cover. .PP Energy conservation with APM is little for a desktop. Turning of the screen will save 1/2, going into standby with drives turned off will save another 1/6th of the current. .TP .B \-V, \-\-version Print the .B apmsleep program version and exit immediately. .TP .B \-s, \-\-suspend Put the machine into suspend mode if possible (default). On my laptop, suspend mode turns off everything except the memory. .TP .B \-S, \-\-standby Put the machine into standby mode if possible. On my laptop, standby mode turns off screen, hard disk, and CPU. .TP .B \-w, \-\-wait Wait indefinitely for the time leap. .TP .B \-p, \-\-precise Wait for alarm time to match actual time. Do not wait for time leap. This might be useful even without APM. .TP .B \-n, \-\-noapm Do not call apm bios to suspend computer, just set the alarm clock and wait for time leap indefinitely. .TP .B \-d, \-\-debug Print some information about what is going on. .SH REQUIRED SYSTEM CONFIGURATION .TP .B Kernel The special character device /dev/rtc must exist and the kernel needs to be compiled with APM and RTC support. .TP .B BIOS The computer must have the 'suspend to RAM' feature enabled in the BIOS; 'suspend to Disk' will not work, because the computer is turned off completely. You do not need to enable the ALARM timer, it will be activated by apmsleep. On some boards, you can configure which interrupts can be used to awake from suspend mode. If you have such a board, you might want to make sure that keyboard (IRQ 1) and RTC (IRQ 8) are among those interrupts. If your computer does not wake up, try to enable 'modem ring' in the BIOS, even if you do not have a modem. .TP .B Privileges The program must be run as root or have the SUID attribute set (see chmod(1)). .PP .SH BUGS Apmsleep cannot detect which event terminated the suspension. Possible events are: keyboard or mouse activity, modem ring, alarm from RTC, any other interrupt. Sometimes, the time leap is not detected properly (causing a wrong exit value). Should use APM BIOS calls to set alarm clock (not yet supported by kernel). This program was tested on a Winbook XL laptop (Pentium) only. It may not function on your hardware. .SH AUTHOR Written by Peter Englmaier (ppe@mpe.mpg.de) and may be freely distributed under the terms of the GNU General Public License. The code is based on Paul Gortmacher's RTC test/example program. There is ABSOLUTELY NO WARRANTY for this program. The current maintainer is Peter Englmaier. .SH "SEE ALSO" .BR xapm (1), .BR apmd (8). apmd-3.2.2.orig/apm.h0000644001167100001440000000556407611624454014303 0ustar cphusers00000000000000/* apm.h -- Header file for sample APM interface routines * Created: Mon Jan 8 11:40:50 1996 by r.faith@ieee.org * Revised: Thu Apr 4 21:57:31 1996 by r.faith@ieee.org * Copyright 1996 Rickard E. Faith (r.faith@ieee.org) * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: apm.h,v 1.7 1999/07/05 22:31:11 apenwarr Exp $ * */ #include #include #define APM_PROC "/proc/apm" #define APM_DEVICE "/dev/apm_bios" #define APM_DEV "/proc/devices" #define APM_NAME "apm_bios" #ifndef APM_32_BIT_SUPPORT #define APM_32_BIT_SUPPORT 0x0002 #endif 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; /* * Encodings for apm_info */ #define AC_LINE_STATUS_OFF (0) #define AC_LINE_STATUS_ON (1) #define AC_LINE_STATUS_BACKUP (2) #define AC_LINE_STATUS_UNKNOWN (0xff) #define BATTERY_STATUS_HIGH (0) #define BATTERY_STATUS_LOW (1) #define BATTERY_STATUS_CRITICAL (2) #define BATTERY_STATUS_CHARGING (3) #define BATTERY_STATUS_ABSENT (4) #define BATTERY_STATUS_UNKNOWN (0xff) #define BATTERY_FLAGS_HIGH (0x1) #define BATTERY_FLAGS_LOW (0x2) #define BATTERY_FLAGS_CRITICAL (0x4) #define BATTERY_FLAGS_CHARGING (0x8) #define BATTERY_FLAGS_ABSENT (0x80) #define BATTERY_PERCENTAGE_UNKNOWN (-1) #define BATTERY_TIME_UNKNOWN (-1) extern int apm_exists(void); extern int apm_read(apm_info * i); extern dev_t apm_dev(void); extern int apm_open(void); extern int apm_close(int fd); extern int apm_get_events(int fd, int timeout, apm_event_t * events, int n); extern int apm_suspend(int fd); extern int apm_standby(int fd); extern int apm_set_ignore(int fd, int mode); extern const char *apm_error_name( unsigned int err ); extern const char *apm_event_name(apm_event_t event); extern const char *apm_time(time_t t); extern const char *apm_delta_time(time_t then, time_t now); extern const char *apm_time_nosec(time_t t); #ifdef APM_IOC_REJECT extern int apm_reject(int fd); #else #define apm_reject(fd) (-EINVAL) #endif apmd-3.2.2.orig/xapm.10000644001167100001440000000734107775757737014425 0ustar cphusers00000000000000.\" xapm.1 -- .\" Created: Thu Jan 11 16:29:49 1996 by r.faith@ieee.org .\" Revised: Sun Apr 21 16:37:42 1996 by r.faith@ieee.org .\" Copyright 1996 Rickard E. Faith (r.faith@ieee.org) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .TH XAPM 1 "January 2004" "" "" .SH NAME xapm \- display Advanced Power Management (APM) BIOS information .SH SYNOPSIS .B xapm [ ... ] .SH DESCRIPTION .B xapm puts up an X window that displays the remaining battery life. The left side of the window contains a printed time or percentage; the right side of the window contains a bar indicating the percentage. Clicking on the left side of the window will toggle the display between time and percentage. .SH "OPTIONS AND RESOURCES" In addition to standard Xt options, the following options are available: .TP .B \-V Print the program version number and exit. .TP .BI \-highcolor " color" The color of the bar when the battery percentage is above .IR highvalue . Defaults to "green". (*highColor) .TP .BI \-lowcolor " color" The color of the bar when the battery percentage is between .I lowvalue and .IR highvalue . Defaults to "yellow". (*lowColor) .TP .BI \-criticalcolor " color" The color of the bar when the battery percentage is below .IR lowvalue . Defaults to "red". This color is also used to flash the alphanumeric part of the display when the power status is critical. (*criticalCOlor) .TP .BI \-highvalue " highvalue" Set .IR highvalue . The default is 50. (*highValue) .TP .BI \-lowvalue " lowvalue" Set .IR lowvalue . The default is 10. (*lowValue) .TP .BI \-chargingcolor " color" The color of the printed display when charging. The default is "blue". Use .B \-foreground to change the color used when on battery power. (*chargingColor) .TP .BI \-delay " delay" Sets the number of seconds delay between each update. The default is 1. (*delay) .TP .B \-percent Display percentage on startup, instead of time remaining. (*percent, boolean) .TP .B \-percentauto Swap automatically between displaying percentage and displaying the time remaining. When on ac power, display percentage, when on battery power, display the time remaining. .SH BUGS There is no way to inhibit the alphanumeric display or the bar display. When the battery percentage is low, using a bright color to warn you of impending doom may be futile because the bar is too short. Because of the form widget's desire to maintain proportions, dynamic resizing of the window may not do what you want it to do. .SH FILES .I /proc/apm .SH AUTHOR This program was written by Rik Faith (faith@cs.unc.edu) and may be freely distributed under the terms of the GNU General Public License. There is ABSOLUTELY NO WARRANTY for this program. The current maintainer is Avery Pennarun (apenwarr@worldvisions.ca). .SH "SEE ALSO" .BR apm (1), .BR apmd (8). apmd-3.2.2.orig/apmsleep.c0000644001167100001440000002227710044353073015315 0ustar cphusers00000000000000/* apmsleep.c: * Suspend computer using APM and wake-up at given time using * the Real Time Clock (RTC) device. * * see man page apmsleep.1 for further details * * Possible applications: * - Run certain internet lookup programs at certain times * e.g. download email, news, etc. * - Send Faxes at night, but do not run laptop all night * - Start up in the morning to catch up old cron jobs * * Hint: * use 'date' to calculate suspend time including daylight saving * time correction. * * Possible future extensions (anyone?): * - correct handling daylight saving time jumps * - Set/restore '/dev/nvram' to set 'suspend to dram' option * - apmcron job scheduler to add flexibility * * Based on Paul Gortmacher's RTC Test/Example Program * Copyright (C) 1999, Peter Englmaier * * Released under the GNU General Public License, version 2, * included herein by reference. * * $Log: apmsleep.c,v $ * Revision 1.1 1999/08/02 20:08:08 apenwarr * * * Integrated apmsleep, and added xbattery (but without Makefile support). * * Revision 0.5 1999/08/01 01:29:29 ppe * Now using the apm library * * Revision 0.4 1999/07/19 16:45:29 ppe * *** empty log message *** * * Revision 0.3 1999/07/19 16:10:38 ppe * Bug in wakeup time calculation corrected. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include static char rcsid[]="$Id: apmsleep.c,v 1.1 1999/08/02 20:08:08 apenwarr Exp $"; static char rcsrev[] = "$Revision: 1.1 $"; void version() { printf("Version: %s (apmsleep 1.3)\n",rcsrev); } void usage() { printf("Usage:\n\n" "apmsleep [+]hh:mm\n\n" "Example:\n" " apmsleep +1:15 will suspend for one hour and 15 minutes\n" " apmsleep 8:00 will suspend until 8:00 am\n\n" "Bugs: Daylight saving jumps are not taken into account.\n" " Modem ring detection may trigger early wake-up.\n" " Does not work with Suspend to Disk.\n" "Bug reports to author Peter Englmaier .\n"); } int main(int argc, char **argv) { int i, rtcfd, retval; struct rtc_time rtc_tm; struct tm kernel_tm; time_t kernel_time, new_time, old_time; char *p; int c; int apmfd=-1; /* APM device file descriptor */ int isoffset; /* setting time offset */ int hour, minute; /* alarm time requested */ int hour1, minute1; /* backup for precise_mode */ int flag; static int suspend_mode=0, wait_mode=0, debug_mode=0, precise_mode=0, noapm_mode=0; while (1) { /* int this_option_optind = optind ? optind : 1; */ int option_index = 0; static struct option long_options[] = { {"help", 0, 0, 'h'}, {"debug", 0, 0, 'd'}, {"version", 0, 0, 'V'}, {"suspend", 0, 0, 's'}, {"standby", 0, 0, 'S'}, {"wait", 0, 0, 'w'}, {"noapm", 0, 0, 'n'}, {"precise", 0, 0, 'p'}, {0,0,0,0} }; c = getopt_long(argc, argv, "hdVsSwnp", long_options, &option_index); if (c == -1) break; switch(c) { case 'h': usage(); exit(0); case 'V': version(); exit(0); case 'd': debug_mode=1; break; case 's': /*suspend*/ suspend_mode=0; break; case 'S': /*standby*/ suspend_mode=1; break; case 'n': /*noapm*/ noapm_mode=1; wait_mode=1; break; case 'w': wait_mode=!precise_mode; break; case 'p':/*precise*/ precise_mode=1; break; case '?': /*unknown option*/ exit(1); default: fprintf(stderr,"unknown option return %d\n", c); exit(1); } } /* end while (1) */ if (optind < argc) { if (optind+1 != argc) { fprintf(stderr,"To many arguments.\n"); usage(); exit(1); } p=argv[optind]; isoffset=0; if (p[0]=='+') { p++; isoffset=1;} if (2!=sscanf(p, "%d:%d", &hour, &minute)) { fprintf(stderr,"apmsleep: Bad argument(s)\n"); exit(1); } hour1=hour; minute1=minute; /* backup */ } else { fprintf(stderr,"apmsleep: missing argument.\n"); usage(); exit(1); } if (noapm_mode) suspend_mode=2; /* argument processing finished */ if (geteuid()!=0) { fprintf(stderr, "apmsleep: warning: This program must be run as root " "or have the SUID attribute set\n"); } /* check if APM is supported */ if (apm_exists()) { fprintf(stderr, "apmsleep: Your kernel does not support APM.\n"); fprintf(stderr, "apmsleep: Recompile kernel with APM and " "/dev/rtc support\n"); exit(1); } if (!noapm_mode) { apmfd=open(APM_DEVICE, O_WRONLY); if (apmfd < 0) { fprintf(stderr, "apmsleep: Cannot open APM device.\n"); exit(1); } } rtcfd = open ("/dev/rtc", O_RDONLY); if (errno == EACCES) { fprintf(stderr, "apmsleep: You don't have permission to " "access /dev/rtc\n"); fprintf(stderr, "apmsleep: The program must be run as root " "or have the SUID attribute set\n"); exit(errno); } if (rtcfd == -1) { perror("/dev/rtc"); fprintf(stderr, "apmsleep: Your kernel does not support " "the real time clock device\n"); fprintf(stderr, "apmsleep: Recompile kernel with APM and " "/dev/rtc support\n"); exit(errno); } /* Read the RTC time/date */ retval = ioctl(rtcfd, RTC_RD_TIME, &rtc_tm); if (retval == -1) { perror("ioctl"); exit(errno); } /* Read Kernel time/date */ time(&kernel_time); kernel_tm=*localtime(&kernel_time); if (debug_mode) { printf("Current RTC time is %02d:%02d:%02d.\n", rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec); printf("Current local time is %02d:%02d:%02d.\n", kernel_tm.tm_hour, kernel_tm.tm_min, kernel_tm.tm_sec); } /* set alarm time in RTC */ if (isoffset) { if (hour == 0 && minute == 0) exit(0); hour+=(int)rtc_tm.tm_hour; minute+=(int)rtc_tm.tm_min; hour1+=(int)kernel_tm.tm_hour; minute1+=(int)kernel_tm.tm_min; } else { /* Special case - wake-up time equal current time this may cause to systems to crash according to a user report. Therefore, we do not suspend in this case. */ if (hour == kernel_tm.tm_hour && minute == kernel_tm.tm_min) { printf("Wake-up time equal to current time. Suspend not required\n"); exit(0); } rtc_tm.tm_sec=0; /* here we take difference between RTC and localtime into account */ minute+=(int)rtc_tm.tm_min - (int)kernel_tm.tm_min; hour+=(int)rtc_tm.tm_hour - (int)kernel_tm.tm_hour; } while (minute<0) {minute +=60; hour--; } while (minute>=60) {minute -=60; hour++; } while (hour < 0) hour += 24; hour %= 24; rtc_tm.tm_min = minute; rtc_tm.tm_hour = hour; if (debug_mode) printf("Setting RTC alarm time to %02d:%02d:%02d.\n", hour, minute, rtc_tm.tm_sec); retval = ioctl(rtcfd, RTC_ALM_SET, &rtc_tm); if (retval == -1) { perror("ioctl"); exit(errno); } /* Read back the current alarm settings */ retval = ioctl(rtcfd, RTC_ALM_READ, &rtc_tm); if (retval == -1) { perror("ioctl"); exit(errno); } if (debug_mode) printf("RTC alarm time now set to %02d:%02d:%02d.\n", rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec); /* Enable alarm interrupts */ retval = ioctl(rtcfd, RTC_AIE_ON, 0); if (retval == -1) { perror("ioctl"); exit(errno); } /* Save time before suspending */ time(&new_time); kernel_time=new_time; if (fork()==0) { /* suspend system -- called from within a child, to make * sure we don't miss the time leap */ switch(suspend_mode) { case 0: apm_suspend(apmfd); break; case 1: apm_standby(apmfd); break; } exit(0); } if (debug_mode) { printf("Waiting until clock jumps\n"); fflush(stdout); } flag=1; /* Note: flag is used as exit value */ if (precise_mode) { /* wait for clock match alarm time */ if (debug_mode) printf("Wait for wakeup time\n"); do { int diff; /* Read Kernel time/date */ time(&kernel_time); kernel_tm=*localtime(&kernel_time); if (debug_mode) printf("Time: %02d:%02d:%02d, wakeup time: %02d:%02d:%02d\n", kernel_tm.tm_hour, kernel_tm.tm_min, kernel_tm.tm_sec, hour1, minute1, 0); diff= hour1*60 + minute1 - kernel_tm.tm_hour*60 - kernel_tm.tm_min; diff %= (24*60); flag=(diff!=0 && diff!=-1); if (flag) sleep(10); } while (flag); } else { /* wait for the actual sleep event */ do { old_time=new_time; sleep(2); time(&new_time); flag=difftime(new_time,old_time)<10.0; /* check for time out */ if (flag && wait_mode==0 && difftime(new_time,kernel_time)>120.0) break; /* timeout, flag is 1 */ } while (flag); if (flag) fprintf(stderr,"Time out -- no time leap happened\n"); else if (debug_mode) printf("Time leap detected\n"); } /* Waiting for child to finish */ wait(&i); /* Disable alarm interrupts */ retval = ioctl(rtcfd, RTC_AIE_OFF, 0); if (retval == -1) { perror("ioctl"); exit(errno); } close(rtcfd); if (!noapm_mode) close(apmfd); return flag; } apmd-3.2.2.orig/apmd.80000644001167100001440000002504207775757411014373 0ustar cphusers00000000000000.\" apmd.8 -- .\" Created: Wed Jan 10 15:07:25 1996 by faith@acm.org .\" Revised: Fri Dec 26 20:34:52 1997 by faith@acm.org .\" Revised: Wed Jun 2 18:47:02 1999 by db@post.harvard.edu .\" Copyright 1996, 1997 Rickard E. Faith (faith@acm.org) .\" Copyright 1999 David Brownell (db@post.harvard.edu) .\" Modified Feb 2002 Chris Hanson .\" Modified Feb 2002 Thomas Hood jdthood_AT_yahoo.co.uk .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .TH APMD 8 "January 2004" "" "" .SH NAME apmd \- Advanced Power Management (APM) daemon .SH SYNOPSIS .BI "apmd" .BI "[ \-TVWciqv ]" .BI "[ \-P " program " ]" .BI "[ \-T " seconds " ]" .BI "[ \-c " seconds " ] .BI "[ \-p " percent " ]" .BI "[ \-v " level " ] .BI "[ \-w " percent " ] .SH DESCRIPTION .B apmd is an monitoring daemon for the Advanced Power Management (APM) subsystem. The APM subsystem consists of power-management hardware, firmware usually referred to as the APM BIOS and a driver in the operating system kernel. The daemon can execute a program (usually a shell script) when events are reported by the APM subsystem, and will log, via .BR syslogd (8), certain changes in power status. When the available battery power becomes very low it can alert the user. .PP When the APM subsystem notifies the daemon of a pending suspend or standby request, .B apmd will run a proxy program, log the event, .BR sync (2) data to the disk and then tell the APM subsystem to continue its operation. .PP Preparations for power management events are made mainly by the proxy .I program specified using the \-P option. The proxy program is invoked with one or two arguments: .TP .B start Invoked when the daemon starts. .TP .B stop Invoked when the daemon stops. .TP .B standby "( system | user )" Invoked when the APM subsystem reports that standby has been initiated. The second parameter indicates whether firmware ("system") or software ("user") was the originator of the event. .sp The "standby" mode conserves power but leaves the machine able to respond almost immediately to user activity. Most laptops can't stay in standby mode on battery power for more than a few hours or a day. Normally, nothing special needs to be done to prepare for "standing by". .TP .B suspend "( system | user )" Invoked when the APM subsystem reports that suspension has been initiated. The second parameter indicates whether firmware ("system") or software ("user") was the originator of the event. .sp The "suspend" mode aggressively conserves power. Usually this involves shutting off power to all devices except the CPU core and memory, which are put into a very low power mode. Most laptops can stay suspended, using battery power alone, for several days. ("Hibernation" is a kind of super-suspend, where all that state is written to disk and the machine uses no power. Hibernation is treated like suspension by the APM subsystem.) .sp Before suspending, PCMCIA devices may need to be disabled using .BR cardctl (8), and some modular device drivers may need to be unloaded if they have not been designed to support power management. .TP .B resume "( suspend | standby | critical )" Invoked when the APM subsystem reports that computer has resumed normal operation. The second parameter indicates the kind of event from which the system is resuming. (A "critical" suspend is a suspension that the APM subsystem performs in an emergency. Some kernels do not pass this event to user space. If .B apmd receives the event, it acknowledges the event and exits immediately without logging or running the proxy program.) .sp When resuming, PCMCIA devices may need to be re-enabled using .BR cardctl (8), and some modular drivers may need to be reloaded. Note that in the case of a critical suspend, the system state may not have been completely saved. .TP .B change power Invoked when the APM subsystem reports a change in power status, such as a switch from mains to battery power. .ig .TP .B change time Invoked when the APM subsystem reports a time change. .. .TP .B change battery Invoked when the APM subsystem reports that the charge of one or more batteries is low. A few minutes of battery power may remain. .TP .B change capability Invoked when the APM subsystem reports some change in power management capabilities. It may have been caused by operation of a setup utility, or by the installation or removal of devices. .PP .B apmd emits various messages, most of which are self-explanatory. Battery status log entries contain three fields, separated by commas. The first field indicates how full the battery is as a percentage of its capacity. The second field indicates whether the battery is charging, not charging, or discharging. When possible, .B apmd adds in parentheses its estimate of the rate of charging or discharging. The third field indicates how much time the battery can or could be used to power the computer. This information is provided by the APM subsystem. When possible, .B apmd adds in parentheses its own estimate of the battery life (if discharging) or of the time required to charge the battery fully (if charging). .SH OPTIONS .TP .BR "\-P " program, " \-\-proxy " program Specifies the proxy program to execute when events are received. See above for information about the arguments supplied to this program. .TP .BR "\-T [" seconds "] , \-\-proxy\-timeout [" seconds "]" Sets a time-out for the proxy. Without this option (or with this option and a negative argument) .B apmd waits indefinitely for the proxy to finish. If the proxy enters an infinite loop or wait then the machine may appear to have crashed. If this option is given a positive integer argument then .B apmd will wait only that many seconds for the proxy to finish, after which it will log a warning, kill the proxy, and continue processing the event. The default is 30 seconds. .TP .B \-V, \-\-version Prints the version of the .B apmd program. .TP .B \-W, \-\-wall In addition to logging low battery status (as determined either by the \fB\-w\fR level or by the firmware) using .BR syslog (2), .B apmd will, given this option, also use .BR wall (1) to alert all users. This is most useful if .BR syslogd (8) is not set up to write ALERT messages to all users. If both methods are used, more warnings will be made during the critical time period. .TP .BR "\-c [" seconds "] , \-\-check [" seconds "]" Controls how many seconds to wait for an event. Without this option (or with this option and a negative argument) apmd waits indefinitely for an event. If this option is given a positive integer argument then .B apmd will wait only that many seconds before checking the battery level and possibly sending out a warning, calling the proxy or making an entry in the log. The default is 30 seconds. .TP .B \-i, \-\-ignore\-bios\-battery\-low Causes .B apmd to ignore a LOW BATTERY signal sent by the APM subsystem. Some firmware signals a low battery at the wrong time. Note that LOW BATTERY events may still be generated by .B apmd itself based on the warning level. .TP .BR "\-p " percent, " \-\-percentage " percent Controls how often the battery status is logged. A new line is printed each time the battery content changes by .IR percent_change if logging is enabled. The default is 5. Use a value greater than 100 to disable periodic logging of the battery level. .TP .B \-q, \-\-quiet\-bios\-battery\-low Causes .B apmd not to generate a warning when a LOW BATTERY signal is received from the APM subsystem. The firmware on some machines produces an audible warning when power is about to be used up, so an extra warning may not be needed. .TP .BR "\-v [" level "] , \-\-verbose [" level "]" The daemon can generate messages of varying degrees of unimportance. Each message is assigned one of the priority levels defined for the .BR syslogd (8) subsystem, ranging from 0 (EMERG, least unimportant) to 7 (DEBUG, most unimportant). This option sets the threshold level above which messages are suppressed. Without an argument it increments the threshold by 1, thus making .B apmd more verbose. The default is 5 (NOTICE). .TP .BR "\-w " percent, " \-\-warn " percent When the battery is not being charged and the battery content falls below the specified percent of capacity, and no such event has yet occurred in the current discharge cycle, .B apmd will log a warning at the ALERT log level to .BR syslog (2) and generate a LOW BATTERY event. If the .B \-W or .B \-\-wall option was given, the daemon will also use .BR wall (1) to alert all users of impending doom. The default warning level is 10. Use a negative value to disable this feature. .TP .B \-h, \-\-help Causes .B apmd to print a brief command summary and exit. .SH BUGS This daemon supports all APM events described in the APM BIOS specification version 1.2; however it fails to support some of the advanced features of APM 1.2, such as reporting the conditions of multiple batteries. (Multiple batteries are currently treated as if they were just one large one.) .PP Estimates of charge and discharge rates and times can be very inaccurate. .PP There is no interaction yet with ACPI support as found in newer PC hardware. .SH FILES .TP .I /dev/apm_bios Device through which apmd communicates with the Linux APM driver. .TP .I /proc/apm APM driver status information .TP .I /etc/apmd_proxy Proxy program that is run if none is specified. .TP .I /etc/apm/apmd_proxy Proxy program that is run if none is specified. (Debian) .SH AUTHOR This program was written by Rik Faith (faith@cs.unc.edu) and may be freely distributed under the terms of the GNU General Public License. There is ABSOLUTELY NO WARRANTY for this program. The current maintainer is Avery Pennarun (apenwarr@worldvisions.ca). .SH "SEE ALSO" .BR apm (1), .BR xapm (1), .BR cardctl (8), .BR syslogd (8). apmd-3.2.2.orig/ChangeLog0000644001167100001440000004340007775762216015130 0ustar cphusers000000000000002004-01-04 Thomas Hood * Release 3.2.1 - Update this ChangeLog - Update VERSION in Makefile * Integrate README.transfer into ChangeLog * Integrate obsolete README into ChangeLog * Rename ANNOUNCE to README, update and add license refs * Delete TODO * Create AUTHORS * Rename COPYING.LIB to apmlib.COPYING * Fix typo in apmlib.COPYING * Update COPYING * Rename BUGS.apmsleep to apmsleep.README * manpages: - Updated - They no longer need patches for Debian - Dashes are escaped with backslashes - Refer to "line" power as instead of "AC" power - French apmsleep man page is apmsleep.fr.1 * Move stephen_disenable_patch into abilitize/ * Copy on_ac_power from Debian version * Evacuate apmd_proxy since everything in there was obsolete * Update LSM 2003-01-16 Chris Hanson * Release 3.2.0: further cleanups by Thomas Hood after several versions of the 3.1.0 Debian packages. 2002-12-08 Thomas Hood * Release 3.1.0 Some of the changes: * Clean up handling of suspend and standby rejection. (It was proposed long ago that the Linux apm driver allow userspace to reject suspend & standby requests by issuing an ioctl(APM_IOC_REJECT). This has not yet been implemented. Nevertheless, most of the supporting code has now been added to apmlib and apmd.) apm_reject() is defined as -EINVAL in apm.h; however a stub function of the same name is still compiled for inclusion in libapm * Try to use the term "line" rather than "AC", since the external power source isn't always AC. * apm.h * Define apm_reject() as a constant (-EINVAL) so that programs that use this header will have the call optimized away for now * apmlib.c * Clean up * apm_suspend() passes EBUSY error code from apm driver * apm_reject() returns -EINVAL for now, but the code should now be ready for implementation (in the apm driver) of userspace rejection of suspend and standby requests. * Remove unneeded apm_last_error() function. Errors are returned by ioctl() in errno and can be returned from functions in apmlib such as apm_suspend() and apm_reject(). * apmd.c * Clean up extensively * Improve battery status printing * Improve verbosity handling * Add -T option to terminate proxies that fail to complete within a reasonable time * Add -i option to deal with bogus LOW BATTERY events on some machines * Handle -EBUSY error code (which signals rejection of suspend request) from apm_suspend() * Fix up use of apm_reject(). apmd.c should now be ready for implementation of userspace rejection of suspend and standby requests. * Log event before running proxy * Call proxy with "change power" when battery starts or stops charging * Move change log material at the top of the file to this ChangeLog * apmd.8 * Largely rewritten * apm.c * Fix bug: didn't update on switch to battery power * Clean up output * xapm.c * 'P' => 'L' in display (for "line" power) * Makefile * Add some targets * on_ac_power * Largely rewritten 2001-09-13 Avery Pennarun * debian/00hwclock, debian/20hdparm, debian/apmd_proxy, debian/apmd_proxy.conf, debian/changelog, debian/conffiles, debian/config, debian/control, debian/copyright, debian/dirs, debian/postinst, debian/rules, debian/templates: A bunch of Debian-related fixes (debconf and apmd_proxy.conf) from Chris Hanson . 2001-05-11 Avery Pennarun * debian/apmd_proxy, debian/changelog, debian/control, apmd.8, apmsleep.1: Several debian-related fixes. * debian/control, apm.c, apmlib.c, apmsleep.c, stephen-disenable-patch, tailf.1: Various changes, particularly to make it build on newer libc versions. 2000-06-14 Avery Pennarun * apm.c: Patch from Dominik Rothert for "apm --monitor" to show a continually-updated apm status on a terminal or in a window. 2000-05-18 Avery Pennarun * debian/changelog, debian/dirs, debian/rules, Makefile: Changes for Debian package 3.0final-2. 2000-02-07 Avery Pennarun * Makefile, apmsleep.1, apmsleep.c: New apmsleep -precise flag from Peter Englmaier. 2000-01-07 Avery Pennarun * BUGS.apmsleep, apmsleep.1, apmsleep.c: apmsleep from Peter Englmaier * debian/changelog, debian/postinst, debian/postrm, debian/preinst, debian/prerm, debian/rules, debian/xaw, Makefile: apmd 3.0final release. 1999-12-07 Avery Pennarun * apmd.c, apmd_proxy: Craig Markwardt's patch: estimate battery life from a major checkpoint instead of a minor one; reset on_ac_power upon resuming from a suspend. * debian/00hwclock, debian/control, apmd.8: Some debian patches from long ago... 1999-10-18 Avery Pennarun * apm.c: Fix to the 'apm' command: -m should _always_ display the minutes remaining, not sometimes the seconds. Thanks to Chris Lawrence for pointing this out. 1999-08-09 Avery Pennarun * debian/00hwclock, debian/changelog, debian/rules, apmd.c, apmlib.c: Some debian-related fixes. 1999-08-03 Avery Pennarun * debian/changelog, debian/rules, Makefile: *** empty log message *** 1999-08-02 Avery Pennarun * xbattery/.cvsignore, xbattery/Imakefile: xbattery .cvsignore file and Makefile fix. * xbattery/BatteryGauge.c, xbattery/BatteryGauge.h, xbattery/BatteryGaugeP.h, xbattery/Imakefile, xbattery/README, xbattery/xbattery.c, xbattery/xbattery.man, .cvsignore, BUGS.apmsleep, Makefile, apmsleep.1, apmsleep.c: Integrated apmsleep, and added xbattery (but without Makefile support). * debian/00hwclock: New Debian systems set UTC instead of GMT in /etc/default/rcS (yay for gratuitous changes). We'll use them both in the debian 00hwclock script. 1999-07-28 Avery Pennarun * debian/00hwclock: Fix for 00hwclock to make it work in bare-bones POSIX shells. From Obi 1999-07-05 Avery Pennarun * apmlib.c: Got rid of a compile warning. * apm.h, apmd.c, apmd_proxy, apmlib.c: Patch from Craig Markwardt: apmd_proxy: Added more PCMCIA handling, debugging examples, ability to disable sound, X-Windows, etc. Some configuration options are now up front. Most power profiling is disabled by default, to not abuse incompatible APM BIOSes. Makefile: Install apmd_proxy with -Vt option, numbers the backup files. apm.h, apmlib.c: added functions apm_reject, apm_last_error, apm_error_name. Set APM_REJECT_ENABLED automatically based on kernel IOCTL value. apmd.c (apmd_log): correct semantics for syslog(). apmd.c (apmd_power_reset, apmd_check_power): correct semantics for apmd_log (no multiply-protected "%" signs). apmd.c (apmd_check_power): moved synthetic_low_battery; made simple logging event a minor_checkpoint again, as per definition. * Makefile, apmd.c, apmd_proxy: Changed version to beta9 so I (hopefully) don't get confused. 1999-06-16 Avery Pennarun * Makefile, apmd.c: Fixes for a VERY stupid Makefile bug, and some sprintf-percent-symbol fixes from Craig Markwardt . * debian/changelog: *** empty log message *** * Makefile, apmd.8, apmd.c, apmd_proxy, apmlib.c: Lots of updates and bugfixes from David Brownell . He also wins the grand prize for getting the man page up to date, although there is no prize: * Reduced spurious and repeated syslog messages, as well as the number of times the proxy gets called during charging/discharging. Minor cleanup and commenting. Documentation updated. Power status reporting now goes by line status only. -- David Brownell, db@post.harvard.edu, 14 June 1999 1999-06-09 Avery Pennarun * debian/apmd_proxy: Fix for a REALLY dumb bug in debian/apmd_proxy (oops) from . 1999-06-07 Avery Pennarun * Makefile, apmd.c: Default location for apmd to look for apmd_proxy is now the same as the directory where it is installed. (Neat, huh?) * debian/rules: Debian package now actually installs the man pages again! 1999-06-05 Avery Pennarun * LSM: Hmm, LSM entry was rather out-of-date. * debian/00hwclock, debian/apmd.init, debian/apmd_proxy, debian/changelog, debian/conffiles, debian/control, debian/dirs, debian/rules: Make a Debian-specific apmd_proxy program (maybe I should just make that everyone's default?) and included a Debian-specific 00hwclock script that will be run to set the clock at the right times. Updated all the other Debian stuff so that it works. * Makefile, apmd.c, apmd_proxy, apmlib.c, on_ac_power: Removed some pauses, and wrote my own on_ac_power script. * apm.c, apm.h, apmd.c, apmd_proxy, apmlib.c, tailf.c, xapm.c: Ran the whole thing through 'indent' to widen the tabs. * Makefile, apm.c, apmd.c, apmlib.c, tailf.c, xapm.c: Merged back the post-3.06beta6 changes (well, the ones that Craig didn't obsolete.) * Makefile, apmd.c, apmd_proxy, apmlib.c: Added massive changes to clean up the code and implement a "central dispatcher" -- many thanks to Craig Markwardt : * Changes to support centralized dispatch routines, generalized logging, general code cleanup, add support for apm_reject and APM_CAPABILITY_CHANGE. In doing this, I lost all the other changes people sent in since beta6... now I need to re-integrate them, where applicable. 1999-05-09 Avery Pennarun * apmd.c: Patch from Seth Golub to fix the broken implementation of on-battery and on-ac-power events. Oops. 1999-04-07 Avery Pennarun * debian/rules: *** empty log message *** * Makefile, apm.1, apm.c, apm.h, apmlib.c, kernel-2.0.36.patch: Added a patch to support "ignore suspend events" from Jon A. Christopher . (Requires you to apply a patch to your kernel; a patch for kernel 2.0.36 is included.) Changed Makefile to grab include files from various kernel source directories before resorting to /usr/include/linux. 1999-04-05 Avery Pennarun * debian/changelog: *** empty log message *** * debian/changelog: Finalizing changes for 3.0beta6. * xapm.c: Included a patch for the IBM Thinkpad 770X from Bill Mair . The letters P or B in the display represent AC power and battery power, respectively. 1999-03-02 Avery Pennarun * Makefile, apmd.c: Patch to add now-on-battery and now-on-wallpower scripts, from J.D. Smith . This will probably change to a more flexible scheme in the future, but this is an awfully popular feature so I'll include it now: * Add support to apmd for ac_offline, ac_online commands to execute when the power status changes. This is useful to set hard drive spindown rates and other configureable power saving options when the ac cord is inserted or removed. New options: long form: -a ac_online_cmd ac_online -b ac_offline_cmd ac_offline * apmd.c: Added -q "quiet mode" patch from Robert de Bath . When this option is given, apmd doesn't syslog so many different events. * debian/changelog: *** empty log message *** 1999-01-24 Avery Pennarun * apmd.c: Must use fork() instead of vfork() -- there's actually a difference between them in 2.2.0 kernels! 1998-11-08 Avery Pennarun * debian/changelog, Makefile: Changed version number to 3.0beta4. * debian/apmd.init, debian/changelog, apm.1, apmd.8, apmd.c, tailf.1, xapm.1: Changes for Debian's apmd 3.0beta3-3. 1998-09-17 Avery Pennarun * debian/dirs, debian/changelog, debian/apmd.init, TODO: Checked in 3.0beta3-2 changes a bit late. 1998-09-12 Avery Pennarun * debian/control, debian/changelog, apmd.c, Makefile: apmd 3.0beta3 * apmlib.c, apmd.c: Thinkpad + features patch from Pavel Machek . 1998-09-11 Avery Pennarun * debian/.cvsignore, debian/changelog, Makefile, LSM, ANNOUNCE, .cvsignore: Released apmd 3.0beta2. * apmd.c: post_resume_cmd doesn't run, and we don't reset the clock when coming back from "standby" mode. Also fixed some error message output. 1998-09-06 Avery Pennarun * debian/rules, debian/dirs, debian/changelog, debian/apmd.init, apmd.c, Makefile, .cvsignore: Fixed implementation of '-s' option (now I know why this was called "PRE" 3.0 when I got it). Fixed up Debian package scripts a bit more. Releasing this version as 3.0beta1. * debian/dirs, debian/changelog, debian/apmd.init: Changes to support /etc/apm-suspend.d and /etc/apm-resume.d under Debian. * apmd.c, apmd.8, Makefile: Added --utc (-u) option, to specify that the BIOS clock is set to UTC. We also choose automatically between the /sbin/clock and /sbin/hwclock programs. * debian/apmd.init, debian/changelog, debian/conffiles, debian/control, debian/copyright, debian/dirs, debian/postinst, debian/postrm, debian/preinst, debian/prerm, debian/rules, apm.c: Integrated Debian patch from apmd-2.4-12 package, and updated a few Debian-related things. * apmd-2.4.Notes, README.transfer, apmd-2.4-to-pre-3.0-diffs, COPYING, COPYING.LIB, LSM, .cvsignore, ANNOUNCE: Rearranged a few files to take over ownership of the package and prepare for release of 3.0beta1. 1998-07-26 faith Date: Sun, 26 Jul 1998 09:04:53 -0400 Message-Id: <199807261304.JAA02109@mancer.cs.unc.edu> From: Rik Faith To: Avery Pennarun Cc: Rik Faith Subject: New maintainer for Linux apmd package -----BEGIN PGP SIGNED MESSAGE----- Avery Pennarun, currently the Debian apmd maintainer, has graciously agreed to take over general maintenance of the Linux apmd package. Since the release of apmd-2.4, I have been extremely busy and have not been able to work on apmd as much as I would have liked. Further, I do not expect to be able to pick up maintenance of apmd in the foreseeable future, so it is best for the Linux community that I officially transfer control of the package to Avery. -----BEGIN PGP SIGNATURE----- Version: 2.6.2 Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface iQCVAwUBNbsl5wkpZvlFoM4xAQHNlgQAqORshKK5xWu4XLCdnAZOrr2c6ldS6MHv ZLJKuS+G1X1nrQFSTZeaLuRYh5hu6mMzVpwlN9dgZkzlj3KgDwK60fOXthdSOgWG wiHhRncydGEu+abZlnR4YPPIgRnEG7taSj35DanKV/IEVlNzGZlfRoPGWiJ560Br gTfuNrcEIxc= =pVNX -----END PGP SIGNATURE----- 1998-07-26 faith * apmd.c, apmlib.c, apm.c, apmd-2.4-to-pre-3.0-diffs, apmd.8, Makefile: Some patches from email applied in December 1997 * Patches to support pre_suspend, post_resume and low_battery commands -- 1996-12-24 Bjoern Kriews 1996-05-04 faith * ANNOUNCE: Update required kernel version number Public release of apmd 2.4 1996-04-21 faith NOTE: Sun Apr 21 16:25:43 1996 This is a completely re-written apmd for Linux. It will work with 1.3.58 kernels, which have a new format for /proc/apm, and with older kernels. I have severely limited time to work on APM -- please do *NOT* send me mail about how to use these utilities with older kernels. If you want to use these utilities with a production kernel, please wait until 2.0.x comes out -- since we are in a code freeze, it is only a waste of time to use these utilities or the APM patches with 1.2.x. If you have bug reports, please include patches which fix them -- chances are that I will not be able to produce your specific bug on my system. apm is a stand-alone utility which prints the /proc/apm information in a nice format. xapmd is a little X utility that provides a bar graph of the battery status. 1996-04-21 faith * xapm.1, xapm.c, apmd-2.4.Notes, apmd.8, apmd.c, apmd-2.2.Notes, README, apm.1, ANNOUNCE, LSM: Pre-2.4 updates. * apm.c: Only report battery status for 1.1 BIOSs * apm.c, Makefile, README, apm.1, ANNOUNCE: Patches from Stephen Rothwell to support --suspend and --standby 1996-04-05 faith * apmd-2.2.Notes, apmd-2.1.Notes: BOGUS 2.0 Notes file * apmd.c, apmlib.c, Makefile, apm.h, ANNOUNCE, LSM: Add support for /dev/apm_bios at (10,134) 1996-01-14 faith * apm.c: Fixed typo * apmlib.c, apm.h, LSM, README, apm.c, ANNOUNCE: Added backward compatibility support for pre-1.3.58 kernels 1996-01-13 faith * Makefile: Fixed ChangeLog support * apmd-2.1.Notes: BOGUS 2.0 Notes file * ANNOUNCE, README: Added documentation * Makefile: Fixed flag usage * apmlib.c: Cleaned up fread() * xapm.c: Added coloring to ScrollBar border; increased update time * apmd.8, apmd.c: Added -wall option; used apm_time_nosec; consolidate data columns * apm.c: Removed -s and -S options 1996-01-12 faith * Makefile, LSM: Minor fixes * apm.h, apmlib.c: Added apm_time_nosec use * xapm.1, xapm.c: Changed color to blue; added apm_time_nosec use * apmd.c: Fixed logging bug * apm.1, apm.c: Added -m option * Makefile: Added ChangeLog support * Makefile: Fixed flags * xapm.c, xapm.1: Added -percent Added flashing 1996-01-11 faith * xapm.c, tailf.1, tailf.c, xapm.1, apmlib.c, apmlib.h, apm.h, apmd.8, apmd.c, apm.1, apm.c, Makefile, LSM: New functionality and bug fixes. Preparing for release 2.1 (the first official release). 1996-01-09 faith * ANNOUNCE, LSM, Makefile, README, apm.c, apmd.c, apmlib.c, apmlib.h: New file. apmd-3.2.2.orig/apmlib.c0000644001167100001440000002761007775737534015000 0ustar cphusers00000000000000/* apmlib.c -- Sample APM interface routines * Created: Mon Jan 8 10:28:16 1996 by faith@acm.org * Revised: Fri Dec 26 21:38:29 1997 by faith@acm.org * Copyright 1996, 1997 Rickard E. Faith (faith@acm.org) * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include "apm.h" #define BACKWARD_COMPAT 1 /* * Return a string describing an APM event. From p. 16 of the Intel/Microsoft * Advanded Power Management (APM) BIOS Interface Specification, Revision * 1.1 (September 1993). Intel Order Number: 241704-001. Microsoft Part * Number: 781-110-X01. * * Updated to APM BIOS 1.2 spec (February 1996). Available on-line. */ const char *apm_event_name(apm_event_t event) { switch (event) { case APM_SYS_STANDBY: return "System Standby Request"; case APM_SYS_SUSPEND: return "System Suspend Request"; case APM_NORMAL_RESUME: return "Normal Resume System"; case APM_CRITICAL_RESUME: return "Critical Resume System"; case APM_LOW_BATTERY: return "Battery Low"; case APM_POWER_STATUS_CHANGE: return "Power Status Change"; case APM_UPDATE_TIME: return "Update Time"; case APM_CRITICAL_SUSPEND: return "Critical Suspend"; case APM_USER_STANDBY: return "User System Standby Request"; case APM_USER_SUSPEND: return "User System Suspend Request"; case APM_STANDBY_RESUME: return "System Standby Resume"; #ifdef APM_CAPABILITY_CHANGE case APM_CAPABILITY_CHANGE: return "Capability Change"; #endif } return "Unknown"; } /* * Functions to format the time nicely. */ #define SEC_PER_MIN (60) #define SEC_PER_HOUR (SEC_PER_MIN*60) #define SEC_PER_DAY (SEC_PER_HOUR*24) const char *apm_time(time_t t) { static char buffer[128]; unsigned long s, m, h, d; if (t<0) { sprintf(buffer, "?"); return buffer; } d = t / SEC_PER_DAY; t -= d * SEC_PER_DAY; h = t / SEC_PER_HOUR; t -= h * SEC_PER_HOUR; m = t / SEC_PER_MIN; t -= m * SEC_PER_MIN; s = t; if (d) sprintf(buffer, "%lud+%lu:%02lu:%02lu", d, h, m, s); else sprintf(buffer, "%lu:%02lu:%02lu", h, m, s); return buffer; } const char *apm_time_nosec(time_t t) { static char buffer[128]; unsigned long s, m, h, d; if (t<0) { sprintf(buffer, "?"); return buffer; } d = t / SEC_PER_DAY; t -= d * SEC_PER_DAY; h = t / SEC_PER_HOUR; t -= h * SEC_PER_HOUR; m = t / SEC_PER_MIN; t -= m * SEC_PER_MIN; s = t; if (s > 30) ++m; if (d) sprintf(buffer, "%lud+%lu:%02lu", d, h, m); else sprintf(buffer, "%lu:%02lu", h, m); return buffer; } const char *apm_delta_time(time_t then, time_t now) { return apm_time(now - then); } /* * Read information from /proc/apm. Return 0 on success, * 1 if APM not installed, 2 if APM installed but old version. */ int apm_read(apm_info * i) { FILE *str; char units[10]; char buffer[100]; int retcode = 0; if (!(str = fopen(APM_PROC, "r"))) return 1; fgets(buffer, sizeof(buffer) - 1, str); buffer[sizeof(buffer) - 1] = '\0'; /* Should check for other driver versions; driver 1.9 (and some * others) uses this format, which doesn't expose # batteries. */ sscanf(buffer, "%s %d.%d %x %x %x %x %d%% %d %s\n", (char *) i->driver_version, &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, units); i->using_minutes = !strncmp(units, "min", 3) ? 1 : 0; if (i->driver_version[0] == 'B') { /* old style. argh. */ #if !BACKWARD_COMPAT retcode = 2; #else strcpy((char *) i->driver_version, "pre-0.7"); i->apm_version_major = 0; i->apm_version_minor = 0; i->apm_flags = 0; i->ac_line_status = 0xff; i->battery_status = 0xff; i->battery_flags = 0xff; i->battery_percentage = -1; i->battery_time = -1; i->using_minutes = 1; sscanf(buffer, "BIOS version: %d.%d", &i->apm_version_major, &i->apm_version_minor); fgets(buffer, sizeof(buffer) - 1, str); sscanf(buffer, "Flags: 0x%02x", &i->apm_flags); if (i->apm_flags & APM_32_BIT_SUPPORT) { fgets(buffer, sizeof(buffer) - 1, str); fgets(buffer, sizeof(buffer) - 1, str); if (buffer[0] != 'P') { if (!strncmp(buffer + 4, "off line", 8)) i->ac_line_status = 0; else if (!strncmp(buffer + 4, "on line", 7)) i->ac_line_status = 1; else if (!strncmp(buffer + 4, "on back", 7)) i->ac_line_status = 2; fgets(buffer, sizeof(buffer) - 1, str); if (!strncmp(buffer + 16, "high", 4)) i->battery_status = 0; else if (!strncmp(buffer + 16, "low", 3)) i->battery_status = 1; else if (!strncmp(buffer + 16, "crit", 4)) i->battery_status = 2; else if (!strncmp(buffer + 16, "charg", 5)) i->battery_status = 3; fgets(buffer, sizeof(buffer) - 1, str); if (strncmp(buffer + 14, "unknown", 7)) i->battery_percentage = atoi(buffer + 14); if (i->apm_version_major >= 1 && i->apm_version_minor >= 1) { fgets(buffer, sizeof(buffer) - 1, str); sscanf(buffer, "Battery flag: 0x%02x", &i->battery_flags); fgets(buffer, sizeof(buffer) - 1, str); if (strncmp(buffer + 14, "unknown", 7)) i->battery_time = atoi(buffer + 14); } } } #endif } /* Fix possible kernel bug -- percentage * set to 0xff (==255) instead of -1. */ if (i->battery_percentage > 100) i->battery_percentage = -1; fclose(str); return retcode; } /* * Look up the device number of the apm_bios device. */ dev_t apm_dev(void) { FILE *str; static int cached = -1; char buf[80]; char *pt; apm_info i; if (cached >= 0) return cached; if (access(APM_PROC, R_OK) || apm_read(&i) == 1) return cached = -1; if (i.driver_version[0] == '1') return cached = makedev(10, 134); if (!(str = fopen(APM_DEV, "r"))) return -1; while (fgets(buf, sizeof(buf) - 1, str)) { buf[sizeof(buf) - 1] = '\0'; for (pt = buf; *pt && isspace(*pt); ++pt); /* skip leading spaces */ for (; *pt && !isspace(*pt); ++pt); /* find next space */ if (isspace(*pt)) { *pt++ = '\0'; pt[strlen(pt) - 1] = '\0'; /* get rid of newline */ if (!strcmp(pt, APM_NAME)) { fclose(str); return cached = makedev(atoi(buf), 0); } } } fclose(str); return cached = -1; } /* * Return a file descriptor for the apm_bios device, or -1 if there is an * error. * * apenwarr 2001/05/11: just throw out the weird temporary device file stuff. * It was only for ancient kernel versions anyway. * alexamici 2001/12/14: remove the redundant check for kernel apm support. * Now apm_open() triggers the auto-load of the apm module. */ int apm_open(void) { int fd; if ((fd = open(APM_DEVICE, O_RDWR)) < 0) { /* * Try to create it. This is reasonable * for backward compatibility. */ if (mknod(APM_DEVICE, S_IFCHR | S_IRUSR | S_IWUSR, apm_dev())) { unlink(APM_DEVICE); return -1; } fd = open(APM_DEVICE, O_RDWR); } return fd; } /* * Given a file descriptor for the apm_bios device, close it. */ int apm_close(int fd) { return close(fd); } /* * If APM support of the right version exists in kernel, return zero. * Otherwise, return 1 if no support exists, or 2 if it is the wrong * version. *NOTE* The sense of the return value is not intuitive. */ int apm_exists(void) { int fd; apm_info i; /* This will force auto-load of the apm module if necessary. */ fd = open(APM_DEVICE, O_WRONLY); if (fd >= 0) close(fd); if (access(APM_PROC, R_OK)) return 1; return apm_read(&i); } /* * Given a file descriptor for the apm_bios device, this routine will wait * timeout seconds for APM events. Up to n events will be placed in the * events queue. The return code will indicate the number of events * stored. Since this routine uses select(2), it will return if an * unblocked signal is caught. A timeout < 0 means to block indefinately. * * Note that if you read a request to standby or to suspend, the kernel * will be waiting for you to respond to it with a call to apm_suspend() * or to apm_standby() ! */ int apm_get_events(int fd, int timeout, apm_event_t * events, int n) { int retcode; fd_set fds; struct timeval t; t.tv_sec = timeout; t.tv_usec = 0; FD_ZERO(&fds); FD_SET(fd, &fds); retcode = select(fd + 1, &fds, NULL, NULL, timeout < 0 ? NULL : &t); if (retcode <= 0) return 0; return read(fd, events, n * sizeof(apm_event_t)) / sizeof(apm_event_t); } /* * Request suspend or acknowledge suspend request */ int apm_suspend(int fd) { sync(); return ioctl(fd, APM_IOC_SUSPEND, NULL) < 0 ? -errno : 0; } /* * Request standby or acknowledge standby request */ int apm_standby(int fd) { sync(); return ioctl(fd, APM_IOC_STANDBY, NULL); } /* * apm_error_name -- return string describing APM error */ typedef struct lookup_t { int key; char * msg; } lookup_t; static const lookup_t error_table[] = { /* N/A { APM_SUCCESS, "Operation succeeded" }, */ { APM_DISABLED, "Power management disabled" }, { APM_CONNECTED, "Real mode interface already connected" }, { APM_NOT_CONNECTED, "Interface not connected" }, { APM_16_CONNECTED, "16 bit interface already connected" }, /* N/A { APM_16_UNSUPPORTED, "16 bit interface not supported" }, */ { APM_32_CONNECTED, "32 bit interface already connected" }, { APM_32_UNSUPPORTED, "32 bit interface not supported" }, { APM_BAD_DEVICE, "Unrecognized device ID" }, { APM_BAD_PARAM, "Parameter out of range" }, { APM_NOT_ENGAGED, "Interface not engaged" }, #ifdef APM_BAD_FUNCTION { APM_BAD_FUNCTION, "Function not supported" }, #endif #ifdef APM_RESUME_DISABLED { APM_RESUME_DISABLED, "Resume timer disabled" }, #endif { APM_BAD_STATE, "Unable to enter requested state" }, /* N/A { APM_NO_EVENTS, "No events pending" }, */ { APM_NOT_PRESENT, "No APM present" } }; #define ERROR_COUNT (sizeof(error_table)/sizeof(lookup_t)) const char *apm_error_name( unsigned int err ) { int i; for(i=0; i Thomas Hood Peter Englmaier (apmsleep) apmd-3.2.2.orig/on_ac_power0000755001167100001440000000275107775742516015604 0ustar cphusers00000000000000#!/bin/sh # # Returns 0 (true) if on AC power # 1 (false) if not on AC power # 255 (false) if can't tell # # Example shell script: # if on_ac_power; then # echo We're on AC power # else # echo Can't say we're on AC power # fi set -e # ACPI # # This algorithm is complicated by the possibility of multiple AC # adapters. We scan the ac_adapter directory looking for adapters # that have known states. If any adapter is on-line, we return 0. If # no adapters are on-line but one or more are off-line, we return 1. # if acpi_available && [ -d /proc/acpi/ac_adapter ]; then OFF_LINE_P=no for FN in /proc/acpi/ac_adapter/*; do if [ -d "${FN}" ]; then if [ -r "${FN}/state" ]; then grep --quiet on-line "${FN}/state" && exit 0 grep --quiet off-line "${FN}/state" && OFF_LINE_P=yes elif [ -r "${FN}/status" ]; then grep --quiet on-line "${FN}/status" && exit 0 grep --quiet off-line "${FN}/status" && OFF_LINE_P=yes fi fi done [ "${OFF_LINE_P}" = "yes" ] && exit 1 fi # APM if apm_available && [ -r /proc/apm ]; then exec awk #include #include #include #include #include #include #include #include #include "apm.h" typedef struct _instance_variables { Pixel highColor; Pixel lowColor; Pixel criticalColor; Pixel chargingColor; Pixel foreground; int highValue; int lowValue; String geometry; int delay; Boolean displayPercent; Boolean displayPercentAuto; } instance_variable_rec; static XtAppContext app_context; static Widget scrollbar; static Widget topLevel; static Widget command; static XtIntervalId timerId; static instance_variable_rec iv; static int debug; /* Bill Mair, 26.03.1999 ----> */ #define IBM_THINKPAD 0 /* ThinkPads use the battery_flags to indicate charging */ #define SHOW_AC_BAT_STATUS 1 #define DEBUG_UPDATE 0 #define DISPLAYPERCENT_AUTO 1 /* We add support to switch between percent and text automatically. */ #if IBM_THINKPAD == 1 #define TP_CHARGE_FLAG 0x08 /* This works on the TP770X but may be different on other TPs */ #endif #if SHOW_AC_BAT_STATUS == 1 #define CHAR_COUNT 5 #else #define CHAR_COUNT 4 #endif /* <---- Bill Mair, 26.03.1999 */ static void update(XtPointer client_data, XtIntervalId * id) { apm_info i; char buf[128]; static int pixel = -1; static int lpixel = -1; static int bpixel = -1; static int lastPercentage = -1; static int lastMinutes = -1; static int lastDisplay = -1; static int count = 0; #if SHOW_AC_BAT_STATUS == 1 static int lastACStatus = -1; #endif apm_read(&i); #if DEBUG_UPDATE == 1 /* BM: Added this to display all of the APM flags */ if (debug) { printf("\nxapm update\n"); printf(" apm_flags: %d\n", i.apm_flags); printf(" ac_line_status: %d\n", i.ac_line_status); printf(" battery_status: %d\n", i.battery_status); printf(" battery_flags: %d\n", i.battery_flags); printf(" battery_percentage: %d\n", i.battery_percentage); printf(" battery_time: %d\n", i.battery_time); printf(" using_minutes: %d\n", i.using_minutes); } #endif #if DISPLAYPERCENT_AUTO == 1 if(iv.displayPercentAuto){ /* We are in auto-change mode, where we print percentages if on ac-power, but time if we are on battery power. */ if(i.ac_line_status != lastACStatus){ /* we changed the powerness */ lastDisplay = -1; iv.displayPercent = i.ac_line_status; } } #endif if (iv.displayPercent) { if (lastDisplay != iv.displayPercent || i.battery_percentage != lastPercentage #if SHOW_AC_BAT_STATUS == 1 || i.ac_line_status != lastACStatus #endif ) { /* lastPercentage updated at end */ #if SHOW_AC_BAT_STATUS == 1 sprintf(buf, "%s%d%%", i.ac_line_status ? "L" : "B", i.battery_percentage); #else sprintf(buf, "%d%%", i.battery_percentage); #endif XtVaSetValues(command, XtNlabel, buf, NULL); } } else { int minutes = i.using_minutes ? i.battery_time : i.battery_time / 60; if (lastDisplay != iv.displayPercent || lastMinutes != minutes #if SHOW_AC_BAT_STATUS == 1 || i.ac_line_status != lastACStatus #endif ) { lastMinutes = minutes; #if SHOW_AC_BAT_STATUS == 1 sprintf(buf, "%s%s", i.ac_line_status ? "L" : "B", apm_time_nosec(minutes * 60)); #else sprintf(buf, "%s", apm_time_nosec(minutes * 60)); #endif XtVaSetValues(command, XtNlabel, buf, NULL); } } lastDisplay = iv.displayPercent; #if SHOW_AC_BAT_STATUS == 1 lastACStatus = i.ac_line_status; #endif if (i.battery_percentage <= iv.lowValue) { if (pixel != iv.criticalColor) XtVaSetValues(scrollbar, XtNforeground, pixel = iv.criticalColor, NULL); if (bpixel != iv.criticalColor) XtVaSetValues(scrollbar, XtNborderColor, bpixel = iv.criticalColor, NULL); } else if (i.battery_percentage <= iv.highValue) { if (pixel != iv.lowColor) XtVaSetValues(scrollbar, XtNforeground, pixel = iv.lowColor, NULL); if (bpixel != iv.foreground) XtVaSetValues(scrollbar, XtNborderColor, bpixel = iv.foreground, NULL); } else { if (pixel != iv.highColor) XtVaSetValues(scrollbar, XtNforeground, pixel = iv.highColor, NULL); if (i.battery_percentage == 100) { if (bpixel != iv.highColor) XtVaSetValues(scrollbar, XtNborderColor, bpixel = iv.highColor, NULL); } else { if (bpixel != iv.foreground) XtVaSetValues(scrollbar, XtNborderColor, bpixel = iv.foreground, NULL); } } if (debug) printf("scrollbar color = %d\n", pixel); if (i.battery_status == 3 #if IBM_THINKPAD == 1 || (i.battery_flags & TP_CHARGE_FLAG) #endif ) { if (lpixel != iv.chargingColor) XtVaSetValues(command, XtNforeground, lpixel = iv.chargingColor, NULL); } else { if (i.battery_percentage < iv.lowValue && count++ % 2) { if (lpixel != iv.criticalColor) XtVaSetValues(command, XtNforeground, lpixel = iv.criticalColor, NULL); } else { if (lpixel != iv.foreground) XtVaSetValues(command, XtNforeground, lpixel = iv.foreground, NULL); } } if (debug) printf("command color = %d, status = %d\n", lpixel, i.battery_status); if (i.battery_percentage != lastPercentage) XawScrollbarSetThumb(scrollbar, 0.0, i.battery_percentage < 0 ? 0.0 : i.battery_percentage / 100.0); lastPercentage = i.battery_percentage; timerId = XtAppAddTimeOut(app_context, 1000 * iv.delay + 500, update, app_context); } static void press(Widget w, XtPointer client_data, XtPointer call_data) { iv.displayPercent = !iv.displayPercent; XtRemoveTimeOut(timerId); timerId = XtAppAddTimeOut(app_context, 0, update, app_context); if (debug) printf("displayPercent = %d\n", iv.displayPercent); } static XrmOptionDescRec options[] = { {"-highcolor", "*highColor", XrmoptionSepArg, NULL}, {"-lowcolor", "*lowColor", XrmoptionSepArg, NULL}, {"-criticalcolor", "*criticalColor", XrmoptionSepArg, NULL}, {"-chargingcolor", "*chargingColor", XrmoptionSepArg, NULL}, {"-highvalue", "*highValue", XrmoptionSepArg, NULL}, {"-lowvalue", "*lowValue", XrmoptionSepArg, NULL}, {"-delay", "*delay", XrmoptionSepArg, NULL}, {"-percent", "*percent", XrmoptionNoArg, (XtPointer) "true"}, #if DISPLAYPERCENT_AUTO == 1 {"-percentauto", "*percentauto", XrmoptionNoArg, (XtPointer) "true"}, #endif }; #define offset(field) XtOffsetOf( instance_variable_rec, field ) static XtResource resources[] = { {"highColor", XtCForeground, XtRPixel, sizeof(Pixel), offset(highColor), XtRString, "green"}, {"lowColor", XtCForeground, XtRPixel, sizeof(Pixel), offset(lowColor), XtRString, "yellow"}, {"criticalColor", XtCForeground, XtRPixel, sizeof(Pixel), offset(criticalColor), XtRString, "red"}, {"chargingColor", XtCForeground, XtRPixel, sizeof(Pixel), offset(chargingColor), XtRString, "blue"}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(foreground), XtRString, XtDefaultForeground}, {"highValue", XtCValue, XtRInt, sizeof(int), offset(highValue), XtRImmediate, (XtPointer) 50}, {"lowValue", XtCValue, XtRInt, sizeof(int), offset(lowValue), XtRImmediate, (XtPointer) 10}, {"geometry", XtCString, XtRString, sizeof(String), offset(geometry), XtRString, (XtPointer) "10x100"}, {"delay", XtCValue, XtRInt, sizeof(int), offset(delay), XtRImmediate, (XtPointer) 1}, {"percent", XtCValue, XtRBoolean, sizeof(Boolean), offset(displayPercent), XtRImmediate, (XtPointer) FALSE}, #if DISPLAYPERCENT_AUTO == 1 {"percentauto", XtCValue, XtRBoolean, sizeof(Boolean), offset(displayPercentAuto), XtRImmediate, (XtPointer) FALSE}, #endif }; static void quit(Widget w, XtPointer client_data, XtPointer call_data) { exit (0); } static XtActionsRec main_actions[] = { {"Quit", (XtActionProc) quit}, }; static String main_translations = "WM_PROTOCOLS:Quit()\n"; int main(int argc, char **argv) { Cursor cursor; int c; Widget form; XFontStruct *fs; int fontWidth, fontHeight; int x = 0, y = 0, height = 10, width = 100; Atom wm_protocols[1]; switch (apm_exists()) { case 1: fprintf(stderr, "No APM support in kernel\n"); exit(1); case 2: fprintf(stderr, "Old APM support in kernel\n"); exit(2); } topLevel = XtVaAppInitialize(&app_context, "XApm", options, XtNumber(options), &argc, argv, NULL, NULL); XtGetApplicationResources(topLevel, &iv, resources, XtNumber(resources), NULL, 0); if (iv.delay < 1) iv.delay = 1; XParseGeometry(iv.geometry, &x, &y, &width, &height); while ((c = getopt(argc, argv, "DV")) != -1) switch (c) { case 'D': ++debug; break; case 'V': fprintf(stderr, "apmd version %s\n", VERSION); exit(0); break; } if (debug) { printf("highColor = %ld\n", iv.highColor); printf("lowColor = %ld\n", iv.lowColor); printf("criticalColor = %ld\n", iv.criticalColor); printf("chargingColor = %ld\n", iv.chargingColor); printf("foreground = %ld\n", iv.foreground); printf("highValue = %d\n", iv.highValue); printf("lowValue = %d\n", iv.lowValue); printf("geometry = %s\n", iv.geometry); } cursor = XCreateFontCursor(XtDisplay(topLevel), XC_top_left_arrow); form = XtVaCreateManagedWidget("form", formWidgetClass, topLevel, XtNorientation, XtorientHorizontal, XtNborderWidth, 0, XtNdefaultDistance, 2, NULL); command = XtVaCreateManagedWidget("command", commandWidgetClass, form, XtNleft, XtChainLeft, XtNhighlightThickness, 0, XtNinternalHeight, 0, XtNinternalWidth, 0, XtNborderWidth, 0, XtNlabel, "", XtNresize, FALSE, NULL); XtVaGetValues(command, XtNfont, &fs, NULL); fontWidth = fs->max_bounds.width; fontHeight = fs->max_bounds.ascent + fs->max_bounds.descent; XtVaSetValues(command, XtNwidth, fontWidth * CHAR_COUNT, NULL); if (debug) { int tmp = (width > fontWidth * CHAR_COUNT - 6) ? width - fontWidth * CHAR_COUNT - 6 : fontWidth * CHAR_COUNT; printf("width = %d, using %d + %d = %d\n", width, fontWidth * CHAR_COUNT, tmp, fontWidth * CHAR_COUNT + tmp); } scrollbar = XtVaCreateManagedWidget("scrollbar", scrollbarWidgetClass, form, XtNhorizDistance, 3, XtNfromHoriz, command, XtNorientation, XtorientHorizontal, XtNscrollHCursor, cursor, XtNthickness, fontHeight, XtNlength, (width > fontWidth * CHAR_COUNT - 6) ? width - fontWidth * CHAR_COUNT - 6 : fontWidth * CHAR_COUNT, NULL); XawScrollbarSetThumb(scrollbar, 0.0, 0.0); XtVaSetValues(scrollbar, XtNtranslations, XtParseTranslationTable(""), NULL); XtAddCallback(command, XtNcallback, press, NULL); XtRealizeWidget(topLevel); /* Add code to handle WM_DELETE_WINDOW cleanly. */ XtAppAddActions(app_context, main_actions, XtNumber(main_actions)); XtOverrideTranslations(topLevel, XtParseTranslationTable(main_translations)); wm_protocols[0] = XInternAtom(XtDisplay(topLevel), "WM_DELETE_WINDOW", False); XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel), wm_protocols, 1); timerId = XtAppAddTimeOut(app_context, 0, update, app_context); XtAppMainLoop(app_context); return 0; } apmd-3.2.2.orig/apmsleep.fr.10000644001167100001440000000726107775757507015670 0ustar cphusers00000000000000.\" apmsleep.1 .\" .TH APMSLEEP 1 "janvier 2004" "" "" .SH NOM apmsleep \- met en mode suspendu ou veille et rallume ultérieurement .SH SYNOPSIS .B apmsleep [\-sSnwhVd] [\-\-suspend] [\-\-standby] [\-\-noapm] [\-\-wait] [\-\-help] [\-\-version] [\-\-debug] [+]hh:mm .SH DESCRIPTION Certains ordinateurs, particulièrement des portables, peuvent être rallumés depuis un mode suspendu de basse consommation en utilisant la puce Horloge-temps-réèl (RTC). .B Apmsleep peut être utilisé pour régler l'heure d'alarme dans la RTC et pour passer en mode suspendu ou veille. Une interruption provenant de la RTC provoque le réveil de l'ordinateur. Le programme détecte cet évènement, en attendant un saut dans le temps du noyau et se termine avec succès. Si aucun saut n'intervient sous une minute, ou que quelque chose se passe mal, la valeur de retour sera différente de zéro. .PP L'heure de réveil peut être spécifiée en deux formats\~: .PP .B +hh:mm spécifie un décalage par rapport à l'heure actuelle. L'ordinateur se réveillera dans exactement hh heures et mm minutes plus quelques secondes pour se réveiller. .PP .B hh:mm spécifie une heure .B locale absolue au format 24 heures. L'heure stockée dans le RTC n'est pas importante. Vous pouvez changer la zone de temps utilisée, courament avec la variable d'environnement TZ. Les heures d'été/hiver ne sont pas prises en compte dans cette version, mais le seront peut-être dans une version future. .TP .B \-V, \-\-version Affiche la version du programme .B apmsleep et termine immédiatement. .TP .B \-s, \-\-suspend Met la machine en mode suspendu si possible (par défaut). Sur mon portable, le mode suspendu éteint tout sauf la mémoire. .TP .B \-S, \-\-standby Met la machine en mode veille si possible. Sur mon portable, le mode veille éteint l'écran, le disque dur et le processeur. .TP .B \-w, \-\-wait Attend indéfiniment le saut de temps. .TP .B \-n, \-\-noapm N'appelle pas /usr/bin/apm pour suspendre l'ordinateur, règle seulement l'alarme de l'horloge et attend le saut de temps. .TP .B \-d, \-\-debug Affiche quelques informations sur ce qui est en train de se passer. .SH CONFIGURATION SYSTÈME REQUISE .TP .B Noyau Le périphérique spécial /dev/rtc doit exister et le noyau doit être compilé avec le support APM et RTC. .TP .B BIOS L'ordinateur doit avoir l'option 'suspendre vers la mémoire' activée dans le BIOS\~; 'suspendre vers le disque' ne va pas fonctionner, car l'ordinateur est complètement éteint. vous n'avez pas besoin d'activer la minuterie de l'ALARME, elle sera activée par apmsleep. Sur certaines cartes mères, vous pouvez déterminer quelles interruptions peuvent être utilisées pour réveiller à partir du mode suspendu. Si vous en possèdez une de ce type, vous voudrez peut-être vous assurer que le clavier (IRQ 1) et la RTC (IRQ 8) sont parmi ces interruptions. .TP .B Privilèges Ce programme doit être exécuté comme administrateur (root) ou avoir l'attribut SUID activé (voir chmod(1)). .PP .SH BOGUES Apmsleep ne peut pas détecter quel evènement a terminé la mise en veille. Les evènements possibles sont\~: activité du clavier ou de la souris, appel sur le modem, alarme de la RTC, n'importe quelle autre interruption. Ce programme n'a été testé que sur un portable Winbook XL (Pentium). Il peut ne pas fonctionner sur votre matériel. .SH AUTEUR Écrit par Peter Englmaier (ppe@pa.uky.edu) et pouvant être distribué suivant les termes de la Licence Publique Générale GNU. Le code est basé sur le programme exemple de test de la RTC de Paul Gortmacher. Il n'y a ABSOLUMENT AUCUNE GARANTIE pour ce programme. Le mainteneur actuel est Peter Englmaier. .SH TRADUCTION Cette page d'aide a été traduite par José JORGE .SH "VOIR AUSSI" .BR xapm (1), .BR apmd (8). apmd-3.2.2.orig/LSM0000644001167100001440000000104707775746202013732 0ustar cphusers00000000000000Begin3 Title: apmd: APM daemon Version: 3.2.1 Entered-date: 05JUN99 Description: 1) Daemon for monitoring battery status via APM 2) Applications for interfacing with the APM subsystem Includes: apmd, apm and xapm Keywords: Power Management APM laptop battery suspend Author: Rik Faith Maintained-by: Avery Pennarun Primary-site: http://www.worldvisions.ca/~apenwarr/apmd/ Platforms: Linux 1.3.46 or higher Copying-policy: GPL End apmd-3.2.2.orig/on_ac_power.10000644001167100001440000000265107775743261015735 0ustar cphusers00000000000000.\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH ON_AC_POWER 1 "January 2004" "" "" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME on_ac_power \- test whether the computer is running on line power .SH SYNOPSIS .B on_ac_power .SH DESCRIPTION The command succeeds (status 0) if the system is using line power and fails (status other than 0) otherwise. It is designed to be easy to use in shell scripts. .SH OPTIONS None. .SH "EXIT STATUS" .br .nf \fB0\fR (true) System is on line power \fB1\fR (false) System is not on line power \fB255\fR (false) Power status could not be determined .SH FILES .br .nf .ta \w'/proc/apm 'u \fI/proc/apm\fR APM status information file .nf .ta \w'/proc/acpi/ 'u \fI/proc/acpi\fR ACPI status information directory .SH AUTHOR This manual page was written by Steve Dodd and was updated by Thomas Hood. apmd-3.2.2.orig/apmlib.COPYING0000644001167100001440000006364007706777321015661 0ustar cphusers00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! apmd-3.2.2.orig/apmsleep.README0000644001167100001440000000060107035363121016014 0ustar cphusers00000000000000Please report bugs to: ppe@mpe.mpg.de The following information would be helpful: 1) Program output with debugging turned on including the command line used to run apmsleep. 2) Make & model of computer. 3) Linux version used. 4) /proc/apm 5) /proc/rtc 6) /proc/interrupts Please write, if you find that my program works on non-intel platforms as well. Peter Englmaier.