• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Inhibiting Sleep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inhibiting Sleep


  • Subject: Re: Inhibiting Sleep
  • From: Luther Fuller <email@hidden>
  • Date: Wed, 12 Jun 2013 10:02:20 -0500

The complete script is included at the end.
I've never used 'TERM' in a 'kill' so I removed that.
Before testing my script, I set Energy Saver so that Computer Sleep = Display Sleep = 5 min.
I launched the my Timer application, set "minutes to alarm' to 10.
Clicked "OK" in the "Begin" dialog.
And waited.

At 10min, the alarm sounded.
I checked pmset in Activity Monitor and found that it had been killed properly.

This script seems to work correctly.
Exactly what is 'pmset noidle' doing while active? It's not clear to me.

on run
repeat
tell application "Finder"
activate
display dialog "Enter minutes until alarm ..." default answer 1 buttons {"Cancel", "Start"} default button 2
end tell
try
set minToAlarm to (text returned of the result) as integer
if minToAlarm > 0 then exit repeat
end try
end repeat
set alarmTime to ((current date) + 60 * minToAlarm) -- adding seconds
---------------------------------
try
do shell script "pmset noidle >/dev/null 2>&1 & echo $!" --****************
set pid to the result
on error errtext number errNr
"Error = " & errNr & return & errtext
display dialog the result buttons {"OK"} default button 1
return
end try
display dialog "Begin time out ..."
---------------------------------
repeat
if (current date) > alarmTime then exit repeat
delay 10
end repeat


do shell script "kill " & pid --*******************


repeat 20 times
beep
delay 1
end repeat
end run


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Inhibiting Sleep (From: Luther Fuller <email@hidden>)
 >Re: Inhibiting Sleep (From: Lists <email@hidden>)
 >Re: Inhibiting Sleep (From: Luther Fuller <email@hidden>)
 >Re: Inhibiting Sleep (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: The latest AS date and AS Editor bugs
  • Next by Date: Re: Inhibiting Sleep
  • Previous by thread: Re: Inhibiting Sleep
  • Next by thread: Re: Inhibiting Sleep
  • Index(es):
    • Date
    • Thread