I am quite a newbie when it comes to applescripting so please bear with me.
I am running this script - Narcolepsy 2.0 on my iMac to make sleep work properly. If I don’t use it, my iMac will not go to sleep…
But it has side effects. It does not detect when I am accessing a file (a tv recording) on the iMac from my media center. It goes to sleep…
The easy fix would be to extend the period in which the iMac will NOT go to sleep (in System Preferences), but is there another way?
Is it possible to have applescript detect if the iMac receives a magic packet (wake on lan) and then prevent sleep?
So as for stopping Narcolepsy from sleeping your mac, get it to start itunes. Apparently that stops it. As for detecting network activity, how’s this:
set in1 to do shell script "(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | grep lastTxRate: | sed 's/.*: //')"
--(ifconfig en0 | grep media: | sed 's/.*(//' | sed 's/ .*//') for wired network
set in1 to in1 as number
if in1 < 70 then -- That's MBit/s
--atm, there is little network activity.
else
--atm, there is more network activity.
end