I try to give a behavior to a closing lid of a laptop following this rules:
When the lid is closed:
- After 1m, it should be screenlocked ;
- After 10m, it should be suspended ;
- After 15m, it should be shutdown.
So, I make the following script:
#!/bin/bash
USER=fauve
sleep 1m
# set screensaver
su -c "$HOME/.local/bin/screenlock" - $USER
# hibernate
sleep 9m
systemctl suspend
sleep 5m
# shutdown
shutdown 0
But as you see, the shutdown
comes when the laptop is under suspension, so it will never shutdown.
So how can I program a suspension or shutdown for 5min, and then make the script keep going to shutdown completely the computer?