So there I lay in bed wishing Spotify had a sleep timer. Alas it did not. But! I do have a tiny bit of ingenuity and know-how so I decided to take matters into my own hands. Apple provides a platform for developers to expose functionality of their app programmatically through AppleScript. This allows a very low entry point for anyone to write small scripts to accomplish tasks with the apps they use that those apps may not take care of themselves.
I wanted a Spotify sleep timer. So I made a Spotify sleep timer.
5 minutes later I had a perfectly functional sleep timer for Spotify on Mac. It's an incredibly simple script that just asks the user how many minutes would they like Spotify to play until the script tells Spotify to stop. You could modify this script to go by hours if you want. I'll leave that up to you to figure out. The script can be run through the Services menu in the Spotify toolbar.
The steps to install this script are pretty straight forward:
- Open Automator
- Create a new "Service" project
- (1) Add the "Run an AppleScript" action to the workflow by finding it in the search bar and then double clicking the result
- (2) Select "no input" from the "Service receives" drop box.
- (3) Select "other" from the application drop box and select Spotify from your applications folder.
- (4) Copy and paste the code above in the box.
- Save as Spotify Sleep
- Restart Spotify
- Click "Spotify" in the toolbar and go down to "Services" and select "sleepSpotify"
- Follow prompts
- Go to sleep listening to music
Hope you enjoy this little script! If you use it, leave me a comment on this post and let me know. Thanks! And don't forget, if you want something done that someone else hasn't done yet, DO IT YOURSELF!