Jump to content

Autosleep-Script


KWS
 Share

165 posts in this topic

Recommended Posts

all you guys are lucky :( i can't even get manual sleep to work on my EX58A-UD3R :(
Luck has nothing to do with it, you need to use a modified DSDT.

There is no such thing as a EX58A-UD3R, it's either a EX58-UD3R or a X58A-UD3R.

Link to comment
Share on other sites

  • 6 months later...

Thank you for the Script !! It fixed my "Auto" Sleep Problem since i use Paragon NTFS v8 :) Manual Sleep/Wake is Rockstable.

 

I use your RIP3lan Script and it works fine while Lan Streaming of Movies too .

 

Autosleep works fine without Paragon NTFS. As soon i install the Paragon NTFS Driver Auto Sleep is broken.

The Script works perfectly fine on Snow Leopard 10.6.5 and my Asus P7P55LX with DSDT.

Link to comment
Share on other sites

Thank you very much KWS, RIP3lan is working for me also.

 

Do you think it's a good idea to set in the script

 

set systemSleepDelay to ((systemSleepDelay * 60) - 1)

 

so the script always takes place before scheduled system sleep?

Link to comment
Share on other sites

Thank you very much KWS, RIP3lan is working for me also.

 

Do you think it's a good idea to set in the script

 

set systemSleepDelay to ((systemSleepDelay * 60) - 1)

 

so the script always takes place before scheduled system sleep?

You can change it, but in my case (wrong dvd-drive) it doesn't matter ... :help:

I think this on idle event is checked every 30 s from system, so it's possible that one check is 2 s before scheduled system sleep and the next (last) is 28 after, so this may be anyway not the exact moment when the the script triggers ...

Link to comment
Share on other sites

Hello,

 

Is this script usable as a third party app? I use hardware monitor and with monitoring ability i can call a 3rd app to launch if CPU overheating per example. Suppose i set hardware monitor to call your script to put the computer in sleep mode when CPU is over 75 degres. OK or KO ?

 

In fact i have already done a shutdown script but there is some resistant programs, even mail sometimes prevents from sleep/shutdown.

 

Thanks.

Link to comment
Share on other sites

If i understand your question you need only the line

 

tell application "System Events" to sleep

 

open AppleScript editor, paste this line, save the script anywhere and call it from hardware monitor ...

Link to comment
Share on other sites

My DVD drive is Optiarc DVD RW AD-7240S.

 

The script puts the PC to sleep perfectly.

It checks AppleFileServer activity (refered to file transfer in the LAN).

For Finder activity and local file transfers it's the same.

But it doesn't check the network activity, for example when Safari is downloading. If I add Safari to the sleep-resistants apps, it works as expected but the computer doesn't go to sleep when Safari's downloads are finished (Safari remains opened).

 

It would be nice to check if Safari's cpu load is greater than 2% (for example). I've tried to duplicate the text of the script containing the references to AppleFileServer and the Finder but it doesn't work:

 

		set Prog3 to do shell script ("ps auxww | grep '[/]" & "Safari" & "'" & " | 
grep '" & "root" & "' | awk '{print $2}'")
	if Prog3 is greater than 0 then
		set cpu_usage to (do shell script ("ps -c -o %cpu='' -p " & Prog3)) as integer
		if cpu_usage > 2 then
			return
		end if
	end if

 

This code doesn't prevent RIP to put the computer to sleep if Safari is downloading some file with a cpu usage greater than 2%.

 

(Sorry my english).

Link to comment
Share on other sites

It seems that Safaris cpu-usage increases with more tabs open or with certain pages (probably with more ads, more background connectivity, preloading or something). So in some cases the script will stop (that means no sleep) without a running download .... :)

 

So try this one, i hope it will not trigger to early ...

 

 

Link to comment
Share on other sites

This is a safer version: no problems with cpu usage or such things ... ?

These lines

 

set filePath to path to home folder from local domain as string

set x to filePath & "Downloads:" as alias

tell current application

set theSize to size of (info for x)

delay 3

set theSize2 to size of (info for x)

if theSize = theSize2 then

else

return

end if

end tell

 

compare the download-folder-size in home-directory within 3 s, so every download should be detected ... :D

 

RIP3lanS2.app.zip

Link to comment
Share on other sites

Clever!

 

Your last RIP3lan with safari check works like a charm, if Safari is open and download is finished the PC goes to sleep (since CPU usage is less than 2%) but if download is active (cpu usage fluctuates from 1-2 to 20%) it goesn't.

 

I've already thought about to check something into the Safari downloads folder (files ending with .download appearing...) but your approach is better. I'll try and comment here.

 

What I haven't found is how to check from Applescrip (or shell script) if Safari downloads are finished.

 

