Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work under macOS Catalina #46

Open
mattjonsson opened this issue Oct 8, 2019 · 3 comments
Open

Doesn't work under macOS Catalina #46

mattjonsson opened this issue Oct 8, 2019 · 3 comments

Comments

@mattjonsson
Copy link

MacBook Pro goes to sleep 15 seconds after closing the lid with NoSleep enabled.

@oddguan
Copy link

oddguan commented May 28, 2020

Is there still no solution to this problem? Is this project still being maintained?

@dschuessler
Copy link

dschuessler commented May 28, 2020

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

@oddguan
Copy link

oddguan commented May 29, 2020

Thanks for the solution. I switched to Amphetamine and it works like a charm (plus it is free as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants