home *** CD-ROM | disk | FTP | other *** search
/ tusportal.tus.k12.pa.us / tusportal.tus.k12.pa.us.tar / tusportal.tus.k12.pa.us / Wyse / latest-image.raw / 0.img / usr / sbin / pm-powersave < prev    next >
Text File  |  2009-02-20  |  2KB  |  66 lines

  1. #!/bin/bash
  2. # vim:noexpandtab
  3. # Simple powersave script
  4. #
  5. # Copyright 2006 Red Hat, Inc.
  6. #
  7. # Based on work from:
  8. #    Bill Nottingham <notting@redhat.com>
  9. #    Peter Jones <pjones@redhat.com>
  10. #    David Zeuthen <davidz@redhat.com>
  11. #    Richard Hughes <richard@hughsie.com>
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of version 2 of the GNU General Public License as
  15. # published by the Free Software Foundation.
  16. #
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with this program; if not, write to the Free Software
  24. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  25. #
  26.  
  27. # set nullglob to make glob results empty in case the pattern does not
  28. # match any files
  29. shopt -s nullglob
  30.  
  31. PM_POWERSAVE_LOGFILE="/var/log/pm-powersave.log"
  32. echo -n > $PM_POWERSAVE_LOGFILE
  33.  
  34. find_powerd_files()
  35. {
  36.     flist="/etc/pm/power.d/*[^~] /usr/lib/pm-utils/power.d/*[^~]"
  37.     bases=$(for file in $flist ; do echo $(basename $file) ; done | sort -n | uniq)
  38.     for base in $bases ; do
  39.         if [ -x "/etc/pm/power.d/$base" ]; then
  40.             echo /etc/pm/power.d/$base
  41.         elif [ -x "/usr/lib/pm-utils/power.d/$base" ]; then
  42.             echo /usr/lib/pm-utils/power.d/$base
  43.         fi
  44.     done
  45. }
  46.  
  47. runpowerhooks()
  48. {
  49.     files=$(find_powerd_files)
  50.     for file in $files ; do
  51.         $file $1 >> $PM_POWERSAVE_LOGFILE 2>&1
  52.     done
  53. }
  54.  
  55. if [ "$1" == "true" ] ; then
  56.     runpowerhooks true
  57. elif [ "$1" == "false" ] ; then
  58.     runpowerhooks false
  59. else
  60.     echo "Argument needs to be true or false" >&2
  61.     exit 1
  62. fi
  63.  
  64. cat $PM_POWERSAVE_LOGFILE
  65.  
  66.