<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Maarten den Braber &#187; Geek stuff</title>
	<atom:link href="http://mdbraber.com/category/geek-stuff/feed/" rel="self" type="application/rss+xml" />
	<link>http://mdbraber.com</link>
	<description>mobile / tech / healthcare / events</description>
	<lastBuildDate>Mon, 21 Dec 2009 14:42:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Stop iTunes from launching when pressing the Play/Pause button on your keyboard</title>
		<link>http://mdbraber.com/2009/10/21/stop-itunes-from-launching-when-pressing-the-playpause-button-on-your-keyboard-snow-leopard/</link>
		<comments>http://mdbraber.com/2009/10/21/stop-itunes-from-launching-when-pressing-the-playpause-button-on-your-keyboard-snow-leopard/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 16:38:57 +0000</pubDate>
		<dc:creator>Maarten den Braber</dc:creator>
				<category><![CDATA[Geek stuff]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[play]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[spotify]]></category>

		<guid isPermaLink="false">http://mdbraber.com/?p=227</guid>
		<description><![CDATA[
With the introduction of Mac OS X 10.6 (Snow Leopard) many cool features were introduced and at least one not so cool feature: whenever you press the Play/Pause button your keyboard when you have e.g. Spotify running, it opens up iTunes. Anyway, nothing we cannot solve with a little hacking, right?
First start by downloading this [...]]]></description>
			<content:encoded><![CDATA[<p><a class="post_image_link" href="http://mdbraber.com/2009/10/21/stop-itunes-from-launching-when-pressing-the-playpause-button-on-your-keyboard-snow-leopard/" title="Permanent link to Stop iTunes from launching when pressing the Play/Pause button on your keyboard"><img class="post_image alignright" src="http://mdbraber.com/wp-content/uploads/playpause.jpg" width="240" height="154" alt="photo by lordgoroth" /></a>
</p><p>With the introduction of Mac OS X 10.6 (Snow Leopard) many cool features were introduced and at least one not so cool feature: whenever you press the Play/Pause button your keyboard when you have e.g. Spotify running, it opens up iTunes. Anyway, nothing we cannot solve with a little hacking, right?</p>
<p>First start by downloading <a href="http://mdbraber.com/wp-content/uploads/iTunes.py">this script</a> and save it somewhere on your computer.  (DISCLAIMER: This script was taking from <a href="http://discussions.apple.com/thread.jspa?threadID=2122639&amp;start=90&amp;tstart=0">this thread</a> on Apple Discussions). The contents of the script are listed below. When the script is launched it checks if another program that uses the multimedia keys is running. If there is it ignores the request to start iTunes, otherwise it simply proceeds with starting iTunes. You can change the <tt>apps</tt> setting to list more apps that you want to prevent iTunes from launching.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>, <span style="color: #dc143c;">os</span>, <span style="color: #dc143c;">subprocess</span>
&nbsp;
launch = <span style="color: #008000;">True</span>
blocker = <span style="color: #483d8b;">&quot;&quot;</span>
apps = <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;Ecoute&quot;</span>, <span style="color: #483d8b;">&quot;Spotify&quot;</span>, <span style="color: #483d8b;">&quot;Songbird&quot;</span>, <span style="color: #483d8b;">&quot;Mplayer OSX Extended&quot;</span>, <span style="color: #483d8b;">&quot;Mplayer&quot;</span><span style="color: black;">&#93;</span>
&nbsp;
ps = <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/bin/ps -x&quot;</span>, shell=<span style="color: #008000;">True</span>, stdout=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> ps.<span style="color: black;">stdout</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> app <span style="color: #ff7700;font-weight:bold;">in</span> apps:
                <span style="color: #ff7700;font-weight:bold;">if</span> app <span style="color: #ff7700;font-weight:bold;">in</span> line:
                        launch = <span style="color: #008000;">False</span>
                        blocker = app
&nbsp;
ps.<span style="color: black;">stdout</span>.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> launch :
        <span style="color: #dc143c;">os</span>.<span style="color: black;">spawnvp</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">P_WAIT</span>, <span style="color: #483d8b;">'/Applications/iTunes.app/Contents/MacOS/iTunesX'</span>, <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">else</span> :
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Not launching iTunes while %s is running.&quot;</span> <span style="color: #66cc66;">%</span> blocker</pre></div></div>

<p>Next issue the following commands in a Terminal (of course replace <tt> &lt;downloaded-script-location&gt;</tt> with the directory where you downloaded the script to (e.g. <tt>/Users/myname/Downloads</tt>).</p>
<pre>cd /Application/iTunes.app/Contents/MacOS
sudo mv iTunes iTunesX
sudo mv &lt;downloaded-script-location&gt;/iTunes.py iTunes
sudo chown root:admin iTunes
sudo chmod 0755 iTunes</pre>
<p>Et voila, this should fix it. You can check by opening up Console to check the logs for the message &#8220;Not launching iTunes while  is running&#8221;.</p>
<p>Comments, tips and suggestions welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://mdbraber.com/2009/10/21/stop-itunes-from-launching-when-pressing-the-playpause-button-on-your-keyboard-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>
