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).