File: acpi_sleep

package info (click to toggle)
hibernate 2.0%2B15%2Bg88d54a8-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 740 kB
  • ctags: 114
  • sloc: sh: 1,223; makefile: 17
file content (62 lines) | stat: -rw-r--r-- 1,731 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- sh -*-
# vim:ft=sh:ts=8:sw=4:noet

AddConfigHandler ACPISleepConfigEnabler
AddOptionHandler ACPISleepOptionHandler

AddConfigHelp "UseACPISleep <state>" "Enables the use of /proc/acpi/sleep for suspending the machine. Be aware that this method is deprecated in favour of using /sys/power/state (with the sysfs_power_state scriptlet). This requires a kernel with ACPI support built in. <state> should generally be 3 (for suspend-to-RAM), or 4 (for suspend-to-disk). Note: You should not use this if you want to use TuxOnIce."

AddShortOption "n"
AddLongOption "no-suspend"

ACPI_SLEEP_FILE=/proc/acpi/sleep

ACPISleepConfigEnabler() {
    [ "$1" != "useacpisleep" ] && return 1
    [ -n "$USING_ACPI_SLEEP" ] && return 0
    if [ -n "$NO_COMPLAIN_UNSUPPORTED" ] ; then
	# Just bail silently if we don't detect it.
	if ! test -f $ACPI_SLEEP_FILE ; then
	    return 0
	fi
    fi
    UsingSuspendMethod acpi_sleep
    AddSuspendHook 10 EnsureACPISleepCapable
    AddSuspendHook 99 DoACPISleep
    USING_ACPI_SLEEP=$2
    return 0
}

ACPISleepOptionHandler() {
    [ -z "$USING_ACPI_SLEEP" ] && return 1
    case $1 in
	-n|--no-suspend)
	    ACPI_SLEEP_NO_SUSPEND=1
	    ;;
	*)
	    return 1
    esac
    return 0
}

DoACPISleep() {
    if [ -z "$ACPI_SLEEP_NO_SUSPEND" ] ; then
	vecho 1 "$EXE: Activating ACPI sleep state $USING_ACPI_SLEEP ..."
	/bin/echo -n $USING_ACPI_SLEEP > $ACPI_SLEEP_FILE
    else
	vecho 1 "$EXE: Not actually suspending (--no-suspend given)"
    fi
    return 0
}

# EnsureACPISleepCapable: makes sure we have /proc/acpi/sleep.
EnsureACPISleepCapable() {
    if ! test -f $ACPI_SLEEP_FILE ; then
	vecho 0 "Your kernel does not appear to have ACPI sleep support."
	return 2
    fi

    return 0
}

# $Id$