Created
October 30, 2009 16:49
-
-
Save jasonmadigan/222516 to your computer and use it in GitHub Desktop.
Block iTunes (or other apps) from opening when Spotify is open. Gets rid of that pesky "oh you hit the play button? Better open iTunes" behaviour.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Blocks iTunes from launching if Spotify is open | |
# Installation: | |
# sudo ruby -e "$(curl -fsS https://raw.github.com/gist/613045/b12123d5e25d446038e6300bf54d2121bf180c34)" | |
blockers = ["Spotify"] | |
launch = true | |
blocker_name = "" | |
IO.popen("/bin/ps -x") do |output| | |
while process = output.gets do | |
blockers.each do |blocker| | |
if process.include?(blocker) | |
launch = false | |
blocker_name = blocker | |
end | |
end | |
end | |
end | |
if launch | |
spawn = fork do | |
%x['/Applications/iTunes.app/Contents/MacOS/iTunesReal'] | |
exit | |
end | |
else | |
puts "Not launching, #{blocker_name} process found." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment