nosleep
nosleep copied to clipboard
Doesn't work under macOS Catalina
MacBook Pro goes to sleep 15 seconds after closing the lid with NoSleep enabled.
Is there still no solution to this problem? Is this project still being maintained?
I switched to Hammerspoon and replicated the functionality with the following script:
-- Menu bar icon for keeping Mac from sleeping when closing lid
local noSleep = hs.menubar.new()
local noSleepState = false
hs.execute("sudo pmset -b disablesleep 0")
function setNoSleepDisplay(state)
if state then
noSleep:setIcon("ZzActive.pdf")
else
noSleep:setIcon("ZzInactive.pdf")
end
end
function noSleepClicked()
if noSleepState then
hs.execute("sudo pmset -b disablesleep 0", true)
noSleepState = false
else
hs.execute("sudo pmset -b disablesleep 1", true)
noSleepState = true
end
setNoSleepDisplay(noSleepState)
end
if noSleep then
noSleep:setClickCallback(noSleepClicked)
setNoSleepDisplay(false)
end
You have to copy ZzActive.pdf
and ZzInactive.pdf
from /Applications/NoSleep.app/Contents/Resources
over to ~/.hammerspoon
for it to work.
I stayed on Mojave so I don't know if it works with Catalina. Anyone who wants to test this on Catalina, please let us know.
EDIT: I forgot that you also have to add the following lines to /etc/sudoers/
via visudo
for this to work:
yourusername ALL = (root) NOPASSWD: /usr/bin/pmset -b disablesleep 0
yourusername ALL = (root) NOPASSWD: /usr/bin/pmset -b disablesleep 1
Thanks for the solution. I switched to Amphetamine and it works like a charm (plus it is free as well).