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

« back to all changes in this revision

Viewing changes to tools/linux/hal-system-power-suspend-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
1
#!/bin/sh
2
2
 
3
 
POWERSAVED_SUSPEND2RAM="dbus-send --system --dest=com.novell.powersave \
4
 
                        --print-reply /com/novell/powersave \
5
 
                        com.novell.powersave.action.SuspendToRam"
6
 
 
7
3
alarm_not_supported() {
8
4
        echo org.freedesktop.Hal.Device.SystemPowerManagement.AlarmNotSupported >&2
9
5
        echo Waking the system up is not supported >&2
31
27
[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VGA_MODE_3" = "true" ] && QUIRKS="$QUIRKS --quirk-vga-mode3"
32
28
[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBE_POST" = "true" ] && QUIRKS="$QUIRKS --quirk-vbe-post"
33
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"
34
32
 
35
 
#PMU systems cannot use /sys/power/state yet, so use a helper to issue an ioctl
36
 
if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "pmu" ]; then
37
 
        hal-system-power-pmu sleep
38
 
        if [ $? -ne 0 ]; then
39
 
                echo "org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported" >&2
40
 
                exit 1
41
 
        fi
42
 
        exit 0
 
33
# Urh. Do any BIOSen handle this correctly?
 
34
if [ $seconds_to_sleep != "0" ] ; then
 
35
        alarm_not_supported
43
36
fi
44
37
 
45
 
#ALTLinux only supports powersave
46
 
if [ -f "/etc/altlinux-release" ]; then
47
 
        if [ -x /usr/bin/powersave ] ; then
48
 
                $POWERSAVED_SUSPEND2RAM
49
 
                RET=$?
50
 
        else
51
 
                # TODO: add support
52
 
                unsupported
53
 
        fi
54
 
 
55
 
#Mandriva supports suspend-scripts 
56
 
elif [ -f "/etc/mandriva-release" ] ; then 
57
 
    # TODO: fix pmsuspend to take a --wakeup-alarm argument 
58
 
    if [ $seconds_to_sleep != "0" ] ; then 
59
 
        alarm_not_supported 
60
 
    fi 
61
 
    
62
 
    if [ -x "/usr/sbin/pmsuspend" ] ; then 
63
 
        /usr/sbin/pmsuspend memory
64
 
        RET=$? 
65
 
    else 
66
 
        # TODO: add support 
67
 
        unsupported 
68
 
    fi 
69
 
 
70
 
#RedHat/Fedora and SUSE support pm-utils
71
 
elif [ -f "/etc/redhat-release" ] || [ -f "/etc/fedora-release" ] \
72
 
                || [ -f "/etc/SuSE-release" ] ; then
73
 
        # TODO: fix pm-suspend to take a --wakeup-alarm argument
74
 
        if [ $seconds_to_sleep != "0" ] ; then
75
 
                alarm_not_supported
76
 
        fi
77
 
        # TODO: fixup pm-suspend to define erroc code (see alarm above) and throw
78
 
        #          the appropriate exception
79
 
        if [ -x "/usr/sbin/pm-suspend" ] ; then
80
 
                /usr/sbin/pm-suspend $QUIRKS
81
 
                RET=$?
82
 
        else
83
 
                # TODO: add support
84
 
                unsupported
85
 
        fi
86
 
 
87
 
#Other distros just need to have *any* tools installed
 
38
# We only support pm-utils
 
39
if [ -x "/usr/sbin/pm-suspend" ] ; then
 
40
        /usr/sbin/pm-suspend $QUIRKS
 
41
        RET=$?
88
42
else
89
 
        if [ -x "/usr/bin/powersave" ] ; then
90
 
            $POWERSAVED_SUSPEND2RAM
91
 
            RET=$?
92
 
        elif [ -x "/usr/sbin/pmi" ] ; then
93
 
            /usr/sbin/pmi action suspend force
94
 
            RET=$?
95
 
        elif [ -x "/usr/sbin/pm-suspend" ] ; then
96
 
                /usr/sbin/pm-suspend $QUIRKS
97
 
                RET=$?
98
 
        elif [ -w "/sys/power/state" ] ; then
99
 
            # Use the raw kernel sysfs interface
100
 
            echo "mem" > /sys/power/state
101
 
            RET=$?
102
 
        else
103
 
            # TODO: add other scripts support
104
 
            unsupported
105
 
            fi
106
 
        fi
 
43
        # TODO: add support
 
44
        unsupported
 
45
fi
107
46
 
108
 
#Refresh devices as a resume can do funny things
 
47
# Refresh devices as a resume can do funny things
109
48
for type in button battery ac_adapter
110
49
do
111
50
        devices=`hal-find-by-capability --capability $type`