I am not that awesome, I have learnt it all here, so you may look at it as a collaborative effort!
Put the call of the
do shell script "SleepDisplay -w"
my logit("The call of SleepDisplay went good from the mailrule","heavymailrule")
between the try - on error clauses.
And yes, on = to. I must also stress that it is important to get output from the logit handler into the file, also after the 30 mins: It is just a silly hypothesis I have; when some time has passed, “something” goes to sleep, and the privileges of your mail rule takes over.
To see that the logit handler indeed also works after 30 mins is important, because the next step is to create a userAgent, that is installed with launchd (I’ll make and test everything.), that watches a watchpath, and then triggers the SleepDisplay, and makes the screen wake up, indirectly, since it is a created file that triggers the whole thing. The UserAgent, runs under Launchd, without any sandboxing of any kind.
But, we’ll have to proceed with the steps that are described so far, in the hope that we don’t have to do the last stunt.
I hope you haven’t read the post above, and I post this separately, for the case that you have, so you see “news” before you start waiting for 30 minutes.
Make the codeblock like this. (The finder block is there for the hope that it will remove any “sandboxing”)
try
tell application "Finder"
do shell script "SleepDisplay -w"
my logit("The call of SleepDisplay went good from the mailrule", "heavymailrule")
end tell
on error e number n
my logit("An error ocurred while trying to fire off Display watcher:" & e & " " & n, "heavymailrule")
end try
My question about the try block was actually in regards to the e and n variables. What values will those be set to? For my future error trapping needs.
e will be set to the errormessage eventually gives you. n will be set to the error number, that are described in a table, usually the same as the message, but may be helpful.
Earier you were asking about if there was a different mode. Could having the hard disk spin down have any effect on your script. If you want to try, go to your preferences and have it not spin down for testing. Here’s an article I was reading:
Another thing I was thinking about is that you might try using ‘with timeout’ especially around your application tell blocks. For the amount of seconds use a big number.