Great job, kws, this is an different approach to an specfic sleep problem common in hackintosh. I have to give publicity to your script between spanish people, it may be usefull.

 

EDIT: entry about this in my blog.

 

EDIT: RIP3lanS2 works well, it checks the download folder and its subfolders, the PC goes to sleep as expected. Thanks.

Link to comment
Share on other sites

The RIPLanS2 Script does nor prevent Sleep when download with jdownloader ?

 

Strange.. jdownloader produce some CPU load and Network Activity so it shouldnt sleep.

 

Can you take a look into it please ?

 

"compares the download-folder-size in home-directory", that means: download your Files to this directory, and the script will prevent sleep. You (or jdownloader with standard settings) have probably choosen a different directory for your downloads ...

Link to comment
Share on other sites

"compares the download-folder-size in home-directory", that means: download your Files to this directory, and the script will prevent sleep. You (or jdownloader with standard settings) have probably choosen a different directory for your downloads ...

 

yes, i know. this should work cause i choose my NTFS Drive. I thought the Script have to stop because jdownloader produce some CPU load up to 15% sometimes?

I will use the Home/Download Folder now, THX

 

But maybe a Function to "generally" Monitor Internet Down/Upload would be usefull.

"Network" Media (with Samba Streaming) Traffic stops the Script without Problems so far, why not Internet Traffic ?

Link to comment
Share on other sites

yes, i know. this should work cause i choose my NTFS Drive. I thought the Script have to stop because jdownloader produce some CPU load up to 15% sometimes?

I will use the Home/Download Folder now, THX

 

But maybe a Function to "generally" Monitor Internet Down/Upload would be usefull.

"Network" Media (with Samba Streaming) Traffic stops the Script without Problems so far, why not Internet Traffic ?

 

Because i dont know which prog (part of OS) is responsible for Internet traffic. Outgoing traffic = Finder, Incoming = AppleFileServer (hope i dont confuse it :D), but "Internet" traffic ... ?? ...;)

Link to comment
Share on other sites

I agree, it's not easy to find which process is responsible for Internet traffic. At least I don't know it.

 

aleister Crowley: if you download all in home/downloads, you can create some folders there for each downloading application (Safari, JDownloader...), the script checks the folder and its subfolders.

Link to comment
Share on other sites

Because i dont know which prog (part of OS) is responsible for Internet traffic. Outgoing traffic = Finder, Incoming = AppleFileServer (hope i dont confuse it :P), but "Internet" traffic ... ?? ...:P

 

What i mean is that jdownloader for example produce "Traffic". But the Script forces Sleep. Shouldnt the Script stop?

It works fine with other Network Activities like Streaming, utorrent etc. Why not jdownlaoder Traffic?

Link to comment
Share on other sites

PleaseSleeep hidden features

do not sleep if CPU idle state is less than x

 

to all you who use PleaseSleep as I do.

I have talked to the developers and you can add some hidden feature to prevent sleep if CPU activity is more than x.

 

Just edit its plist in User/You/Library/Preferences/com.dragonone.PleaseSleep.com and add keys

"CPULoad" as Boolean , and "CPUThreshold" as integer, if not already in the plist.

 

or use terminal with

 

$ defaults write com.dragonone.PleaseSleep CPULoad -bool true

 

$ defaults write com.dragonone.PleaseSleep CPUThreshold -int 3

 

As this is unsupported, you should check what CPUThreshold value is right for you.

I use value 3, that ensures that my system does not sleep if Finder does some copying work and/or some download jobs are still active.

 

Restart the app to make it read new values!

 

 

Hope this will help anybody, as it helped me.

 

Cheers

Link to comment
Share on other sites

PleaseSleeep hidden features

do not sleep if CPU idle state is less than x

 

to all you who use PleaseSleep as I do.

I have talked to the developers and you can add some hidden feature to prevent sleep if CPU activity is more than x.

 

Just edit its plist in User/You/Library/Preferences/com.dragonone.PleaseSleep.com and add keys

"CPULoad" as Boolean , and "CPUThreshold" as integer, if not already in the plist.

 

or use terminal with

 

$ defaults write com.dragonone.PleaseSleep CPULoad -bool true

 

$ defaults write com.dragonone.PleaseSleep CPUThreshold -int 3

 

As this is unsupported, you should check what CPUThreshold value is right for you.

I use value 3, that ensures that my system does not sleep if Finder does some copying work and/or some download jobs are still active.

 

Restart the app to make it read new values!

 

 

Hope this will help anybody, as it helped me.

 

Cheers

 

mhh.. i dont have this .plist on SnowLeo. so the Terminal commands wont work

 

but wait, you dont mean this Script here? You mean the App Please Sleep ? I made a Test with this App and this Script works by far better/more Vanilla

Link to comment
Share on other sites

 Share

×
×
  • Create New...