Ubuntu – How to inhibit suspend from the command line

command linesshsuspend

Is there a way to inhibit suspend/hibernate from the command line. I want to ssh into my home computer and not have it suspend while I'm working on it.

Best Answer

Use xdotool instead:

sudo apt-get install xdotool

Then, in a bash loop like this

while true ; do
    DISPLAY=:0.0 xdotool key Shift_L   # send a "harmless" keypress to Xorg
    sleep 5                            # wait a little bit and do it again
done