Skip to content

Instantly share code, notes, and snippets.

@jmlacroix
Created April 14, 2010 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jmlacroix/366061 to your computer and use it in GitHub Desktop.
Save jmlacroix/366061 to your computer and use it in GitHub Desktop.
Small bash script to prevent iTunes from opening when pressing media keys to control other applications such as Ecoute.
#!/bin/bash
IPATH="/Applications/iTunes.app/Contents/MacOS"
if [ ! -e "$IPATH/iTunesX" ]
then
sudo mv "$IPATH/iTunes" "$IPATH/iTunesX"
# has sudo failed?
if (( $? ))
then
exit
fi
sudo cat > "$IPATH/iTunes" <<-'EOF'
#!/bin/bash
PROCESS=$(ps aux | grep Ecoute | egrep -v "grep|Ecoute Helper")
if [ -z "$PROCESS" ]
then
"/Applications/iTunes.app/Contents/MacOS/iTunesX" &
disown %1
fi
EOF
sudo chmod uog+x "$IPATH/iTunes"
else
echo "Already patched."
fi
@remi
Copy link

remi commented Apr 14, 2010

I modified it to also check if VLC is running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment