#!/usr/bin/env python import sys, os, subprocess launch = True ps = subprocess.Popen("/bin/ps -x", shell=True, stdout=subprocess.PIPE) for l in ps.stdout.read().split("\n") : if "Spotify" in l : launch = False ps.stdout.close() if launch : os.spawnvp(os.P_WAIT, '/Applications/iTunes.app/Contents/MacOS/iTunesX',sys.argv) else : print "Not launching iTunes while spotify is running"