Skip to content

Instantly share code, notes, and snippets.

@ngopal
Created August 13, 2012 21:02
Show Gist options
  • Save ngopal/3344086 to your computer and use it in GitHub Desktop.
Save ngopal/3344086 to your computer and use it in GitHub Desktop.
Setup your mac to use Spotify as your alarm clock
# In order to use this script, you must replace 'YOURUSERNAMEHERE' with your Spotify username.
# Execute this script like so: 'osascript alarm_clock_spotify.scpt' (without single-quotes obviously)
# Full explanation here: http://www.nikhilgopal.com/2011/08/show-and-tell-applescript-spotify-alarm.html
# If you would like to specify a playlist, please refer to this gist: https://gist.github.com/3344118
set volume 2
open location "spotify:user:YOURUSERNAMEHERE:playlist:muzic"
tell application "Spotify"
set the sound volume to 0
play
repeat 10 times
if sound volume is less than 80 then
set sound volume to (sound volume + 10)
delay 3
end if
end repeat
end tell
@paulcgt
Copy link

paulcgt commented Nov 15, 2016

@matheus-santos
Copy link

Kudos man! Exactly what I was looking for.

@sam0per
Copy link

sam0per commented Nov 26, 2018

line 7 did not really work for me but I solved it doing the following:
In the Spotify app, right click on the playlist you want to listen to --> Share --> Copy Spotify URI
substitute the string between quotes after open location (line 7) with the copied Spotify URI

@amonkhepri
Copy link

When I paste this snippet in terminal I get "zsh: parse error near `end'"

@JanProgrammierung
Copy link

JanProgrammierung commented Mar 27, 2022

First, big kudos for the explanation!
I try setting it up right now, but on your website (https://nikhilgopal.com/2011/08/03/show-and-tell-applescript-a-spotify-alarm-clock-on-mac/) I cannot see the pic with the code for the VI editor. Could you post the code line here?

@jamesboonstra
Copy link

Open a terminal window and type EDITOR=nano crontab -e to enter cron editor.
Then add this line of code 55 6 * * * osascript /path-to-file/alarm_clock_spotify.scpt Click ctrl+x to exit, then click y to save. It should run automatically at this time now
The numbers 55 refer to the minute it will run, and the number 6 refers to the hour it will be run. Change these however you would like.

Screen Shot 2022-10-26 at 11 22 47 AM

If you want to learn more about cron and how to set the time, there is a good guide here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment