~ubuntu-branches/ubuntu/maverick/hal/maverick

« back to all changes in this revision

Viewing changes to tools/linux/hal-system-power-hibernate-linux

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-10-23 12:33:58 UTC
  • mto: (1.5.1 sid)
  • mto: This revision was merged to the branch mainline in revision 90.
  • 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_SUSPEND2DISK="dbus-send --system --dest=com.novell.powersave \
4
 
                         --print-reply /com/novell/powersave \
5
 
                         com.novell.powersave.action.SuspendToDisk"
6
 
 
7
3
unsupported() {
8
4
        echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
9
5
        echo No hibernate script found >&2
23
19
[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VGA_MODE_3" = "true" ] && QUIRKS="$QUIRKS --quirk-vga-mode3"
24
20
[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBE_POST" = "true" ] && QUIRKS="$QUIRKS --quirk-vbe-post"
25
21
[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_RADEON_OFF" = "true" ] && QUIRKS="$QUIRKS --quirk-radeon-off"
26
 
 
27
 
#ALTLinux only supports powersave
28
 
if [ -f /etc/altlinux-release ] ; then
29
 
        if [ -x /usr/bin/powersave ] ; then
30
 
                $POWERSAVED_SUSPEND2DISK
31
 
                RET=$?
32
 
        else
33
 
                unsupported
34
 
        fi
35
 
 
36
 
#Mandriva support suspend-scripts 
37
 
elif [ -f /etc/mandriva-release ] ; then 
38
 
    if [ -x /usr/sbin/pmsuspend ] ; then 
39
 
        /usr/sbin/pmsuspend disk 
40
 
        RET=$? 
41
 
    else 
42
 
        unsupported 
43
 
    fi 
44
 
 
45
 
#RedHat/Fedora and SUSE support support pm-utils
46
 
elif [ -f /etc/redhat-release ] || [ -f /etc/fedora-release ] \
47
 
                 || [ -f "/etc/SuSE-release" ] ; then
48
 
        if [ -x /usr/sbin/pm-hibernate ] ; then
49
 
                /usr/sbin/pm-hibernate $QUIRKS
50
 
                RET=$?
51
 
        else
52
 
                unsupported
53
 
        fi
54
 
 
55
 
#Other distros just need to have *any* tools installed
 
22
[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_RESET_BRIGHTNESS" = "true" ] && QUIRKS="$QUIRKS --quirk-reset-brightness"
 
23
[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_NONE" = "true" ] && QUIRKS="$QUIRKS --quirk-none"
 
24
 
 
25
# We only support pm-utils
 
26
if [ -x /usr/sbin/pm-hibernate ] ; then
 
27
        /usr/sbin/pm-hibernate $QUIRKS
 
28
        RET=$?
56
29
else
57
 
        if [ -x "/usr/bin/powersave" ] ; then
58
 
                $POWERSAVED_SUSPEND2DISK
59
 
                RET=$?
60
 
        elif [ -x "/usr/sbin/pmi" ] ; then
61
 
                /usr/sbin/pmi action hibernate force
62
 
                RET=$?
63
 
        elif [ -x "/usr/sbin/pm-hibernate" ] ; then
64
 
                /usr/sbin/pm-hibernate $QUIRKS
65
 
                RET=$?
66
 
        elif [ -x "/usr/sbin/hibernate" ] ; then
67
 
                # Suspend2 tools installed
68
 
                /usr/sbin/hibernate --force
69
 
                RET=$?
70
 
        elif [ -w "/sys/power/state" ] ; then
71
 
                # Use the raw kernel sysfs interface
72
 
                echo "disk" > /sys/power/state
73
 
                RET=$?
74
 
        else
75
 
                unsupported
76
 
                fi
77
 
        fi
 
30
        unsupported
 
31
fi
78
32
 
79
33
#Refresh devices as a resume can do funny things
80
34
for type in button battery ac_adapter