I'm trying to do an Applescript to enable or not SleepDisabled (using pmset) depending on the state of SleepDisabled.
Something like :
set SuperSleep to do shell script "return status of SleepDisabled"
if SuperSleep is equal to "0" then
do shell script "sudo pmset -a disablesleep 1" user name "Myname" password "Mypassword" with administrator privileges
else
do shell script "sudo pmset -a disablesleep 0" user name "Myname" password "Mypassword" with administrator privileges
I tried looking into man psmet
or using defaults read
but no success.
The only thing I'm thinking of is using pmset -g
to shows up this :
System-wide power settings:
SleepDisabled 0
Currently in use:
lidwake 1
autopoweroff 1
standbydelayhigh 86400
autopoweroffdelay 28800
standbydelaylow 10800
standby 1
proximitywake 0
ttyskeepawake 1
hibernatemode 3
powernap 0
gpuswitch 2
hibernatefile /var/vm/sleepimage
highstandbythreshold 50
displaysleep 2
sleep 2 (sleep prevented by coreaudiod, coreaudiod)
tcpkeepalive 1
halfdim 1
acwake 0
disksleep 10
And then look up the status of SleepDisabled on the list, but I don't know how to return the "0" or "1" of SleepDisabled...