<?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>Jkx@home &#187; spotify</title>
	<atom:link href="http://www.larsen-b.com/tags/spotify/feed" rel="self" type="application/rss+xml" />
	<link>http://www.larsen-b.com</link>
	<description>Titanium Exposé</description>
	<lastBuildDate>Wed, 20 May 2026 16:33:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Howto : Change Spotify font size (for 42&#8243; TV display)</title>
		<link>http://www.larsen-b.com/Article/446.html</link>
		<comments>http://www.larsen-b.com/Article/446.html#comments</comments>
		<pubDate>Wed, 16 Jan 2013 13:48:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hifi]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[spotify]]></category>

		<guid isPermaLink="false">http://www.larsen-b.com/?p=446</guid>
		<description><![CDATA[I use Spotify for my every day listening, and I decided to use it on a big screen : My 42&#8243; LCD TV. Simply launch Spotify in a one-line .xinitrc script. It fit perfectly in full screen mode without any tweak. But &#8230; <a href="http://www.larsen-b.com/Article/446.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I use <a title="spotify.com" href="http://www.spotify.com">Spotify</a> for my every day listening, and I decided to use it on a big screen : My 42&#8243; LCD TV. Simply launch Spotify in a one-line .xinitrc script. It fit perfectly in full screen mode without any tweak. But of course nothing is perfect,  we have to live with a very small font on a such big screen. Spotify use a skin for the client app, so changing QT4 fonts doesn&#8217;t change anything, we have to fix the skin directly.</p>
<p>So, first step : search the file <em>resources.zip</em> (in <em>/opt/spotify/spotify-client/Data/</em> on Debian). Extract the file <strong>skin.xml</strong>. In this file, search for line like this.</p>
<pre>&lt;font ci="FriendsListFont" color="#dddddd" shadow="#333333" size="11" /&gt;</pre>
<p>So change all font sizes, save the file, re-pack the ressources file .. and Voila. You can fix this manually (or with a special XML editor), but the file contain 245 font definitions. I decided to fix with a <a href="http://www.python.org">Python</a> script.</p>
<pre>
<strong>import</strong> <font color="#2040a0">xml</font>.<font color="#2040a0">etree</font>.<font color="#2040a0">ElementTree</font> <font color="#2040a0">as</font> <font color="#2040a0">xml</font>

<font color="#2040a0">tree</font> <font color="4444FF">=</font> <font color="#2040a0">xml</font>.<font color="#2040a0">parse</font><font color="4444FF">(</font><font color="#008000">&quot;./skin.xml&quot;</font><font color="4444FF">)</font>
<font color="#2040a0">root</font> <font color="4444FF">=</font> <font color="#2040a0">tree</font>.<font color="#2040a0">getroot</font><font color="4444FF">(</font><font color="4444FF">)</font>

<strong>for</strong> <font color="#2040a0">f</font> <strong>in</strong> <font color="#2040a0">root</font>.<font color="#2040a0">findall</font><font color="4444FF">(</font><font color="#008000">'font'</font><font color="4444FF">)</font><font color="4444FF">:</font>
	<font color="#2040a0">taille</font> <font color="4444FF">=</font> <font color="#2040a0">f</font>.<font color="#2040a0">get</font><font color="4444FF">(</font><font color="#008000">'size'</font><font color="4444FF">)</font>
	<strong>if</strong> <font color="#2040a0">taille</font><font color="4444FF">:</font>
		<font color="#2040a0">taille</font> <font color="4444FF">=</font> <font color="#2040a0">int</font><font color="4444FF">(</font><font color="#2040a0">taille</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="#FF0000">4</font>
		<font color="#2040a0">f</font>.<font color="#2040a0">set</font><font color="4444FF">(</font><font color="#008000">'size'</font>,<font color="#2040a0">str</font><font color="4444FF">(</font><font color="#2040a0">taille</font><font color="4444FF">)</font><font color="4444FF">)</font>


<font color="#2040a0">file</font> <font color="4444FF">=</font> <font color="#2040a0">open</font><font color="4444FF">(</font><font color="#008000">&quot;new_skin.xml&quot;</font>, <font color="#008000">'w'</font><font color="4444FF">)</font>

<font color="#2040a0">xml</font>.<font color="#2040a0">ElementTree</font><font color="4444FF">(</font><font color="#2040a0">root</font><font color="4444FF">)</font>.<font color="#2040a0">write</font><font color="4444FF">(</font><font color="#2040a0">file</font><font color="4444FF">)</font>

</pre>
<p>Let&#8217;s try this new skin :  <a style="font-style: normal; line-height: 24px; text-decoration: underline;" href="http://jkx.larsen-b.com/gallery/blog/big_spotify?full=1"><img class="alignnone" alt="" src="http://jkx.larsen-b.com/photos/blog/big_spotify.sized.jpg" width="640" height="433" /></a></p>
<p>This should be a easier for the big screen :)</p>
<p><strong>/Enjoy music</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.larsen-b.com/Article/446.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Change the default sound card in Spotify : Alsa + Monkey Patching</title>
		<link>http://www.larsen-b.com/Article/425.html</link>
		<comments>http://www.larsen-b.com/Article/425.html#comments</comments>
		<pubDate>Sat, 08 Dec 2012 13:12:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[alsa]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[spotify]]></category>

		<guid isPermaLink="false">http://www.larsen-b.com/?p=425</guid>
		<description><![CDATA[I&#8217;m a long time Spotify user right now. I decided to opt for a unlimited account due to the price. The main issue : Spotify for Linux is a closed source software, doesn&#8217;t allow the user to change the sound &#8230; <a href="http://www.larsen-b.com/Article/425.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m a long time <a href="http://www.spotify.com">Spotify</a> user right now. I decided to opt for a unlimited account due to the price. The main issue : Spotify for Linux is a closed source software, doesn&#8217;t allow the user to change the sound card and I want to use my <a href="http://www.larsen-b.com/Article/414.html">almost finished USB DAC</a>.</p>
<p>In fact, if you use <a href="http://jackaudio.org/">Jackd</a> (and perhaps Pulse) you can change the sound card used by Spotify, but this is overkill for my needs (mainly cause, I use Spotify on a litte old netbook and Jackd is a nightmare to configure)</p>
<p>After some strace dump, Alsa (libasound2) source reading, I decided to fix it by myself. Let&#8217;s go for some <a href="http://en.wikipedia.org/wiki/Monkey_patch">Monkey Patching</a>. Monkey patching on closed source binary isn&#8217;t that easy, the hard step : find the right function to hack. Here the<a href="http://equalarea.com/paul/alsa-audio.html"> Alsa tutorial</a> come to rescue (ldd of course too). So we need to modify the <em>snd_pcm_open</em> call.</p>
<p>Let&#8217;s give it a try : First we need to dynamically re-route this call to a wrapper. The easier way to do this, is to build a special library and to force Spotify to use the wrapper with an <a href="http://en.wikipedia.org/wiki/Dynamic_linker">LD_PRELOAD</a> hack. (see code below). In fact, Spotify call the <em>snd_pcm_open</em> with <em>name=&#8221;default&#8221;</em> which is the default sound card, so we can change this to &#8220;usb&#8221; for example, and fix the .asoundrc to point &#8220;usb&#8221; sound card to the right hardware card.</p>
<p>That&#8217;s enough, let&#8217;s code :</p>
<pre>
<font color="0000ff"><strong>#define _GNU_SOURCE</strong></font>

<font color="0000ff"><strong>#include <font color="#008000">&lt;dlfcn.h&gt;</font></strong></font>
<font color="0000ff"><strong>#include <font color="#008000">&lt;stdio.h&gt;</font></strong></font>
<font color="0000ff"><strong>#include <font color="#008000">&lt;alsa/asoundlib.h&gt;</font></strong></font>

<strong>static</strong> <strong>int</strong> <font color="4444FF">(</font><font color="4444FF">*</font><font color="#2040a0">wrap_snd_pcm_open</font><font color="4444FF">)</font><font color="4444FF">(</font><font color="#2040a0">snd_pcm_t</font> <font color="4444FF">*</font><font color="4444FF">*</font><font color="#2040a0">pcm</font>, <strong>const</strong> <strong>char</strong> <font color="4444FF">*</font><font color="#2040a0">name</font>, <font color="#2040a0">snd_pcm_stream_t</font> <font color="#2040a0">stream</font>, <strong>int</strong> <font color="#2040a0">mode</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#2040a0">NULL</font><font color="4444FF">;</font>

<strong>void</strong> <font color="4444FF">*</font> <font color="#2040a0">wrap</font><font color="4444FF">(</font><strong>void</strong> <font color="4444FF">*</font> <font color="#2040a0">func</font>,<strong>char</strong> <font color="4444FF">*</font><font color="#2040a0">name</font><font color="4444FF">)</font>
<font color="4444FF"><strong>{</strong></font>
    <strong>char</strong> <font color="4444FF">*</font><font color="#2040a0">msg</font><font color="4444FF">;</font>
    <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">func</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#2040a0">NULL</font><font color="4444FF">)</font> <font color="4444FF"><strong>{</strong></font>
        <font color="#2040a0">func</font> <font color="4444FF">=</font> <font color="#2040a0">dlsym</font><font color="4444FF">(</font><font color="#2040a0">RTLD_NEXT</font>, <font color="#2040a0">name</font><font color="4444FF">)</font><font color="4444FF">;</font>
        <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">stderr</font>, <font color="#008000">&quot;** wrapping %s =&gt;  %p<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">name</font>,<font color="#2040a0">func</font><font color="4444FF">)</font><font color="4444FF">;</font>
        <strong>if</strong> <font color="4444FF">(</font><font color="4444FF">(</font><font color="#2040a0">msg</font> <font color="4444FF">=</font> <font color="#2040a0">dlerror</font><font color="4444FF">(</font><font color="4444FF">)</font><font color="4444FF">)</font> <font color="4444FF">!</font><font color="4444FF">=</font> <font color="#2040a0">NULL</font><font color="4444FF">)</font> <font color="4444FF"><strong>{</strong></font>
            <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">stderr</font>, <font color="#008000">&quot;** %s: dlopen failed : %s<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">name</font>,<font color="#2040a0">msg</font><font color="4444FF">)</font><font color="4444FF">;</font>
            <font color="#2040a0">exit</font><font color="4444FF">(</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">;</font>
        <font color="4444FF"><strong>}</strong></font> <strong>else</strong> <font color="4444FF"><strong>{</strong></font>
            <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">stderr</font>, <font color="#008000">&quot;** %s: wrapping done<font color="#77dd77">\n</font>&quot;</font>,<font color="#2040a0">name</font><font color="4444FF">)</font><font color="4444FF">;</font>
        <font color="4444FF"><strong>}</strong></font>
    <font color="4444FF"><strong>}</strong></font>
    <strong>return</strong> <font color="#2040a0">func</font><font color="4444FF">;</font>
<font color="4444FF"><strong>}</strong></font>

<strong>int</strong> <font color="#2040a0">snd_pcm_open</font><font color="4444FF">(</font><font color="#2040a0">snd_pcm_t</font> <font color="4444FF">*</font><font color="4444FF">*</font><font color="#2040a0">pcm</font>, <strong>const</strong> <strong>char</strong> <font color="4444FF">*</font><font color="#2040a0">name</font>, <font color="#2040a0">snd_pcm_stream_t</font> <font color="#2040a0">stream</font>, <strong>int</strong> <font color="#2040a0">mode</font><font color="4444FF">)</font>
<font color="4444FF"><strong>{</strong></font>
    <strong>int</strong> <font color="#2040a0">temp</font><font color="4444FF">;</font>

    <font color="#2040a0">sprintf</font><font color="4444FF">(</font><font color="#2040a0">name</font>,<font color="#008000">&quot;usb&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>

    <font color="#2040a0">wrap_snd_pcm_open</font> <font color="4444FF">=</font> <font color="#2040a0">wrap</font><font color="4444FF">(</font><font color="#2040a0">wrap_snd_pcm_open</font>,<font color="#008000">&quot;snd_pcm_open&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
    <font color="#2040a0">temp</font> <font color="4444FF">=</font> <font color="#2040a0">wrap_snd_pcm_open</font><font color="4444FF">(</font><font color="#2040a0">pcm</font>,<font color="#2040a0">name</font>,<font color="#2040a0">stream</font>,<font color="#2040a0">mode</font><font color="4444FF">)</font><font color="4444FF">;</font>
    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">stderr</font>, <font color="#008000">&quot;** Calling snd_pcm_open for path:[%s] =&gt; fd:[%d]<font color="#77dd77">\n</font>&quot;</font>,<font color="#2040a0">name</font>,<font color="#2040a0">temp</font><font color="4444FF">)</font><font color="4444FF">;</font>
    <font color="#2040a0">fflush</font><font color="4444FF">(</font><font color="#2040a0">stderr</font><font color="4444FF">)</font><font color="4444FF">;</font>
    <strong>return</strong> <font color="#2040a0">temp</font><font color="4444FF">;</font>

<font color="4444FF"><strong>}</strong></font>
</pre>
<p>As you can see in the code, I use a generic wrapper function because during my code session, I used this function to re-route some other functions. To build the library :</p>
<pre>gcc -g -fPIC -shared -Wl,-soname,preload.so -ldl -o preload.so  main.c</pre>
<p>Load the lib, with export LD_PRELOAD=./preload.so before running Spotify. Spotify (and all other software using Alsa) will use &#8220;usb&#8221; as default sound card.</p>
<p>Note: C reader will note that name is a const char pointer, and so we can&#8217;t change it, but even if gcc raise a big warning, the code do trick fine.</p>
<p><strong>Enjoy good quality sound even w/ closed source </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.larsen-b.com/Article/425.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
