N'oubliez pas de chmod + x ce fichier, rendez-le exécutable.
Il existe une autre solution sans rtcwake, en utilisant wakealarm dans / sys / class / rtc / rtc0. Utilisez du code obsolète dans pm-functions (/ usr / lib / pm-utils) après les commentaires # depuis que le noyau ne supporte pas directement ..., (car le noyau actuel (quelque chose après la version 3.6) le supporte directement). Retournez ce code et insérez la partie do_suspend () à la place de do_suspend_hybrid ().
Code obsolète (suspendre puis hiberner lorsque susp_hybrid est appelé):
# since the kernel does not directly support hybrid sleep, we do
# something else -- suspend and schedule an alarm to go into
# hibernate if we have slept long enough.
# Only do this if we do not need to do any special video hackery on resume
# from hibernate, though.
if [ -z "$SUSPEND_HYBRID_MODULE" -a -w "$PM_RTC/wakealarm" ] && \
check_suspend && check_hibernate && ! is_set $HIBERNATE_RESUME_POST_VIDEO; \
then
SUSPEND_HYBRID_MODULE="kernel"
do_suspend_hybrid() {
WAKETIME=$(( $(cat "$PM_RTC/since_epoch") + PM_HIBERNATE_DELAY))
echo >"$PM_RTC/wakealarm"
echo $WAKETIME > "$PM_RTC/wakealarm"
if do_suspend; then
NOW=$(cat "$PM_RTC/since_epoch")
if [ "$NOW" -ge "$WAKETIME" -a "$NOW" -lt $((WAKETIME + 30)) ]; then
log "Woken by RTC alarm, hibernating."
# if hibernate fails for any reason, go back to suspend.
do_hibernate || do_suspend
else
echo > "$PM_RTC/wakealarm"
fi
else
# if we cannot suspend, just try to hibernate.
do_hibernate
fi
}
fi
Conseillé. Encore plus facile à utiliser uswsusp tout en maximisant les avantages de s2both, c’est-à-dire s2both lorsqu’il est suspendu. Placez le code inversé dans la partie do_suspend () du module uswsusp (/usr/lib/pm-utils/module.d).
Code inversé (suspend_hybrid lorsque la suspension est appelée):
WAKETIME=$(( $(cat "$PM_RTC/since_epoch") + PM_HIBERNATE_DELAY))
echo >"$PM_RTC/wakealarm"
echo $WAKETIME > "$PM_RTC/wakealarm"
if do_suspend_hybrid; then
NOW=$(cat "$PM_RTC/since_epoch")
if [ "$NOW" -ge "$WAKETIME" -a "$NOW" -lt $((WAKETIME + 30)) ]; then
log "Woken by RTC alarm, hibernating."
# if hibernate fails for any reason, go back to suspend_hybrid.
do_hibernate || do_suspend_hybrid
else
echo > "$PM_RTC/wakealarm"
fi
else
# when do_suspend is being called, convert to suspend_hybrid.
do_suspend_hybrid
fi
Avec uswsusp, nous pouvons voir l’avancement de la suspension / hibernation et le processus inverse affichés en texte, même si nous pouvons l’abandonner en appuyant sur la touche retour arrière. Sans uswsusp, suspendre / hibernate semble juste disparaître de manière ennuyeuse, surtout lorsque wakealarm est déclenché et exécuter hibernate (s2disk in uswsusp). Définissez la période de sommeil avant l'hibernation à l'emplacement habituel du fichier pm-functions.
# variables to handle hibernate after suspend support
PM_HIBERNATE_DELAY=900 # 15 minutes
PM_RTC=/sys/class/rtc/rtc0
Voici le mod uswsusp: (rappelez-vous, ce module est appelé depuis pm-functions, donc les variables insérées sont les mêmes)
#!/bin/sh
# disable processing of 90chvt and 99video.
# s2ram and s2disk handle all this stuff internally.
uswsusp_hooks()
{
disablehook 99video "disabled by uswsusp"
}
# Since we disabled 99video, we need to take responsibility for proper
# quirk handling. s2ram handles all common video quirks internally,
# so all we have to do is translate the HAL standard options to s2ram options.
uswsusp_get_quirks()
{
OPTS=""
ACPI_SLEEP=0
for opt in $PM_CMDLINE; do
case "${opt##--quirk-}" in # just quirks, please
dpms-on) ;; # no-op
dpms-suspend) ;; # no-op
radeon-off) OPTS="$OPTS --radeontool" ;;
reset-brightness) ;; # no-op
s3-bios) ACPI_SLEEP=$(($ACPI_SLEEP + 1)) ;;
s3-mode) ACPI_SLEEP=$(($ACPI_SLEEP + 2)) ;;
vbe-post) OPTS="$OPTS --vbe_post" ;;
vbemode-restore) OPTS="$OPTS --vbe_mode" ;;
vbestate-restore) OPTS="$OPTS --vbe_save" ;;
vga-mode-3) ;; # no-op
save-pci) OPTS="$OPTS --pci_save" ;;
none) QUIRK_NONE="true" ;;
*) continue ;;
esac
done
[ $ACPI_SLEEP -ne 0 ] && OPTS="$OPTS --acpi_sleep $ACPI_SLEEP"
# if we were told to ignore quirks, do so.
# This is arguably not the best way to do things, but...
[ "$QUIRK_NONE" = "true" ] && OPTS=""
}
# Since we disabled 99video, we also need to handle displaying
# help info for the quirks we handle.
uswsusp_help()
{
echo # first echo makes it look nicer.
echo "s2ram video quirk handler options:"
echo
echo " --quirk-radeon-off"
echo " --quirk-s3-bios"
echo " --quirk-s3-mode"
echo " --quirk-vbe-post"
echo " --quirk-vbemode-restore"
echo " --quirk-vbestate-restore"
echo " --quirk-save-pci"
echo " --quirk-none"
}
# This idiom is used for all sleep methods. Only declare the actual
# do_ method if:
# 1: some other sleep module has not already done so, and
# 2: this sleep method can actually work on this system.
#
# For suspend, if SUSPEND_MODULE is set then something else has already
# implemented do_suspend. We could just check to see of do_suspend was
# already declared using command_exists, but using a dedicated environment
# variable makes it easier to debug when we have to know what sleep module
# ended up claiming ownership of a given sleep method.
if [ -z "$SUSPEND_MODULE" ] && command_exists s2ram && \
( grep -q mem /sys/power/state || \
( [ -c /dev/pmu ] && check_suspend_pmu; ); ); then
SUSPEND_MODULE="uswsusp"
do_suspend()
{
WAKETIME=$(( $(cat "$PM_RTC/since_epoch") + PM_HIBERNATE_DELAY))
echo >"$PM_RTC/wakealarm"
echo $WAKETIME > "$PM_RTC/wakealarm"
if do_suspend_hybrid; then
NOW=$(cat "$PM_RTC/since_epoch")
if [ "$NOW" -ge "$WAKETIME" -a "$NOW" -lt $((WAKETIME + 30)) ]; then
log "Woken by RTC alarm, hibernating."
# if hibernate fails for any reason, go back to suspend_hybrid.
do_hibernate || do_suspend_hybrid
else
echo > "$PM_RTC/wakealarm"
fi
else
# when do_suspend is being called, convert to suspend_hybrid.
do_suspend_hybrid
fi
}
fi
if [ -z "$HIBERNATE_MODULE" ] && \
[ -f /sys/power/disk ] && \
grep -q disk /sys/power/state && \
[ -c /dev/snapshot ] &&
command_exists s2disk; then
HIBERNATE_MODULE="uswsusp"
do_hibernate()
{
s2disk
}
fi
if [ -z "$SUSPEND_HYBRID_MODULE" ] &&
grep -q mem /sys/power/state && \
command_exists s2both && \
check_hibernate; then
SUSPEND_HYBRID_MODULE="uswsusp"
do_suspend_hybrid()
{
uswsusp_get_quirks
s2both --force $OPTS
}
if [ "$METHOD" = "suspend_hybrid" ]; then
add_before_hooks uswsusp_hooks
add_module_help uswsusp_help
fi
fi