1. Does the below code still apply?
2. Can I use it for Windows?
3. Does it also prevent screensaver coming up (after inactivity)
Thanks for any help
Code: Select all
function sleepTime
return shell("pmset -g | grep displaysleep | awk '{ print $2; }'")
end sleepTime
on setSleepTime theMins
ask "Enter your password"
if it is not empty then
put it into myPW
put "#!/bin/sh" & cr into myScript
put "pw=" & quote & myPW & quote & cr after myScript
put "echo $pw | sudo pmset dim " & theMins & cr after myScript
put myscript
put shell(myScript) into rslt -- do the command & get the result
if rslt is not empty then
beep
answer error "Sorry, a problem occurred." & cr & cr & rslt with "Okay"
end if
end if
end setSleepTime
on setSleepTimeAS theMins
put "sudo pmset dim " & theMins into myShell
put "try" & cr & ¬
"do shell script" && quote & myShell & quote && "with administrator privileges" & cr & ¬
"on error myErr number myErrNr" & cr & ¬
"set myErrMsg to myErr & ' (' & myErrNr & ')'" & cr & ¬
"end try" into myScript
replace "'" with quote in myScript
do myScript as AppleScript
put the result into rslt
if rslt is not empty and rslt is not (quote & quote) and "(-128)" is not in rslt then
beep
answer error "Sorry, a problem occurred." & cr & cr & rslt with "Okay"
end if
end setSleepTimeAS