I am using a laptop with Ubuntu 16.04, Gnome as desktop environment and LightDM as login manager.
What I want to do is to suspend the computer after the lid has been closed for 30 seconds. Is this possible?
gnomelidpower-managementsuspend
I am using a laptop with Ubuntu 16.04, Gnome as desktop environment and LightDM as login manager.
What I want to do is to suspend the computer after the lid has been closed for 30 seconds. Is this possible?
Best Answer
Switch to suspend 30 seconds after the lid is closed
Disable default close-lid actions
To set a specific time, before the computer should switch to suspend, we need to disable the default actions for closing the lid. This can be done by the following commands:
and
Custom actions on closing lid
Subsequently, we need to set alternative actions on closing the lid, to include the break of 30 seconds before suspend. We can hook those to existing events.
The question is if the advantages of that weigh up to the more complicated setup that would require. A scripted version like below consumes practically zero from both your processor and your memory, even if you ran ten of them.
The advantage of the scripted option is that it is easily revertible; simply don't run it anymore and restore your original (or different) settings.
The script
How to use
As mentioned, first disable the default lid-close-actions:
and
Copy the script into an empty file, save it as
delay_lidsuspend.py
In the head section of the script, some default values and paths are set. Most likely, you don't need to change anything:
I am not sure the path to your lid state file ("/proc/acpi/button/lid/LID/state") is the same on every laptop. Test with the command:
Test- run the script by running from a terminal:
and close the lid to see if it works as intended (here it did the job perfectly).
If all works fine, add it to Startup Applications.