View previous topic :: View next topic |
Author |
Message |
Andrey Grozin n00b
Joined: 12 Nov 2015 Posts: 9
|
Posted: Mon Oct 21, 2024 4:00 pm Post subject: How to hibernate when I close the lid |
|
|
I've bought a new notebook (asus vivobook) and installed gentoo. I want the system to hibernate when I close the lid. I've installed hibernate-scripts; when I do (as root)
it hibernates fine, when I switch it on again, everything is restored. But I want to be able to do it quickly, without su and typing the root password, just by closing the lid. I've edited /etc/elogind/logind.conf to contain
Code: | HandleLidSwitch=hibernate
HandleLidSwitchExternalPower=hibernate |
But this does not work: when I close the lid, the notebook continues to work. Is it possible to instruct elogind to call /usr/bin/hibernate when I close the lid? |
|
Back to top |
|
|
Ralphred l33t
Joined: 31 Dec 2013 Posts: 711
|
Posted: Mon Oct 21, 2024 5:27 pm Post subject: Re: How to hibernate when I close the lid |
|
|
Andrey Grozin wrote: | Is it possible to instruct elogind to call /usr/bin/hibernate when I close the lid? | Yeah, if you look up the "Hook Directories" section in man loginctl you can put scripts to be run on "system-sleep" in there. It's worth checking if loginctl hibernate works first though, if it does it could indicate elogind isn't seeing the lid close event at all. |
|
Back to top |
|
|
Andrey Grozin n00b
Joined: 12 Nov 2015 Posts: 9
|
Posted: Tue Oct 22, 2024 4:54 am Post subject: Re: How to hibernate when I close the lid |
|
|
Ralphred wrote: | Andrey Grozin wrote: | Is it possible to instruct elogind to call /usr/bin/hibernate when I close the lid? | Yeah, if you look up the "Hook Directories" section in man loginctl you can put scripts to be run on "system-sleep" in there. It's worth checking if loginctl hibernate works first though, if it does it could indicate elogind isn't seeing the lid close event at all. |
When I do
as root, nothing happens: I get the next shell prompt, and the notebook continues to work.
works as expected. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 23062
|
Posted: Tue Oct 22, 2024 11:11 am Post subject: |
|
|
That suggests that elogind is not able to initiate hibernate. Thus, as Ralphred suggested, lid detection might be fine, and the laptop recognizes the lid close by attempting to hibernate (and not doing so). This differs from the laptop being unaware that the lid closed, and therefore not attempting to hibernate. I suggest debugging why loginctl hibernate does nothing. |
|
Back to top |
|
|
Andrey Grozin n00b
Joined: 12 Nov 2015 Posts: 9
|
Posted: Thu Oct 24, 2024 12:22 pm Post subject: Re: How to hibernate when I close the lid |
|
|
Ralphred wrote: | Andrey Grozin wrote: | Is it possible to instruct elogind to call /usr/bin/hibernate when I close the lid? | Yeah, if you look up the "Hook Directories" section in man loginctl you can put scripts to be run on "system-sleep" in there. It's worth checking if loginctl hibernate works first though, if it does it could indicate elogind isn't seeing the lid close event at all. |
Thank you. I've returned /etc/elogind/logind.conf to its virgin state, and now I'm trying to make a suitable hook. In /lib/elogind I've created a directory system-sleep; here I've created hook.sh:
Code: | #!/bin/bash
if [ $1 = "pre" ]; then
if [ $2 = "suspend" ]; then
echo "hook"
#/usr/bin/hibernate
fi
fi |
(let it hust say "hook" for now). I did . When I say
there is no message "hook", but the computer successfully suspends. When I later press the power button, it activates. Maybe, this hook.sh should be somewhere else?
By the way, after I reconfigure something, should I restart elogind? It behaves in a strange way:
Code: | frodo /lib/elogind/system-sleep # /etc/init.d/elogind stop
* WARNING: elogind is already stopped
frodo /lib/elogind/system-sleep # /etc/init.d/elogind start
* Starting elogind ...
* start-stop-daemon: /usr/lib/elogind/elogind is already running [ !! ]
* ERROR: elogind failed to start
frodo /lib/elogind/system-sleep # /etc/init.d/elogind restart
* Starting elogind ...
* start-stop-daemon: /usr/lib/elogind/elogind is already running [ !! ]
* ERROR: elogind failed to start
frodo /lib/elogind/system-sleep # |
|
|
Back to top |
|
|
Ralphred l33t
Joined: 31 Dec 2013 Posts: 711
|
Posted: Thu Oct 24, 2024 1:44 pm Post subject: Re: How to hibernate when I close the lid |
|
|
Well, how about that, I was messing around in my laptop, testing different loginctl stuff, and stumbled across man sleep.conf: | SuspendByUsing=, HibernateByUsing=
Instead of writing the corresponding state to /sys/power/state, an executable can be defined to
call instead. More than one value can be specified by separating multiple values with whitespace.
They will be tried in turn, until one is called without error. If neither succeeds, the default
operation of writing to /sys/power/state is performed. | so echo "HibernateByUsing=/usr/bin/hibernate" >>/etc/elogind/sleep.conf should fix it as long as hibernate isn't disabled in /etc/elogind/logind.conf.
It's worth checking your DE isn't "intercepting" lid close too, I know KDE can.
Edit: my elogind service behaves oddly too, I have to killall elogind-daemon; rc-service elogind start then it works as expected thereafter. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|