Skip to content

Instantly share code, notes, and snippets.

@SteffenDE
Forked from nikcub/Spotify.scpt
Created August 23, 2014 14:17
Show Gist options
  • Save SteffenDE/6fe12c6006465b582920 to your computer and use it in GitHub Desktop.
Save SteffenDE/6fe12c6006465b582920 to your computer and use it in GitHub Desktop.
--Mute Spotify when ads are playing. Use if in a country where you can't
--purchase a pro account. Open AppleScript editor (Applications > Utilities)
--paste this script in and then go File -> Save As, change 'File Format' to
--'Application' and save somewhere. Run Spotify using that application.
set currentTrack to ""
do shell script "open -a \"Spotify\""
delay 5
repeat while appIsRunning("Spotify")
tell application "Spotify"
if player state is playing then
if get sound volume > 0 then
set defVolume to sound volume
else
set defVolume to 60
end if
set currentTrack to current track
if currentTrack's name is "Spotify" then
set sound volume to 0
else
set sound volume to defVolume
end if
end if
end tell
delay 2
end repeat
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment