Skip to content

Instantly share code, notes, and snippets.

@rizkiandrianto
Last active November 7, 2018 15:09
Show Gist options
  • Save rizkiandrianto/55bb2ee312bf3cd98bb298957f94e931 to your computer and use it in GitHub Desktop.
Save rizkiandrianto/55bb2ee312bf3cd98bb298957f94e931 to your computer and use it in GitHub Desktop.
Spotify Timer to Sleep
display dialog "Set minutes before turning off:" default answer "60"
set the time_before_sleep to the text returned of the result
delay time_before_sleep * minutes
tell the application "Spotify"
delay (duration of the current track) - the player position
pause
end tell
tell the application "Finder" to sleep
**SpotifyTimer**
I wrote a script that should work, but the computer needs to be turned on (the screen can be off though) and the separator between hours and minutes must be a colon.
If you want it to wake you up with a specific track or playlist, then you just replace the last line with
tell the application "Spotify" to play track "____________"
where the ____________ is a Spotify URI of some track or a playlist. You can get this URI by right-clicking on a track or playlist inside Spotify and selecting Copy Spotify URI.
Credit: https://server9.kproxy.com/r/mac/comments/1dw6og/i_made_a_sleep_timer_for_spotify_for_those_of_you/
display dialog "When to wake up:" default answer "8:00"
set the wakeup_time to date (the text returned of the result)
if the wakeup_time is less than (the current date) then
set the wakeup_time to the wakeup_time + 1 * days
end if
repeat until (current date) > wakeup_time
delay 10
end repeat
tell the application "Spotify" to play
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment