How to prevent sleep until script finish
(how to temporary forbid sleep and suspend)
Published in
1 min readJan 7, 2018
Autosuspend is a great feature. Your PC goes into suspend (sleep) after some inactivity period. But if you have some long-running job (backup, computation, etc), you may want to prevent sleep until this job is done.
Manual switch is an option, but there is a better way.
I use Cinnamon, so here is a solution for Cinnamon:
old_autosleep=`dconf read /org/cinnamon/settings-daemon/plugins/power/sleep-inactive-ac-timeout`
dconf write /org/cinnamon/settings-daemon/plugins/power/sleep-inactive-ac-timeout 0
your_important_job_here
dconf write /org/cinnamon/settings-daemon/plugins/power/sleep-inactive-ac-timeout $old_autosleep