← all writing

Automatically pausing Spotify on macOS

I really enjoy listening to some good music before sleeping. But the question is who will stop the music once you fall asleep, right? If you’re using iPhone you can schedule a timer which will stop playing after time elapses.

iPhone Clock app timer screen set to Stop Playing after 20 minutes

But what if you want to have the same functionality on Macbook too? Well, I was missing this feature so I decided to create a simple Bash script that uses AppleScript to stop Spotify playing after a defined time.

Terminal command line interface showing a prompt to set a 20 minute sleep timer for Spotify playback

You can find the source code on Github.