home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / rescue / usr / lib / hal / scripts / linux / hal-system-power-standby-linux < prev    next >
Text File  |  2006-11-29  |  1KB  |  59 lines

  1. #!/bin/sh
  2.  
  3. POWERSAVED_STANDBY="dbus-send --system --dest=com.novell.powersave \
  4.                     --print-reply /com/novell/powersave \
  5.                     com.novell.powersave.action.Standby"
  6.  
  7. unsupported() {
  8.     echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
  9.     echo No Standby method found >&2
  10.     exit 1
  11. }
  12.  
  13. #SuSE and ALTLinux only support powersave
  14. if [ -f "/etc/altlinux-release" ] || [ -f "/etc/SuSE-release" ] ; then
  15.     if [ -x /usr/bin/powersave ] ; then
  16.             $POWERSAVED_STANDBY
  17.         RET=$?
  18.     else
  19.         # TODO: add support
  20.         unsupported
  21.     fi
  22.  
  23. #FreeBSD uses zzz to suspend for both ACPI and APM
  24. elif [ "x`uname -s`" = "xFreeBSD" ] ; then
  25.     if [ -x /usr/sbin/acpiconf ] ; then
  26.         /usr/sbin/acpiconf -s 1
  27.         RET=$?
  28.     else
  29.         unsupported
  30.     fi
  31.  
  32. #Other distros just need to have *any* tools installed
  33. else
  34.     if [ -x "/usr/bin/powersave" ] ; then
  35.         $POWERSAVED_STANDBY
  36.         RET=$?
  37.     elif [ -w "/sys/power/state" ] ; then
  38.         # Use the raw kernel sysfs interface
  39.         echo "standby" > /sys/power/state
  40.         RET=$?
  41.     else
  42.         # TODO: add other scripts support
  43.         unsupported
  44.         fi
  45.     fi
  46.  
  47. #Refresh devices as a resume can do funny things
  48. for type in button battery ac_adapter
  49. do
  50.     devices=`hal-find-by-capability --capability $type`
  51.     for device in $devices
  52.     do
  53.         dbus-send --system --print-reply --dest=org.freedesktop.Hal \
  54.               $device org.freedesktop.Hal.Device.Rescan
  55.     done
  56. done
  57.  
  58. exit $RET
  59.