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
@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