~ubuntu-branches/debian/sid/hal/sid

« back to all changes in this revision

Viewing changes to tools/linux/hal-system-power-suspend-hybrid-linux

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-10-23 12:33:58 UTC
  • Revision ID: james.westby@ubuntu.com-20071023123358-xaf8mjc5n84d5gtz
Tags: upstream-0.5.10
ImportĀ upstreamĀ versionĀ 0.5.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_NONE" = "true" ] && QUIRKS="$QUIRKS --quirk-none"
 
32
 
 
33
# We only support pm-utils
 
34
if [ -x "/usr/sbin/pm-suspend-hybrid" ] ; then
 
35
    if [ $seconds_to_sleep != "0" ] ; then
 
36
        alarm_not_supported
 
37
    fi
 
38
    /usr/sbin/pm-suspend-hybrid $QUIRKS
 
39
    RET=$?
 
40
else
 
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