Table of Contents
Mise en Veille vers Hibernation
explication
Si la machine est en veille 5min alors elle passe en hibernation.
On place une heure de reveil (+4min par rapport à l'heure actuelle) dans WAKEALARM /sys/class/rtc/rtc0/wakealarm et on dit à la machine de se réveiller dans 5min via rtcwake :
SLEEPLENGTH=+4min
alarm set for " $(/bin/date -d "$SLEEPLENGTH") > /sys/class/rtc/rtc0/wakealarm
rtcwake --seconds 600 --auto --mode no'
Au réveil on vérifie la valeur de l'alarme pour passer en mode hibernation ou rendre la machine active :
WAKEALARM=/sys/class/rtc/rtc0/wakealarm
ALARM=$(cat $WAKEALARM)
NOW=$(/bin/date +%s)
if [ -z "$ALARM" ] || [ "$NOW" -ge "$ALARM" ]; then
echo "hibernate triggered"
systemctl hibernate || systemctl suspend
else
echo "normal wakeup, clearing RTC alarm."
rtcwake --auto --mode disable
fi
man rtcwake (extrait) :
rtcwake - enter a system sleep state until specified wakeup time
-a, --auto
Read the clock mode (whether the hardware clock is set to UTC
or local time) from the adjtime file, where hwclock(8)
stores that information. This is the default.
-m, --mode mode
no Don't suspend, only set the RTC wakeup time.
script complet
systemd suspend.target
ajouter : Requires=suspend-to-hibernate.service dans /lib/systemd/system/suspend.target :
$ cat /lib/systemd/system/suspend.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Suspend
Documentation=man:systemd.special(7)
DefaultDependencies=no
BindsTo=systemd-suspend.service
After=systemd-suspend.service
Requires=suspend-to-hibernate.service
suspend-to-hibernate.service
edit : /lib/systemd/system/suspend-to-hibernate.service
Description=Delayed hibernation suspend -> hibernate
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279
Documentation=https://wiki.archlinux.org/index.php/Power_management
Before=suspend.target
Conflicts=hibernate.target hybrid-suspend.target
StopWhenUnneeded=true
[Service]
Type=oneshot
RemainAfterExit=yes
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"
Environment="SLEEPLENGTH=+39min"
ExecStart=/bin/bash -c '\
/bin/echo -n "alarm set for " $(/bin/date -d "$SLEEPLENGTH"); \
/bin/echo $(/bin/date +%s -d "$SLEEPLENGTH") > $WAKEALARM; \
/bin/echo;\
/usr/sbin/rtcwake --seconds 2400 --auto --mode no'
ExecStop=/bin/sh -c '\
NOW=$(date '+%s'); \
ALARM=$(cat $WAKEALARM); \
/bin/echo "ALARM wake for hibernate :"$ALARM; \
/bin/echo "NOW :"$NOW; \
if [ -z "$ALARM" ] || [ "$NOW" -ge "$ALARM" ]; then \
/bin/echo "hibernate triggered"; \
/bin/systemctl hibernate || /bin/systemctl suspend; \
else \
/bin/echo "normal wakeup, clearing RTC alarm."; \
/usr/sbin/rtcwake --auto --mode disable; \
fi;'
[Install]
WantedBy=sleep.target
root@houyo:/lib/systemd/system# systemctl start suspend-to-hibernate
root@houyo:/lib/systemd/system# systemctl enable suspend-to-hibernate
Created symlink from /etc/systemd/system/sleep.target.wants/suspend-to-hibernate.service to /lib/systemd/system/suspend-to-hibernate.service.
root@houyo:/lib/systemd/system#
Gestionnaire Alimention Xfce
ce qui dois arriver
inactivitée sur batterie
- 1m30s : reduire la luminosité à 5%
- 2m : écran vide
- 15m : mettre en veille sur Ram le système
- 40m : passer de veille sur Ram à veille sur disque
inactivitée sur secteur
Quand branché sur le secteur aucun paramètre de mise en veille n'est activé.
- 1m30s : reduire la luminosité à 5%
- 2m : écran vide
trouble
ask for passwd
Automatic suspend from the xfce power manager does not work, as a window opens and asks for my password. Well, if it wants to suspend the system after a given timeout, I cannot enter my password as I'm not in front of my system then. Once I'm able to enter my password it is too late to run the suspend action.
message in the upper corner saying :
Power Manager: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Method call timed out.
Put light-locker setting Auto Lock Session to When the screensaver is deactivated to solves the problem.
see :
- Ubuntu Bug : 1605189 Authentication is required for suspending the system
- Xubuntu Bug : Failing to sleep after inactivity - power manager error ?
There's already a shutdown or sleep operation in progress
Failed to hibernate system via logind: There's already a shutdown or sleep operation in progress
Failed to suspend system via logind: There's already a shutdown or sleep operation in progress
missing in : /lib/systemd/system/suspend.target
Requires=suspend-to-hibernate.service