How do I inhibit suspend from the command line?

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.


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

You also might want to try this script 1, it inhibits to suspend/turn off your machine, I use it when watching movies.

img

1 http://linuxtidbits.wordpress.com/2009/09/08/movietime-stop-powersaving-to-watch-a-movie/