home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / hal / scripts / linux / hal-system-power-suspend-linux < prev    next >
Encoding:
Text File  |  2009-07-05  |  2.1 KB  |  56 lines

  1. #!/bin/sh
  2.  
  3. alarm_not_supported() {
  4.     echo org.freedesktop.Hal.Device.SystemPowerManagement.AlarmNotSupported >&2
  5.     echo Waking the system up is not supported >&2
  6.     exit 1
  7. }
  8.  
  9. unsupported() {
  10.     echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
  11.     echo No suspend method found >&2
  12.     exit 1
  13. }
  14.  
  15. read seconds_to_sleep
  16.  
  17. # Make a suitable command line argument so that the tools can do the correct
  18. # quirks for video resume.
  19. # Passing the quirks to the tool allows the tool to not depend on HAL for data.
  20. QUIRKS=""
  21. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_S3_BIOS" = "true" ] && QUIRKS="$QUIRKS --quirk-s3-bios"
  22. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_S3_MODE" = "true" ] && QUIRKS="$QUIRKS --quirk-s3-mode"
  23. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_SUSPEND" = "true" ] && QUIRKS="$QUIRKS --quirk-dpms-suspend"
  24. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_ON" = "true" ] && QUIRKS="$QUIRKS --quirk-dpms-on"
  25. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBESTATE_RESTORE" = "true" ] && QUIRKS="$QUIRKS --quirk-vbestate-restore"
  26. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBEMODE_RESTORE" = "true" ] && QUIRKS="$QUIRKS --quirk-vbemode-restore"
  27. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VGA_MODE_3" = "true" ] && QUIRKS="$QUIRKS --quirk-vga-mode3"
  28. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBE_POST" = "true" ] && QUIRKS="$QUIRKS --quirk-vbe-post"
  29. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_RADEON_OFF" = "true" ] && QUIRKS="$QUIRKS --quirk-radeon-off"
  30. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_RESET_BRIGHTNESS" = "true" ] && QUIRKS="$QUIRKS --quirk-reset-brightness"
  31. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_SAVE_PCI" = "true" ] && QUIRKS="$QUIRKS --quirk-save-pci"
  32. [ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_NONE" = "true" ] && QUIRKS="$QUIRKS --quirk-none"
  33.  
  34. # We only support pm-utils
  35. if [ -x "/usr/sbin/pm-suspend" ] ; then
  36.     export NUM_SECONDS_TO_SLEEP=$seconds_to_sleep
  37.     /usr/sbin/pm-suspend $QUIRKS
  38.     RET=$?
  39. else
  40.     # TODO: add support
  41.     unsupported
  42. fi
  43.  
  44. # Refresh devices as a resume can do funny things
  45. for type in button battery ac_adapter
  46. do
  47.     devices=`hal-find-by-capability --capability $type`
  48.     for device in $devices
  49.     do
  50.         dbus-send --system --print-reply --dest=org.freedesktop.Hal \
  51.               $device org.freedesktop.Hal.Device.Rescan
  52.     done
  53. done
  54.  
  55. exit $RET
  56.