diff --git a/apmd.conf b/apmd.conf index 5dd0ff6..9220ad4 100644 --- a/apmd.conf +++ b/apmd.conf @@ -102,3 +102,8 @@ LOWPOWER_SERVICES="atd crond" # If your BIOS is broken, uncomment the line below, and possibly change the # value (e.g. "5s = Wait 5 seconds before allowing to suspend"). #DELAYSUSPEND="3s" + +# If your machine supports using cpufreq to change its speed, you can enable +# this to support changing the cpu frequence to performance or powersave +# based on whether or not you are currently on AC power or battery power +#CPUFREQ="no" diff --git a/apmd.spec b/apmd.spec index c5708c8..71d36d5 100644 --- a/apmd.spec +++ b/apmd.spec @@ -1,7 +1,7 @@ Summary: Advanced Power Management (APM) BIOS utilities for laptops. Name: apmd Version: 3.0.2 -Release: 12 +Release: 18 Source: http://www.worldvisions.ca/~apenwarr/apmd/%{name}-%{version}.tar.bz2 Source1: apmd.init Source2: apmscript @@ -47,6 +47,7 @@ install -m 755 %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/apmd install -m 755 %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/apm-scripts/ install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/apmd rm -f $RPM_BUILD_ROOT%{_bindir}/xapm +rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/apmd_proxy %clean rm -rf $RPM_BUILD_ROOT @@ -82,6 +83,27 @@ fi %config /etc/sysconfig/apm-scripts/* %changelog +* Mon Feb 24 2003 Elliot Lee +- debuginfo rebuild + +* Thu Feb 20 2003 Bill Nottingham 1:3.0.2-17 +- don't remove network modules (#83996) + +* Tue Feb 18 2003 Bill Nottingham 1:3.0.2-16 +- pass arguments to apmcontinue-pre (#83398, ) +- fix NETDEVICES line (#81153) + +* Wed Jan 22 2003 Tim Powers +- rebuilt + +* Thu Jan 2 2003 Jeremy Katz 1:3.0.2-14 +- add CPUFREQ= to /etc/sysconfig/apmd +- if CPUFREQ="yes" and /proc/cpufreq exists, use cpufreq to change between + performance and power-save when switching between ac and battery + +* Fri Nov 22 2002 Tim Powers +- remove unpackaged files from the buildroot + * Fri Jun 21 2002 Tim Powers - automated rebuild diff --git a/apmscript b/apmscript index 8390e3d..946c715 100755 --- a/apmscript +++ b/apmscript @@ -1,8 +1,9 @@ #!/bin/bash # # Red Hat APM suspend/resume script -# version 1.5.3 +# $Id: apmscript,v 1.9 2003/02/21 01:05:59 notting Exp $ # (c) 1999-2002 Bernhard Rosenkraenzer +# (c) 2003 Red Hat, Inc. # # DO NOT EDIT THIS SCRIPT, CREATE AND EDIT apmcontinue IN THIS DIRECTORY; you # can put your stuff into apmcontinue for every link you create to apmscript; @@ -14,7 +15,7 @@ # as which it was called as $1; for debugging see the logfiles # # If you think something in this script needs to be changed anyway, please -# report it to http://bugzilla.redhat.com/bugzilla/ or bero@redhat.com +# report it to http://bugzilla.redhat.com/bugzilla/ # # This script can be controlled by editing /etc/sysconfig/apmd. @@ -27,16 +28,21 @@ LANG="C" # We're parsing the output of some scripts, better not i18n it [ -z "$UTC" ] && UTC="no" [ -z "$CHANGEVT" ] && CHANGEVT="0" [ -z "$CLOCK_SYNC" ] && CLOCK_SYNC="no" +[ -z "$CPUFREQ" ] && CPUFREQ="no" if [ -n "`/sbin/pidof X`" ]; then X_RUNNING=1 fi +if [ ! -f /proc/cpufreq ]; then + CPUFREQ="no" +fi + CLOCK="--localtime" [ "$UTC" = "yes" -o "$UTC" = "true" -o "$UTC" = 1 ] && CLOCK="--utc" case "$PROG" in suspend|standby) - [ -f /etc/sysconfig/apm-scripts/apmcontinue-pre ] && /etc/sysconfig/apm-scripts/apmcontinue-pre + [ -f /etc/sysconfig/apm-scripts/apmcontinue-pre ] && /etc/sysconfig/apm-scripts/apmcontinue-pre "$@" # Stop services that might break echo "#!/bin/sh" >/var/run/apm-resume-post if [ -n "$RESTORESERVICES" ]; then @@ -52,11 +58,11 @@ case "$PROG" in # Find all programs using sound and kill them... rm -rf /var/run/apm-soundprogs if [ -c /dev/sndstat ]; then - for n in `cat /dev/sndstat 2>/dev/null|grep Open\ by|awk {'print $3'}|uniq`; do + for n in `cat /dev/sndstat 2>/dev/null| LC_ALL=C grep Open\ by|awk {'print $3'}|uniq`; do SOUNDPROG=`echo $n|awk -F / {'print $2'}` SOUNDPID=`echo $n|awk -F / {'print $1'}` SOUNDUSER=`ls -ld /proc/$SOUNDPID |awk {'print $3'}` - SOUNDDISPLAY=`perl -e 's/\000/\n/g;' -p /proc/$SOUNDPID/environ|grep ^DISPLAY=|cut -d= -f2-` + SOUNDDISPLAY=`perl -e 's/\000/\n/g;' -p /proc/$SOUNDPID/environ| LC_ALL=C grep ^DISPLAY=|cut -d= -f2-` # Make sure nobody is playing foul tricks on us SOUNDPROG=`echo $SOUNDPROG |sed -e "s/|.*//` @@ -67,11 +73,11 @@ case "$PROG" in logger "apmscript: Program $SOUNDPROG ($SOUNDPID) of user $SOUNDUSER on display $SOUNDDISPLAY terminated." done fi - for n in `lsof |grep /dev|grep ' 14,'|sed -e 's/ \+/|/g'|cut '-d|' -f1-3`; do + for n in `lsof | LC_ALL=C grep /dev| LC_ALL=C grep ' 14,'|sed -e 's/ \+/|/g'|cut '-d|' -f1-3`; do SOUNDPROG=`echo $n |cut '-d|' -f1` SOUNDPID=`echo $n |cut '-d|' -f2` SOUNDUSER=`echo $n |cut '-d|' -f3` - SOUNDDISPLAY=`perl -e 's/\000/\n/g;' -p /proc/$SOUNDPID/environ|grep ^DISPLAY=|cut -d= -f2-` + SOUNDDISPLAY=`perl -e 's/\000/\n/g;' -p /proc/$SOUNDPID/environ| LC_ALL=C grep ^DISPLAY=|cut -d= -f2-` # Make sure nobody is playing foul tricks on us SOUNDPROG=`echo $SOUNDPROG |sed -e "s/|.*//` @@ -106,7 +112,7 @@ case "$PROG" in fi if [ "$NET_RESTART" = "yes" ] ; then # Make an educated guess at what interfaces need restarting - NETDEVICES=`service network status |grep -A1 "Currently active devices" |tail -n1` + NETDEVICES=`LC_ALL=C /etc/init.d/network status | LC_ALL=C grep -A1 "Currently active devices" |tail -n1` if [ "$?" = "0" ]; then for i in $NETDEVICES; do echo "/sbin/ifup $i" >>/var/run/apm-resume-post @@ -114,10 +120,6 @@ case "$PROG" in echo "touch /var/lock/subsys/network" >>/var/run/apm-resume-post fi /sbin/service network stop - interfaces=`cat /etc/modules.conf|grep eth[0-9]|sed 's/alias eth[0-9] //g'` - for i in $interfaces; do - /sbin/modprobe -r $i - done fi [ -n "$NEED_NETFS_START" ] && echo "/sbin/service netfs start" >>/var/run/apm-resume-post [ "$PCMCIARESTART" = "yes" ] && { @@ -125,7 +127,7 @@ case "$PROG" in /sbin/cardctl eject } if [ "$PCMCIAWAIT" = "yes" ]; then - until [ `grep "Socket .: empty" /var/lib/pcmcia/stab|wc -l` = `grep "Socket" /var/lib/pcmcia/stab|wc -l` ]; do + until [ `LC_ALL=C grep "Socket .: empty" /var/lib/pcmcia/stab|wc -l` = `LC_ALL=C grep "Socket" /var/lib/pcmcia/stab|wc -l` ]; do logger "Waiting for pcmcia-device to be removed..." sleep 10 done @@ -143,7 +145,7 @@ case "$PROG" in [ "x$LOCK_X" = "xyes" -o "x$LOCK_X" = "x1" ] && { # Lock X, based on patch from Hannu Martikka # - w |tail +3 |awk '{print $1, $3}'|grep -v '-'|grep : | \ + w |tail +3 |awk '{print $1, $3}'| LC_ALL=C grep -v '-'| LC_ALL=C grep : | \ sort -u | \ while read line; do Usern=`echo $line |awk '{print $1}'` @@ -173,7 +175,7 @@ case "$PROG" in [ -x /usr/local/sbin/soundoff ] && /usr/local/sbin/soundoff rm -rf /var/run/apm-soundmodules for m in $SOUNDMODULES; do - if lsmod |grep -q "^$m " &>/dev/null; then + if lsmod | LC_ALL=C grep -q "^$m " &>/dev/null; then rmmod $m echo $m >>/var/run/apm-soundmodules fi @@ -208,7 +210,7 @@ case "$PROG" in fi - [ -f /etc/sysconfig/apm-scripts/apmcontinue-pre ] && /etc/sysconfig/apm-scripts/apmcontinue-pre + [ -f /etc/sysconfig/apm-scripts/apmcontinue-pre ] && /etc/sysconfig/apm-scripts/apmcontinue-pre "$@" # as some displays don't like being waked up from power-off # state directly into graphics mode, we can switch to console @@ -279,12 +281,20 @@ case "$PROG" in # If anacron is installed and we're on AC power or we want # to run it even in battery mode. if [ -x /usr/sbin/anacron ]; then - if apm |grep -q on-line &>/dev/null; then + if apm | LC_ALL=C grep -q on-line &>/dev/null; then /usr/sbin/anacron elif test "x$ANACRON_ON_BATTERY" = "xyes"; then /usr/sbin/anacron fi fi + + if test "x$CPUFREQ" = "xyes"; then + if apm | LC_ALL=C grep -q on-line &>/dev/null; then + echo -n "0%100%100%performance" > /proc/cpufreq + else + echo -n "0%0%0%powersave" > /proc/cpufreq + fi + fi if test "x$HDPARM_AT_RESUME" != "x"; then for i in /proc/ide/hd*; do @@ -298,12 +308,22 @@ case "$PROG" in rm -f "$LOCKFILE" ;; change) - [ -f /etc/sysconfig/apm-scripts/apmcontinue-pre ] && /etc/sysconfig/apm-scripts/apmcontinue-pre + [ -f /etc/sysconfig/apm-scripts/apmcontinue-pre ] && /etc/sysconfig/apm-scripts/apmcontinue-pre "$@" case $2 in power) + # change from performance to powersave or vice versa based + # on whether we're running on batter or ac power + if test "x$CPUFREQ" = "xyes"; then + if apm | LC_ALL=C grep -q on-line &>/dev/null; then + echo -n "0%100%100%performance" > /proc/cpufreq + else + echo -n "0%0%0%powersave" > /proc/cpufreq + fi + fi + # Change from battery power to AC power or vice versa. if [ -n "$POWER_SERVICES" ]; then - if apm |grep -q on-line &>/dev/null; then + if apm | LC_ALL=C grep -q on-line &>/dev/null; then what="start" if [ -n "$LOWPOWER_SERVICES" -a -e /var/run/apmd/LOW_POWER ]; then rm -f /var/run/apmd/LOW_POWER