Prevent mac from sleeping when HD in use

Discussion in 'OS X Mountain Lion (10.8)' started by jangozo, Jan 23, 2013.

  1. jangozo macrumors member

    Joined:
    Oct 10, 2012
    #1
    Hi,

    I stream via DLNA movies from my external hard drive but every time my mac reaches the set sleeping time, it shuts down. Is there a way to prevent my mac from sleeping whenever it's reading from the external hard drive? It would be better if it can monitor just whenever it's streaming but that would depend on the software I think.

    Thanks.
     
  2. jangozo thread starter macrumors member

    Joined:
    Oct 10, 2012
    #2
    Since there are so many views but no replies. I'll post the answer.

    Option 1:
    Crontab this script (the IP is the IP of my tv on dlna):
    Code:
    #!/bin/sh
    
    script_name=`basename $0`
    echo $script_name
    coffee_time=20
    if [ `ps -ef | grep -v grep | grep $script_name | wc -l` -eq 2 ]; then
    	echo `date` "$script_name is checking for streams"
    	until [[ -z `/usr/sbin/lsof -i @192.168.1.100` ]]; do
    		echo `date` "Stream found. Caffeinating.." 
    		caffeinate -t $coffee_time
    	done
    else
    	echo `date` "$script_name is already running"
    fi
    Option 1:
    Use sleepwatcher app and this script:
    Code:
    #!/bin/sh
    
    coffee_time=20
    until [[ -z `/usr/sbin/lsof -i @192.168.1.100` ]]; do
    	echo `date` "Stream found. Caffeinating.." 
    	caffeinate -t $coffee_time
    done
     
  3. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #3
    Caffeine will temporarily override your energy saver settings and keep your Mac awake with a click on the Menu Bar icon. Another click turns it off.

    To keep your Mac notebook awake with the lid closed, use InsomniaX or InsomniaT (rebuild for SL) (fix for 2011 MPBs)

    NoSleep also keeps your Mac notebook awake when you close the lid.
     
  4. jangozo thread starter macrumors member

    Joined:
    Oct 10, 2012
    #4
    All good apps but not what I'm after. They all require user input to stop the sleep when I'm streaming to my tv. There are times when I will forget it and there will be some swearing.
     
  5. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #5
    You can set Caffeine to automatically launch when you start your Mac. No user input required.
     
  6. jangozo thread starter macrumors member

    Joined:
    Oct 10, 2012
    #6
    Sure, it will automatically launch and prevent it from sleeping. This means there will be user input when I want it to go to sleep after some idle time.
     

Share This Page