Jump to content

Autosleep-Script


KWS
 Share

165 posts in this topic

Recommended Posts

mmmhhhhhhhhh still no go.... i played with NetVal=20000 # Treshold for Network-Traffic in Byte/s going up to 90000 no change at all..... so i tried just to unplug lan cable and ..... no network traffic but no sleep...

 

so as nobody of the other downloaders gave a feedback i assume it must be something with my two test systems!!.. well KWS you did not confirm that its working for you ;)

 

i have no script skills but i can make few more test if you like..

 

thx

 

salu2

Link to comment
Share on other sites

Heres a Testskript, download it and copy it to your desktop ...

 

TestLAN.sh.zip

 

Then open a terminal window, type

bash

and drag the TestLan-skript inside the window.

 

You will see something like

bash /Users/xxx/Desktop/TestLAN.sh

 

Hit enter ...

You should see

 

en0 TrafficOut 0

en1 TrafficOut 0

fw0 TrafficOut 0

 

Now try to copy some files from your server to a client ...

 

In the terminal window again hit enter and wait ...

 

Now you should see something like

 

en0 TrafficOut 0

en1 TrafficOut 18348

exit en1

 

if the outgoing traffic uses en1

 

You can copy the appearing lines and post them ...

Link to comment
Share on other sites

thats what i get

 

 

Server$ bash /Users/Server/Desktop/TestLAN.sh this one via remote desktop

en0 TrafficOut 528

en1 TrafficOut 0

fw0 TrafficOut 0

Server$ bash /Users/Server/Desktop/TestLAN.sh without remote desktop

en0 TrafficOut 0

en1 TrafficOut 0

fw0 TrafficOut 0

Server$ bash /Users/Server/Desktop/TestLAN.sh

en0 TrafficOut 78733242

exit en0

 

whats strange is even if i disable the ethernet port in bios there is definitely no traffic and it should sleep.. but it doesn't

 

 

Link to comment
Share on other sites

  • 3 weeks later...

Thanx :thumbsup_anim: to all for shearing your workarounds, after going through all post I`ve managed to bring to sleep my machine, one thing at the and which made my day was that I`ve moved from L/Pref/SystemConfiguration/ com.apple.PowerManagement.plist of SL10.6.8 to Leo 10.7.2 and its sleeps and wakes like in my old SL without any problem--- maybe this tipp helps somebody-

 

Here`s my plist

 


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ActivePowerProfiles</key>
<dict>
<key>AC Power</key>
<integer>-1</integer>
</dict>
<key>Custom Profile</key>
<dict>
<key>AC Power</key>
<dict>
<key>Automatic Restart On Power Loss</key>
<integer>0</integer>
<key>Disk Sleep Timer</key>
<integer>10</integer>
<key>Display Sleep Timer</key>
<integer>60</integer>
<key>Hibernate File</key>
<string>/var/vm/sleepimage</string>
<key>Hibernate Mode</key>
<integer>0</integer>
<key>Sleep On Power Button</key>
<integer>1</integer>
<key>System Sleep Timer</key>
<integer>0</integer>
<key>TTYSPreventSleep</key>
<integer>0</integer>
</dict>
</dict>
<key>LastSleepUUID</key>
<dict>
<key>Date</key>
<date>2012-01-16T20:14:57Z</date>

 

changes which I`ve made are:

 

Hibernat=0,

System Sleep timer=0,

TTYSPreventSleep=0

Link to comment
Share on other sites

I was having a problem where my hack would go to sleep while i was streaming content to my AppleTV. It appears to happen once the content has been fully buffered on the AppleTV and the network traffic drops below the 50KB/s limit. Once that happened, the computer would go to sleep and the AppleTV would abruptly stop playing. In order to prevent this from happening, i edited the sleep.sh script and added the following code just before the end where it puts the system to sleep

 

# check if any appletvs are currently connected and prevent sleep if they are
ATV=`/usr/sbin/lsof -i | grep apple-tv`
if [ -n "$ATV" ]; then
logger -t KWSleep "AppleTV currently connected. Do Not Sleep"
exit
fi

 

In order for this to work correctly, i had to make sure my AppleTV was set to sleep after a period of inactivity (i have mine set to 15 minutes). Otherwise the AppleTV keeps the connection open regardless of whether it's playing something and the computer would never sleep.

 

UPDATE: I found something interesting today when i hooked up a new AppleTV to my home network. I have 3 ATV's connected via Wired connection. The new ATV i had to use wireless. I found that when the wireless ATV was streaming from iTunes, my hack still went to sleep. Upon digging, it looks like the wireless ATV does not resolve to the host name specified (ie. office-apple-tv) and only shows the IP address when you run lsof -i | grep iTunes. This appears to be a problem with my Linksys WRT610N router not supporting IPV6 over wifi. It does support IPV6 over LAN. Instead of trying to figure out the IP addresses of all the ATVs and hardcoding them in the script, i just used an Airport Express i had lying around to create a second wifi network that my ATV is connected to. As expected, the Airport Express (and i would assume an Airport Extreme) allows wireless clients to connect to my home network via IPV6 and the hostnames are resolved, allowing me to use "lsof -i | grep apple-tv" for determining when my ATV's are streaming content from my hack.

Edited by rcork
  • Like 1
Link to comment
Share on other sites

  • 6 months later...

Thanks for this script KWS. I have been using it for 1 yr plus and has been working great. One thing that I just noticed is that I can't update cpu load for programs. I am using 10.7.4 and whether I open the main.scpt manually or through "Open RIP 10.7.x.app" when I make the change from example to add HandBrake to the list of Finder and Diskutility already present, the change stays till I reboot. On reboot, the program returns to its default values of Finder and Disk Utility only. My addition of Handbrake disappears. Do you have any idea as to why this is happening and what I can do to prevent it? Thanks.

Link to comment
Share on other sites

I have no clue. I tried it here on 10.8 and it works ....

 

If you select in Finder go to Folder and paste

 

/Library/Scripts/RIP3Lion.app/Contents/Resources/Scripts/

 

and doubleclick on main.scpt it should be possible to change the script and save it.

If not, try to copy RIP3Lion.app to your desktop, change main.scpt and copy it back (overwrite) to /Library/Scripts/.

Link to comment
Share on other sites

  • 3 weeks later...

Hi KWS, ive been using your rip3lion on 10.8 and i have to say it works really good, but i have one issue that i hope u can solve for me....

i use plex media server on the same mac as rip3lion , and it streams all my media to various iPads/iphones.

the only problem i have is that the second a movie stops playingon the iPad,,the mac sleeps,which is okay but i have to keep waking via bluetooth mouse if i want to watch another movie or episode.

i have added the plex media server to the script, but i find uses almost zero cpu resources, while browsing the plex library...

ive tried modifying your code but with no positive results...

any help here would be appreciated

Link to comment
Share on other sites

It is possible to ask if plex is running and stop the script ... questioning for plex playing needs applescript-support in the prog which (i think) is not given yet.

So you need to look in activity-monitor for the running prog's name and add these lines (changing PLEX to the real name in activity-monitor) somewhere behind DVD-Player-section:

 

tell application "System Events"

if exists process "PLEX" then

return

end if

end tell

Link to comment
Share on other sites

  • 7 months later...
 Share

×
×
  • Create New...