prevent sleep script

For help and support with issues specific to Linux/Unix
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply.

prevent sleep script

Postby bandolero » Fri Oct 19, 2012 1:47 am

Hello; I had not luck with the infamous "Prevent sleep if streaming" option on my 64 bit chakra linux desktop, so i wrote a linux script based on the idea I found on a Seven thread; it periodically pings PS3 IP, if the PS3 is alive then simulate a shift key pressed with the xdotool command (must be installed).

Code: Select all

# Checks every $SLEEP seconds if PS3 is alive.
# If this happens, prevent sleep.


# Checks if script is already running
if pidof -x $(basename $0) > /dev/null; then
  for p in $(pidof -x $(basename $0)); do
    if [ $p -ne $$ ]; then
      echo "Script $0 is already running: exiting"

# Checks if PS3 Mediaserver is running
if [ -z 'ps -ef |grep ps3 |grep -v grep | awk '{print$2}'' ]; then
    echo "PMS not found. Dying" ; exit 1

# Periodically pings PS3
while true; do
   echo "Checking"
   if [[ $(ping -q -c 3 ${PS3IP}) == @(*100% packet loss*) ]]; then
      echo "PS3 is down"
       echo "PS3 is alive, preventing sleep"
       xdotool key shift
   sleep ${SLEEP}

Seconds to sleep is written in SLEEP at beginning, and the PS3 IP in PS3IP, you must change it with your settings.
I installed xdotool in Chakra linux with the ccr command, google it for Ubuntu or other distros.

I have PS3 Mediaserver installed as a service, I don't know if it works otherwise.
Posts: 4
Joined: Tue Jan 03, 2012 2:03 am

Return to Linux/Unix Support

Who is online

Users browsing this forum: No registered users and 1 guest