Spotify Prevents MacOS to Sleep 2020 Fix

Spotify Prevents MacOS to Sleep

Having some time these days – with holidays and stuff – decided to see why my Macbook Pro does not sleep when I close the lid.

The short explanation is that after you open Spotify and play a song, the program will prevent your system to sleep. It’s a very known old bug from 8 years ago now.

spotify prevents mac sleep

There is a relatively quick fix for that:

    1. Install Homebrew – a package manager for Mac:
      /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    2. Install sleepwatcher – it monitors sleep wakeup and idleness of a Mac: brew install sleepwatcher
    3. Create a .sleep file for sleepwatcher to execute when we close the lid. Run the command: echo "osascript -e 'tell application "\"Spotify"\" to quit'" >> ~/.sleep && chmod +x ~/.sleep
    4. (optional) if you want Spotify to resume playing at system wake-up, run this: echo "osascript -e 'tell application "\"Spotify"\" to play'" >> ~/.wakeup && chmod +x ~/.wakeup
    5. Run it as a service. If you don’t have enabled homebrew services, you must run this command brew tap homebrew/services and then run sleepwatcher as a service: brew services start sleepwatcher

That’s all. Now, you can test it by having the Spotify MacOS app running, then close the lid and wait few seconds until the system sleep. Re-open the lid and you should have your Spotify app closed.

Tested on macOS Catalina 10.15.2.

Waiting for your feedback! 🙂




Silviu Stroe

Silviu is a full stack developer and entrepreneur. He is the founder of one of the first VPN services in Romania, RoTunneling and is part of Yahoo - Wall of Fame. He also loves bleeding edge technologies and new challenges.

No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *