<?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>blog.tordeu.com &#187; Uncategorized</title>
	<atom:link href="http://blog.tordeu.com/?cat=1&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.tordeu.com</link>
	<description>a blog about stuff</description>
	<lastBuildDate>Thu, 25 Apr 2013 07:03:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.2</generator>
		<item>
		<title>Digikam crashes on Debian</title>
		<link>http://blog.tordeu.com/?p=423</link>
		<comments>http://blog.tordeu.com/?p=423#comments</comments>
		<pubDate>Tue, 18 Dec 2012 11:58:29 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=423</guid>
		<description><![CDATA[Today I thought it&#8217;s time to install digikam and play with it. I was using digikam when I was still on Ubuntu and compared to F-Spot and Shotwell, digikam was way way superior when it comes to tag management. Of course I immediately ran sudo aptitude install digikam and installed diigkam 2.6.0 along with its <a href='http://blog.tordeu.com/?p=423'>[...]</a>]]></description>
				<content:encoded><![CDATA[<p>Today I thought it&#8217;s time to install digikam and play with it. I was using digikam when I was still on Ubuntu and compared to F-Spot and Shotwell, digikam was way way superior when it comes to tag management.</p>
<p>Of course I immediately ran</p>
<pre>sudo aptitude install digikam</pre>
<p>and installed diigkam 2.6.0 along with its necessary dependencies.</p>
<p>&nbsp;</p>
<h2>The Problem</h2>
<p>Then I just ran</p>
<pre>digikam</pre>
<p>and I started, asked me some useful questions and then greeted me with:</p>
<pre>QSqlDatabasePrivate::removeDatabase: connection 'ConnectionTest' is still in use, all queries will cease to work.
[0x2f86b90] main services discovery error: no suitable services discovery module
digikam: symbol lookup error: /usr/lib/qt4/plugins/phonon_backend/phonon_vlc.so: undefined symbol: libvlc_audio_filter_list_get</pre>
<p>Normally I don&#8217;t pay attention to the messages in the terminal after starting a program (Hello, Iceweasel), but digikam was nice enough to crash, so that I would not distract me from the error message. How kind.</p>
<p>&nbsp;</p>
<h2>The Solution</h2>
<p>When looking at the error message, you can see that the file &#8220;/usr/lib/qt4/plugins/phonon_backend/phonon_vlc.so&#8221; plays some role here. And playing around with aptitude you can find a package named &#8220;phonon-backend-vlc&#8221;. The package name matches the file having the problem quite nicely. I am convinced now, that the solution is to remove the package (be sure you do not need it):</p>
<p>sudo aptitude remove phonon-backend-vlc</p>
<p>Aptitude might then suggest to remove a bunch of other stuff as well (digikam among them), which I find counter-productive. So I just enter &#8220;n&#8221; the first few times until I am satisfied with the solution aptitude offers me:</p>
<pre>The following actions will resolve these dependencies:

     Install the following packages:                   
1)     phonon-backend-gstreamer [4:4.6.0.0-2 (testing)]</pre>
<p>That does not sound too bad, so I accept it.</p>
<p>When aptitude is done removing the phonon-backend-vlc package, I try it again:</p>
<pre>digikam</pre>
<p>And now it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=423</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error: PHP Startup: Unable to load dynamic library &#8216;/usr/lib/php5/20100525/suhosin.so&#8217; [Debian Wheezy]</title>
		<link>http://blog.tordeu.com/?p=417</link>
		<comments>http://blog.tordeu.com/?p=417#comments</comments>
		<pubDate>Sun, 16 Sep 2012 21:35:57 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[suhosin]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=417</guid>
		<description><![CDATA[The Problem Chances are you have seen the following error message (or else you would probably not have found this post): Error: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/suhosin.so' - /usr/lib/php5/20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown, line 0 I hope I am not the only one who <a href='http://blog.tordeu.com/?p=417'>[...]</a>]]></description>
				<content:encoded><![CDATA[<h2>The Problem</h2>
<p>Chances are you have seen the following error message (or else you would probably not have found this post):</p>
<pre>Error: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/suhosin.so' -
/usr/lib/php5/20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown, line 0</pre>
<p>I hope I am not the only one who lived with this message for a while, because everything was working as expected. But even though I never noticed any real problem, the message surely gets on your nerve after a while, so it&#8217;s time to make it go away&#8230;</p>
<p>&nbsp;</p>
<h2>The Solution</h2>
<p>The solution is actually very easy. As mentioned on the <a title="Solution on the Debian Bug Tracking System" href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666911">Debian Bug Tracking System</a> ages ago, all you need to do is to purge the suhosin package (the php5-suhosin package, to be precise):</p>
<p>sudo aptitude purge php5-suhosin</p>
<p>(In case you have not <a title="How to enable sudo in Linux (here: Debian Squeeze)?" href="http://blog.tordeu.com/?p=31">enabled sudo</a>, just do the usual and run this command as superuser without the sudo.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=417</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Using a HTML5 based video player on Youtube instead of Flash</title>
		<link>http://blog.tordeu.com/?p=388</link>
		<comments>http://blog.tordeu.com/?p=388#comments</comments>
		<pubDate>Fri, 07 Sep 2012 06:00:00 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Youtube]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=388</guid>
		<description><![CDATA[This will be a very short post. If you want to use the HTML5 based video player on Youtube instead of the Flash based one (which is presented to you by default), then you just need to follow these simple steps: Enabling HTML5 Go to http://www.youtube.com/html5 and at the bottom you will see this: Here <a href='http://blog.tordeu.com/?p=388'>[...]</a>]]></description>
				<content:encoded><![CDATA[<p>This will be a very short post. If you want to use the HTML5 based video player on Youtube instead of the Flash based one (which is presented to you by default), then you just need to follow these simple steps:</p>
<h2></h2>
<h2>Enabling HTML5</h2>
<p>Go to <a href="http://www.youtube.com/html5">http://www.youtube.com/html5</a> and at the bottom you will see this:</p>
<p><a href="http://blog.tordeu.com/wp-content/uploads/2012/08/youtube-html5-1.png"><img class="aligncenter size-full wp-image-397" title="youtube-html5-1" src="http://blog.tordeu.com/wp-content/uploads/2012/08/youtube-html5-1.png" alt="before entering the HTML5 trial on Youtube" width="633" height="164" /></a></p>
<p>Here you can see the capabilities of your browser and if you currently are in the HTML5 trial (which means HTML5 will be enabled). As you can see here, it states &#8220;You are not currently in the HTML5 trial&#8221;.</p>
<p>But directly below this statement, there is a link which reads &#8220;Join the HTML5 Trial&#8221;. When you click on it, HTML5 on Youtube will be enabled and the site will now look like this:</p>
<p><a href="http://blog.tordeu.com/wp-content/uploads/2012/08/youtube-html5-2.png"><img class="aligncenter size-full wp-image-398" title="youtube-html5-2" src="http://blog.tordeu.com/wp-content/uploads/2012/08/youtube-html5-2.png" alt="after entering the HTML5 trial on Youtube" width="633" height="164" /></a></p>
<p>That&#8217;s it. You don&#8217;t need to do anything else. But one thing you should know is that the HTML5 based player will not work on all videos. Therefore, if you still happen to see the flash based video player on a lot of videos, it does not mean that enabling HTML5 did not work. It just means that those videos can not be presented to you using the HTML5 based player.</p>
<h2></h2>
<h2>Check Which Player Is Used On A Specific Video</h2>
<p>You can check if the HTML5 based player is used by right clicking on a video while it&#8217;s playing or paused. If the HTML5 based player is used, you will see something like this when right clicking on it):</p>
<p><a href="http://blog.tordeu.com/wp-content/uploads/2012/08/youtube-html5-3b.png"><img class="aligncenter size-full wp-image-400" title="youtube-html5-3b" src="http://blog.tordeu.com/wp-content/uploads/2012/08/youtube-html5-3b.png" alt="The HTML5 is used for video playback" width="255" height="326" /></a></p>
<p>The &#8220;About HTML5&#8243; indicates that this is the HTML5 based player.</p>
<p>When the default Flash based played is used, the menu presented to you when right-clicking on the video will look like this instead (the version at the bottom will be different, but you can clearly see that it&#8217;s the &#8220;Adobe Flash Player&#8221; which is used):</p>
<p><a href="http://blog.tordeu.com/wp-content/uploads/2012/08/youtube-html5-4b.png"><img class="aligncenter size-full wp-image-401" title="youtube-html5-4b" src="http://blog.tordeu.com/wp-content/uploads/2012/08/youtube-html5-4b.png" alt="The Flash based player is used for video playback" width="306" height="331" /></a></p>
<p>&nbsp;</p>
<p>Like I said, the HTML5 based player will not be used for every video and you might even be wondering if entering the HTML5 trial worked at all, because quite a lot of videos will still be played with the Flash based player. All I can tell you is: It does work! The number of videos that will be presented to you this way will probably increase over time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=388</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command: md5sum (Extended Documentation)</title>
		<link>http://blog.tordeu.com/?p=359</link>
		<comments>http://blog.tordeu.com/?p=359#comments</comments>
		<pubDate>Wed, 04 Apr 2012 11:41:25 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=359</guid>
		<description><![CDATA[I published an extended documentation for the md5sum command in my wiki: http://www.tordeu.com/commands/md5sum]]></description>
				<content:encoded><![CDATA[<p>I published an extended documentation for the md5sum command in my wiki:</p>
<p><a title="http://www.tordeu.com/commands/md5sum" href="http://www.tordeu.com/commands/md5sum">http://www.tordeu.com/commands/md5sum</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=359</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>md5sum Command Overview (Cheat Sheet)</title>
		<link>http://blog.tordeu.com/?p=354</link>
		<comments>http://blog.tordeu.com/?p=354#comments</comments>
		<pubDate>Sun, 29 Jan 2012 13:26:35 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=354</guid>
		<description><![CDATA[I published a small command overview (cheat sheet) for md5sum on my site: md5sum Command Overview (Cheat Sheet)]]></description>
				<content:encoded><![CDATA[<p>I published a small command overview (cheat sheet) for md5sum on my site:</p>
<p><a title="md5sum Command Overview (Cheat Sheet)" href="http://www.tordeu.com/doku.php?id=commands:md5sum:overview">md5sum Command Overview (Cheat Sheet)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=354</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Aliases in Bash</title>
		<link>http://blog.tordeu.com/?p=289</link>
		<comments>http://blog.tordeu.com/?p=289#comments</comments>
		<pubDate>Sun, 22 Jan 2012 12:53:56 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Alias]]></category>
		<category><![CDATA[Aliases]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=289</guid>
		<description><![CDATA[Introduction What Aliases Are Here is a short introduction to aliases in case you have not idea what they are: An alias is simply a different name for a specific command line command. You can call an alias like any other program and the shell will then replace the alias with the command it represents. <a href='http://blog.tordeu.com/?p=289'>[...]</a>]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<h3>What Aliases Are</h3>
<p>Here is a short introduction to aliases in case you have not idea what they are:</p>
<p>An alias is simply a different name for a specific command line command. You can call an alias like any other program and the shell will then replace the alias with the command it represents.</p>
<p>If you find yourself typing&#8221;aptitude&#8221; a lot you could, for example, define an alias &#8220;a&#8221; for this command instead. Now, instead of typing</p>
<pre>aptitude install &lt;package&gt;</pre>
<p>you just need to type</p>
<pre>a install &lt;package&gt;</pre>
<p>Bash will recognize that the command a is really just an alias that stands for &#8220;aptitude&#8221; and therefore replace a with &#8220;aptitude&#8221;. You could make your like even easier by assigning an alias &#8220;ai&#8221; to the command &#8220;aptitude install&#8221;. Then, when typing</p>
<pre>ai &lt;package&gt;</pre>
<p>bash will notice that the command &#8220;ai&#8221; is really just an alias for &#8220;aptitude install&#8221; and replace &#8220;ai&#8221; accordingly. Therefore, the command that bash will execute is:</p>
<pre>aptitude install &lt;package&gt;</pre>
<p><span id="more-289"></span></p>
<h3>Permanently Storing Your Aliases</h3>
<p>It is important to note than running the commands below will only change the alias definitions for the current shell. The changes will not appear in other shells and they will be lost when closing the shell (and logout/shutdown/reboot). This basically means that the changes are only temporary.</p>
<p>Therefore, if you want to permanently define new aliases, you can create new file named</p>
<pre>.bash_aliases</pre>
<p>in your homefolder (the file will most likely not exist already) and put all you alias definitions in there. Alternatively you can add the definitions to the file</p>
<pre>.bashrc</pre>
<p>in your home folder, but it&#8217;s cleaner to have a separate file for the aliases and the .bashrc should already check for a file named .bash_aliases, so you only need to create the .bash_aliases and the file will automatically loaded.</p>
<p>It is important to note that the .bashrc and therefore the .bash_aliases will only be read when the shell is created. Therefore, you won&#8217;t see the changes to .bash_aliases immediately. You need to either create a new shell after saving your modified .bash_aliases or (re)load the .bash_aliases file like this:</p>
<pre>. ~/.bash_aliases</pre>
<p>You can, of course, create an an alias for this command in your .bash_aliases file&#8230;</p>
<p>&nbsp;</p>
<h2>List All Aliases</h2>
<p>To get a list of all aliases which are currently defined, all you need to do is to run:</p>
<pre>alias</pre>
<p>This will list all defined aliases, one per line, like this:</p>
<pre>alias la='ls -la'
alias ls='ls --color=auto'
alias lx='ls -lAh --group-directories-first'</pre>
<p>&nbsp;</p>
<h2>List A Specific Alias</h2>
<p>To only get the value of a specific alias, you can type:</p>
<pre>alias &lt;name&gt;</pre>
<p>You can also use this command to display several aliases:</p>
<pre>alias &lt;name1&gt; &lt;name2&gt; ...</pre>
<h3>Example 1</h3>
<pre>alias la</pre>
<p>will display</p>
<pre>alias la='ls -la'</pre>
<h3>Example 2</h3>
<pre>alias ls la</pre>
<p>will display:</p>
<pre>alias ls='ls --color=auto'
alias la='ls -la'</pre>
<h2></h2>
<h2>Create A New Alias / Change An Existing Alias</h2>
<p>Creating a new alias or changing the value of an existing alias can be done in the same way:</p>
<pre>alias &lt;name&gt;=&lt;value&gt;</pre>
<p>For example, creating an alias &#8220;www&#8221; to avoid typing &#8220;cd /var/www&#8221; all the time, can be done like this:</p>
<pre>alias www='cd /var/www'</pre>
<p>&nbsp;</p>
<h3>Combining Aliases</h3>
<p>When defining an alias it is possible to use another alias. Let me show you two examples of how this might be put to use:</p>
<h4>Supplying (additional) options</h4>
<p>The only predefined alias on Debian is</p>
<pre>ls='ls --color=auto</pre>
<p>By defining an alias la like this:</p>
<pre>alias la='ls -la'</pre>
<p>You already used an alias for defining the new alias. When typing</p>
<pre>la</pre>
<p>bash will now recognize that &#8220;la&#8221; is an alias and replace it with its value:</p>
<pre>ls -la</pre>
<p>But now, again, bash will recognize that &#8220;ls&#8221; is an alias as well and replace this will its value &#8220;ls &#8211;color=auto&#8221;, which results in the command:</p>
<pre>ls --color=auto -la</pre>
<p>(bash will not recognize ls an alias again, so this is where it stops)</p>
<p>In this example the alias &#8220;la&#8221; used the already defined alias &#8220;ls&#8221; (which adds coloring to the command ls) to add the additional options &#8220;-l&#8221; and &#8220;-a&#8221; to it. This can be used for various purposes. If you want to define various aliases for the ls command, for example, it might be a good idea to create an alias that already contains the common options (like coloring) you want to use for all the other aliases. This will shorten the alias values, which makes them easier to manage. Instead of defining the following aliases:</p>
<pre>alias la='ls -la --color=auto'
alias lh='ls -lh --color=auto'
alias lx='ls -lAh --color=auto --group-directories-first'</pre>
<p>you could define them like this:</p>
<pre>alias la='ls -a'
alias lh='ls -h'
alias ls='ls -l --color=auto'
alias lx='lh -A --group-directories-first'</pre>
<p>In this example the alias ls already carried the &#8220;-l&#8221; and &#8220;&#8211;color=auto&#8221; option, therefore avoiding the others to specify them as well. The definition of the lx alias uses the lh alias, which additionally carries the &#8220;-h&#8221; option. You should be careful when using this approach, because creating two many connections between aliases can make management more complicated instead of simplifying it and also create some unwanted side effects.</p>
<p>&nbsp;</p>
<h4> Supplying (additional) arguments</h4>
<p>Similar to applying additional command line options, you can supply additional arguments to</p>
<p>&nbsp;</p>
<h2>Delete An Alias</h2>
<p>To delete an alias you need to use the unalias command:</p>
<pre>unalias &lt;name&gt;</pre>
<p>It is also possible to delete several aliases at once:</p>
<pre>unalias &lt;name1&gt; &lt;name2&gt; ...</pre>
<h3>Example</h3>
<p>To delete the www alias that we just created, type:</p>
<pre>unalias www</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=289</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable GNOME3&#8242;s Habbit Of Turning Off The Display After Some Time.</title>
		<link>http://blog.tordeu.com/?p=292</link>
		<comments>http://blog.tordeu.com/?p=292#comments</comments>
		<pubDate>Sun, 15 Jan 2012 04:29:32 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[GNOME]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=292</guid>
		<description><![CDATA[Gnome3 has the annoying habbit of turning off the monitor after a while, even if you are watching a video. Unfortunately, if you go to System Settings &#62; Screen   you will be surprised that if offers you the possibility to change the time the system has to be idle for the monitor to be <a href='http://blog.tordeu.com/?p=292'>[...]</a>]]></description>
				<content:encoded><![CDATA[<p>Gnome3 has the annoying habbit of turning off the monitor after a while, even if you are watching a video. Unfortunately, if you go to</p>
<address>System Settings &gt; Screen</address>
<address> </address>
<p>you will be surprised that if offers you the possibility to change the time the system has to be idle for the monitor to be turned off from 1 minute to 1 hour. But what is missing is an option to turn this function off entirely.</p>
<p>Fortunately, it is possible to do that, just not in System Settings and you can either do that from command line or with a GUI.</p>
<p><span id="more-292"></span></p>
<h2>Explanation</h2>
<p>I will not explain GSettings here, but just in case you don&#8217;t know: GSettings (which replaces GConf) is used to store the configuration of the GNOME desktops. Don&#8217;t worry, you don&#8217;t need to know GSettings to follow the instructions below. But GSettings is also used to store the information about when to turn off the display. The keys that are important here are the following:</p>
<pre>org.gnome.settings-daemon.plugins.power sleep-display-ac
org.gnome.settings-daemon.plugins.power sleep-display-battery
org.gnome.desktop.session idle-delay</pre>
<p>Those are the keys that the System Settings GUI is changing when you use it.</p>
<p>The first two determine when the display is turned off (on a desktop system that is always plugged in the first value is the important one. The second key is used in case the system is running on a battery, which is important for portable devices like notebooks and tablets).</p>
<p>The third key is important, because it is used to determine when to start the screensaver and lock the screen, although there are additional values that target those two in org.gnome.desktop.session.</p>
<p><span style="text-decoration: underline;">The values of all three keys are in seconds (so a value of 600 stands for 600s = 10min).</span></p>
<p>But because the System Settings GUI does change these three keys altogether and there is a connection between these three, it is probably a good idea for most people to change all three to the same value by hand as well.</p>
<p>&nbsp;</p>
<h2>Using Command Line</h2>
<p>You can use the gsettings command to change the values of the keys.</p>
<p>First, let&#8217;s see what the values of these keys are. You can do that by running the following three commands.</p>
<pre>gsettings get org.gnome.settings-daemon.plugins.power sleep-display-ac
gsettings get org.gnome.settings-daemon.plugins.power sleep-display-battery
gsettings get org.gnome.desktop.session idle-delay</pre>
<p>Each command will print the value of the given key. You will notice (most likely) that all three values are equal and that they reflect the value that is displayed in System Settings. If you change the value in System Settings, you will notice that these three keys do change accordingly.</p>
<p>To set these by hand you can use the following three commands:</p>
<pre>gsettings set org.gnome.settings-daemon.plugins.power sleep-display-ac &lt;value&gt;
gsettings set org.gnome.settings-daemon.plugins.power sleep-display-battery &lt;value&gt;
gsettings set org.gnome.desktop.session idle-delay &lt;value&gt;</pre>
<p>Just replace &lt;value&gt; with the number of seconds you want the system to wait before turning off the display (and potentially locking the screen). To tell the system that it should let the display turned on forever, you can use the value 0:</p>
<pre>gsettings set org.gnome.settings-daemon.plugins.power sleep-display-ac 0
gsettings set org.gnome.settings-daemon.plugins.power sleep-display-battery 0
gsettings set org.gnome.desktop.session idle-delay 0</pre>
<p>&nbsp;</p>
<h2>Using A GUI</h2>
<p>To change the keys you can use &#8220;dconf Editor &#8220;. You can start the program by one of the following ways:</p>
<ul>
<li>go to Applications and either</li>
<ul>
<li>search for dconf or</li>
<li>look for it under &#8220;System Tools&#8221; or</li>
</ul>
<li>press Alt+F2 and enter: dconf-editor or</li>
<li>open a terminal and run &#8220;dconf-editor&#8221;</li>
</ul>
<p>Once dconf Editor starts, you will see the following window:</p>
<div id="attachment_297" class="wp-caption aligncenter" style="width: 534px"><a href="http://blog.tordeu.com/wp-content/uploads/2012/01/1.png"><img class="size-full wp-image-297 " title="dconf-editor_1" src="http://blog.tordeu.com/wp-content/uploads/2012/01/1.png" alt="dconf-editor 1" width="524" height="463" /></a><p class="wp-caption-text">The dconf-editor window after starting the I</p></div>
<p>On the left side you now need to navigate to &#8220;org.gnome.settings-daemon.plugins.power&#8221; (that means: open &#8220;org&#8221;, then &#8211; within &#8220;org&#8221; &#8211; open &#8220;gnome&#8221; and so on until you reach &#8220;power&#8221;). Then, you need to find the keys &#8220;sleep-display-ac&#8221; and &#8220;sleep-display-battery&#8221; on the right side:</p>
<div id="attachment_301" class="wp-caption aligncenter" style="width: 696px"><a href="http://blog.tordeu.com/wp-content/uploads/2012/01/2b.png"><img class="size-full wp-image-301" title="dconf-editor 2b" src="http://blog.tordeu.com/wp-content/uploads/2012/01/2b.png" alt="dconf-editor 2b" width="686" height="596" /></a><p class="wp-caption-text">The dconf-edtior window after navigating to the first key</p></div>
<p>Change both numbers to 0 to prevent the system from turning off the display.</p>
<p>After that you should navigate to &#8220;org.gnome.desktop.session&#8221; on the left side and change the key &#8220;idle-delay&#8221; (on the right side) to 0 as well.</p>
<p>After that, just quit the editor (the changes are automatically saved).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=292</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to use Ctrl+Alt+F1 etc. in a Virtual Machine in VirtualBox</title>
		<link>http://blog.tordeu.com/?p=322</link>
		<comments>http://blog.tordeu.com/?p=322#comments</comments>
		<pubDate>Sat, 07 Jan 2012 08:56:22 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=322</guid>
		<description><![CDATA[Problem When using a virtual machine in VirtualBox you might want to switch to a different console by hitting Ctrl+Alt+F&#60;n&#62;   where &#60;n&#62; stands for the number of the console you want to access (like Ctrl+Alt+F1 to get a text console and Ctrl+Alt+F7 to get back to your X session). Unfortunately, key combinations with Ctrl+Alt <a href='http://blog.tordeu.com/?p=322'>[...]</a>]]></description>
				<content:encoded><![CDATA[<h2>Problem</h2>
<p>When using a virtual machine in VirtualBox you might want to switch to a different console by hitting</p>
<address>Ctrl+Alt+F&lt;n&gt;</address>
<address> </address>
<p>where &lt;n&gt; stands for the number of the console you want to access (like Ctrl+Alt+F1 to get a text console and Ctrl+Alt+F7 to get back to your X session).</p>
<p>Unfortunately, key combinations with Ctrl+Alt like the mentioned Ctrl+Alt+F&lt;n&gt; or Ctrl+Alt+Del will not be sent to the guest operating system. <span id="more-322"></span>Instead, Ctrl+Alt+F&lt;n&gt; will only let you change consoles on your host and Ctrl+Alt+Del will magically disappear and effect neither the host nor the guest OS.</p>
<p>VirtualBox offers two menu entries (under the menu entry &#8220;Machine&#8221;) to send Ctrl+Alt+Del and Ctrl+Alt+Backspace to the guest OS, but does not offer such a feature for other key combinations.</p>
<p>&nbsp;</p>
<h2>Solution</h2>
<p>Fortunately, you can use the host key (the right Ctrl key by default) as a substitute for Ctrl+Alt. Therefore when pressing</p>
<pre>HOST+F&lt;n&gt;</pre>
<p>VirtualBox will send</p>
<address>Ctrl+Alt+F&lt;n&gt;</address>
<address> </address>
<p>to the guest OS and this will let you change consoles in your guest and also use other key combination that include Ctrl+Alt.</p>
<p>&nbsp;</p>
<h2>Links</h2>
<p><a title="Link to the corresponding section in the VirtualBox User Manual" href="https://www.virtualbox.org/manual/ch01.html#idp7685232">https://www.virtualbox.org/manual/ch01.html#idp7685232</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=322</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>rename &#8211; Batch renaming files in command line</title>
		<link>http://blog.tordeu.com/?p=112</link>
		<comments>http://blog.tordeu.com/?p=112#comments</comments>
		<pubDate>Thu, 08 Dec 2011 16:05:52 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Commands]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command line]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=112</guid>
		<description><![CDATA[&#160; There are several ways one can batch rename files in Linux. One of the possibilities is the linux command rename. Usage To rename files you have to supply a Perl expression. Using Perl expressions might be scary for beginners (because they look like someone hit his head on the keyboard), but they allow for <a href='http://blog.tordeu.com/?p=112'>[...]</a>]]></description>
				<content:encoded><![CDATA[<p>&nbsp;</p>
<p>There are several ways one can batch rename files in Linux. One of the possibilities is the linux command rename.</p>
<h2>Usage</h2>
<p>To rename files you have to supply a Perl expression. Using Perl expressions might be scary for beginners (because they look like someone hit his head on the keyboard), but they allow for complex renaming with a minimum of characters.</p>
<p>Although I won&#8217;t go into detail about Perl expressions here, I will try to make it a little easier for beginners to use them for batch renaming.</p>
<p>According to the man page of rename, this is the way to use rename:</p>
<pre>rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]</pre>
<p>If you have not worked with Perl expressions before, this might not be enough to get you started. So let me present you with the way one would probably use rename most of the time:</p>
<pre>rename 's/<span style="color: #00ccff;">OLD</span>/<span style="color: #00ccff;">NEW</span>/' <span style="color: #00ccff;">FILES</span></pre>
<p>OLD is an expressions which describes a pattern in the name filenames. If rename can find this pattern in the name of a file, it will replace this part of the filename with what is defined as NEW. The files rename should rename are defined by FILES.</p>
<p>Let me provide you with two examples:<span id="more-112"></span></p>
<h2>Examples</h2>
<h3>Example 1 &#8211; Replacing a single word/string</h3>
<p>Let&#8217;s start with a very simple example: Imagine, you have a lot of images that are named</p>
<pre>picture 1.jpg
picture 2.jpg
...</pre>
<p>and you would like to replace the word &#8220;picture&#8221; with the word &#8220;image&#8221;, so that the files will be named like this:</p>
<pre>image 1.jpg
image 2.jpg
...</pre>
<p>As describes under usage, OLD represents the part that we want to replace. As we want  to replace the word &#8220;picture&#8221;, in this example OLD will be &#8220;picture&#8221;.</p>
<p>And because NEW defines with what OLD is replaced with, in our example. We want the OLD(=&#8221;picture&#8221;) to be replaced with &#8220;image&#8221;, so here NEW=&#8221;image&#8221;.</p>
<p>And because we want to do this only for all the pictures which name starts with &#8220;picture&#8221; FILES will be &#8220;picture*.jpg&#8221;.</p>
<p>Therefore the general command</p>
<pre>rename 's/OLD/NEW/' FILES</pre>
<p>becomes:</p>
<pre>rename 's/picture/image/' picture*.jpg</pre>
<p>It might have not been necessary for us to restrict this to the the files &#8220;picture*.jpg&#8221;. We might have just used *.jpg (all files in the current directory with the extension .jpg) or even * (all files in the current directory), because rename will only change the filename, if the pattern OLD (here: &#8220;picture&#8221;) is found in the filename. You have to be careful, though. A file with the name &#8220;just a picture.jpg&#8221; would have been renamed to &#8220;just a image.jpg&#8221;, because we told rename to replace &#8220;picture&#8221; with &#8220;image&#8221;.</p>
<h3>Example 2</h3>
<p>Let&#8217;s go back to Example 1. One problem I mentioned is that running</p>
<pre>rename 's/picture/image' *.jpg</pre>
<p>to rename files like &#8220;picture 23.jpg&#8221; to &#8220;image 23.jpg&#8221; would also rename files like &#8220;just a picture.jpg&#8221; to &#8220;just a image.jpg&#8221;, because rename would find the word &#8220;picture&#8221; and replace it with &#8220;image&#8221;, although this is not what we intended.</p>
<p>We could prevent this by calling rename like this:</p>
<pre>rename 's/picture/image' picture*.jpg</pre>
<p>This would call rename only for the .jpg files starting with the word &#8220;picture&#8221;. But this is not really a solution, because files like &#8220;picture of a sunset.jpg&#8221; would still be renamed to &#8220;image of a sunset.jpg&#8221;.</p>
<p>To make sure that rename really does what we want it to do, we need to be very clear about what should be renamed. Because what we want is not to replace the word &#8220;picture&#8221; with the word &#8220;image&#8221; in every case, we want to replace the word &#8220;picture&#8221; with the word &#8220;image&#8221;, but only for the files which name consists of the word &#8220;picture&#8221;, then a space and then a number and then the extension &#8220;.jpg&#8221;.</p>
<p>This can be achieved with the following command:</p>
<pre>rename 's/^picture( [0-9]*\.jpg)$/image$1/' *.jpg</pre>
<p>This might look a little scary, but is a good example of what you can do with Perl expressions. Because this would only rename the desired files. Files like &#8220;my picture 11.jpg&#8221; or &#8220;picture 28 (beach).jpg&#8221; would not be renamed and in this example that is exactly what we want to do.</p>
<p>Let me go through the different parts of the expression above briefly, to give you an idea of how this works. Keep in mind that this just an example and not intended as a complete tutorial. I will just try to explain to you the various elements of this expression to show you some of the possibilities and to demystify them a little bit.</p>
<p>When you compare the command to the general form under &#8220;Usage&#8221;, you will see that in this case:</p>
<ul>
<li>OLD = ^picture( [0-9]*\.jpg)$</li>
<li>NEW = image$1</li>
<li>FILES = *.jpg</li>
</ul>
<p>In this example OLD makes sure that only the desired files are renamed by defining the structure of what we are looking for exactly. This works, because OLD defines what should be renamed. That means that files where the pattern/structure defined by OLD can not be found will not be renamed. Therefore, OLD automatically works as a filter to make sure that only the desired files get renamed. The trick is to make sure that OLD and NEW reflect what you wish to do. Let&#8217;s dissect it:</p>
<p>Let&#8217;s ignore the &#8220;^&#8221; at the beginning, the &#8220;$&#8221; at the end, the parentheses and the &#8220;\&#8221;  at the moment. This leaves the following:</p>
<pre>picture [0-9]*.jpg</pre>
<p>This describes our basic structure. First, we have the word &#8220;picture&#8221;, then a space. [0-9] means any character from 0 to 9, which essentially means &#8220;a digit&#8221; and when putting a &#8220;*&#8221; after it, it means that there can be &#8220;any number of&#8221; digits. We need this, because we don&#8217;t know how many digits there will be. We can have files like &#8220;picture 7.jpg&#8221;, where there is only 1 digit or files like &#8220;picture 1432.jpg&#8221;, where he have four of them. So, &#8220;[0-9]*&#8221; stands for &#8220;any number of digits&#8221;, which just means: a number. And then we have &#8220;.jpg&#8221;, our extensions.</p>
<p>It is important to note that  &#8220;[0-9]*&#8221; really means &#8220;any number of digits&#8221; and that &#8220;any number&#8221; could also mean 0. This means that the number is optional and a file named &#8220;picture .jpg&#8221; would also be renamed. In this example it probably would not make a real difference, but in general you need to be careful. If there really has to be a number and it can not be optional, you can use a &#8220;+&#8221; instead of a &#8220;*&#8221;, because &#8220;[0-9]+&#8221; means &#8220;at least one digit&#8221;.  But because it will not be a problem in this case, we will keep the &#8220;*&#8221;.</p>
<p>Now, let&#8217;s add the parts we ignored:</p>
<p>The &#8220;.&#8221; is a special character which stand for &#8220;any character&#8221;. But in our pattern, we want to make clear that the filename ends with &#8220;.jpg&#8221;. But &#8220;.jpg&#8221; would be interpreted as &#8220;any character, then j, then p, then g&#8221;. Therefore a file like &#8220;picture 234Xjpg&#8221; would be renamed, because the . (which stand for &#8220;any character&#8221;) would be &#8220;X&#8221; in this case. But really want to make sure that the file ends with &#8220;.jpg&#8221; and therefore need to make it clear that the &#8220;.&#8221; really stand for &#8220;.&#8221; and not for &#8220;any character&#8221;. This can be done by escaping it with a &#8220;\&#8221;. Therefore, we need to write &#8220;\.jpg&#8221;.</p>
<p>The parentheses are added, because the pattern we are creating will be matching the complete filename. If we would run a command like this:</p>
<pre>rename 's/^picture [0-9]*\ .jpg$/image/' *.jpg</pre>
<p>A file like &#8220;picture 23.jgp&#8221; would be renamed to &#8220;image&#8221; and not to &#8220;image 23.jpg&#8221;. This is because our pattern &#8220;^picture [0-9]*\.jpg$&#8221; describes the whole filename. So the complete filename would be replace with &#8220;image&#8221;. But we just want to replace &#8220;picture&#8221; and keep the rest.</p>
<p>We can do this by telling rename that we want to keep everything after &#8220;picture&#8221;. While we can&#8217;t do this directly, we can put every after &#8220;picture&#8221; in parentheses and then later use this part to build our new filename, because everything within the parentheses will be saved accessible later as &#8220;$1&#8243;, so if we use the pattern</p>
<pre>picture( [0-9]*\.jpg)</pre>
<p>We can now see that the space, the number and the extension &#8220;.jpg&#8221; are within the parentheses and we can access this part as &#8220;$1&#8243;. When the filename is &#8220;picture 83.jpg&#8221;, $1 will therefore contain &#8221; 83.jpg&#8221;. Then, when we define our replacement, we can tell rename to use &#8220;image$1&#8243; as our replacement for the filename. Because $1 contains the space, the number and the extension, this would translate to &#8220;image 83.jpg&#8221;.</p>
<p>Now, what&#8217;s left are &#8220;^&#8221; and &#8220;$&#8221;. &#8220;^&#8221; stand for the beginning of the filename. This makes sure that files like &#8220;some picture 44.jpg&#8221; would not be renamed. This is because a pattern like &#8220;picture&#8221; means: find the word picture anywhere. Whereas &#8220;^picture&#8221; essentially means: find the word picture at the beginning of the input(=filename).</p>
<p>Similarly, &#8220;$&#8221; stand for the end of the input (here: filename). We use this to make sure that something like &#8220;picture 74.jpg.gz&#8221; does not get renamed.</p>
<p>Combining &#8220;^&#8221; and &#8220;$&#8221; therefore ensures that the filename only consists of the pattern we defined and there is nothing before &#8220;picture&#8221; and nothing after our &#8220;.jpg&#8221;.</p>
<p>Therefore, our final pattern is:</p>
<pre>^picture( [0-9]*\.jpg)$</pre>
<p>And the command to rename the files is, again:</p>
<pre>rename 's/^picture [0-9]*\ .jpg$/image/' *.jpg</pre>
<h3>Example 4 &#8211; add a prefix to all filenames (added on 2012-05-20)</h3>
<p>In case you want to add a prefix at the beginning of a filename, you can use this line:</p>
<p>rename &#8216;s/(.*)/PREFIX$1/&#8217; FILES</p>
<p>Substitute PREFIX to whatever you want to put in front of the filename and substitute FILES for the files you want to rename (see Example 6 below for some examples)</p>
<p>If you run</p>
<p>rename &#8216;s/(.*)/foo_$1/&#8217; *.txt</p>
<p>All the .txt files in the current directory will get an &#8220;foo_&#8221; in front of of their name. (So info.txt would be renamed to foo_info.txt, for example)</p>
<p>&nbsp;</p>
<h3>Example 5 &#8211; add a suffix to all filenames (added on 2012-05-20)</h3>
<p>Adding a suffix at the end of a filename can be as simple as adding a prefix; you could simply run:</p>
<pre>rename 's/(.*)/$1SUFFIX/' FILES</pre>
<p>The problem is that this might not be what you expected, because the suffix will be added at the end of the filename, which also means after the suffix the file might already have to denote its type (e.g. &#8220;.txt&#8221;, &#8220;.tar&#8221;, &#8220;.jpg&#8221; etc. Running</p>
<pre>rename 's/(.*)/$1boo/' info.tar</pre>
<p>would rename the file &#8220;info.tar&#8221; to &#8220;info.tar.boo&#8221;. If that is what you want, you can use the line above, but if you would want to rename it to &#8220;infoboo.tar&#8221;, then you can use the following line:</p>
<pre>rename 's/(.*)\.(.*)/$1SUFFIX.$2/' FILES</pre>
<p>with this, running</p>
<pre>rename 's/(.*)\.(.*)/$1boo.$2/' FILES</pre>
<p>would rename &#8220;info.tar&#8221; to &#8220;infoboo.tar&#8221;.</p>
<p>Be aware that this will not work for files with suffixes that contain two dots (like &#8220;archive.tar.gz&#8221;).</p>
<h4>Improvement 1 (Update 2012-05-22):</h4>
<p>The fact that files like &#8220;archive.tar.gz&#8221; would be renamed as well and the result would certainly not be as hoped, we can try to improve the pattern above a little bit:</p>
<pre>rename 's/^([^.]*)\.([^.]*)$/$1SUFFIX.$2/' FILES</pre>
<p>This approach will only rename files that only contain a single dot and leave all other files alone.</p>
<h4>Improvement 2 (Update 2012-05-22):</h4>
<p>If you want to rename files with extensions like &#8220;.tar.gz&#8221; correctly, you can use the following approach:</p>
<pre>rename 's/^([^.]*)\.(.*)$/$1SUFFIX.$2/' FILES</pre>
<p>This will essentially add the suffix directly in front of the first dot. However, this approach will not work in case you have files that contain dots that are not supposed to be part of the file extension (in &#8220;some.great.file.txt&#8221;, the suffix &#8220;111&#8243; would be added like this: &#8220;some111.great.file.txt&#8221;)</p>
<h3>Example 6 &#8211; how to define which files to rename (added on 2012-05-20)</h3>
<p>In the beginning I noted the general form of how to use rename:</p>
<pre>rename 's/OLD/NEW/' FILES</pre>
<p>I now want to give you some simple examples of what you can do with &#8220;FILES&#8221;, which tells rename which files it<br />
should try to rename in the first place. This list is by no means complete. It just provides you with a few (hopefully useful) examples.</p>
<ul>
<li>to rename a single file just state its name. Example: backup.tar</li>
<li>to rename several specific files just list all their names. Example: backup.tar mypicture.jpg asong.ogg</li>
<li>to rename all files in the current directory just use &#8220;*&#8221; (without the &#8220;).</li>
<li>to rename all files with a specific ending (e.g. .jpg) use &#8220;*ENDING&#8221;. Example: *.jpg</li>
<li>to rename files with different endings, just list them all. Example: *.jpg *.jpeg *.mp3 *.txt *.ar</li>
<li>to rename files that start with the same word/characters use &#8220;START*&#8221;. Example: my* old*</li>
<li>to rename files that contain the same word/sequence of characters use &#8220;*WITHIN*&#8221;. Example: *good*</li>
<li>you can combine all of those things. Example: my*.txt *boo*.jpg foo* test.tmp</li>
</ul>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>I hope that this article succeeds in demonstrating how rename can be used to batch rename files (not in detail, but at least in pushing you in the right direction). And I also hope that while covering Perl expressions in detail is beyond the scope of this article, the second example gives you an idea of how powerful and useful they can be and why it can make sense to learn more about them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=112</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Converting FLAC to MP3 (including Tags) on command line</title>
		<link>http://blog.tordeu.com/?p=184</link>
		<comments>http://blog.tordeu.com/?p=184#comments</comments>
		<pubDate>Wed, 23 Nov 2011 07:29:14 +0000</pubDate>
		<dc:creator>tordeu</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[flac]]></category>
		<category><![CDATA[metaflac]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.tordeu.com/?p=184</guid>
		<description><![CDATA[ (Download the script from this article ) When converting FLAC files to MP3, the first problem you will notice is that lame does not support FLAC files. This might now seem like big problem, because you can easily decode FLAC files using the command line tool flac and then use the decoded file with lame. <a href='http://blog.tordeu.com/?p=184'>[...]</a>]]></description>
				<content:encoded><![CDATA[<p style="text-align: right;"> (Download the script from this article <a href="http://blog.tordeu.com/downloads/2">flac2mp3.sh</a>)</p>
<p>When converting FLAC files to MP3, the first problem you will notice is that lame does not support FLAC files. This might now seem like big problem, because you can easily decode FLAC files using the command line tool flac and then use the decoded file with lame.</p>
<h2>The Problem</h2>
<p>The real problem is that you will loose your metadata in this process, so the tags you added to your FLAC won&#8217;t be copied to the MP3 file. While you could &#8220;easily&#8221; add them by hand, it is pretty annoying to do that even if you only want to convert a handful of files.</p>
<p><span id="more-184"></span></p>
<h2>The solution</h2>
<p>The solution is to extract the metadata from the FLAC file using metaflac and to use the options lame provides to inject the tags into the MP3 file when calling lame.</p>
<p>Note:</p>
<p>This section is merely provided to explain the steps involved. You do not need to read this nor do you need to do this by hand, since I offer you a small script that will do these steps for you (look at the very first line of the article or below under &#8220;Download&#8221; to download the script).</p>
<h3>Step 1 &#8211; Extract the Metadata</h3>
<p>To extract a single tag, you can use metaflac like this:</p>
<pre>metaflac --show-tag=&lt;tag&gt; &lt;file&gt;</pre>
<p>To extract the artist of the track from the file named &#8220;1 &#8211; Let It In.flac&#8221;, you could call:</p>
<pre>metaflac --show-tag=ARTIST "1 - Let It In.flac"</pre>
<p>&nbsp;</p>
<p>In general you will get a result like this:</p>
<pre>&lt;TAG&gt;=&lt;VALUE&gt;</pre>
<p>In the mentioned example you might get the following:</p>
<pre>ARTIST=Josh Woodward</pre>
<h3></h3>
<h3> Step 2 &#8211; Fomat the Metadata</h3>
<p>We only need the name of the artist, so we need to get rid of  &#8220;ARTIST=&#8221;. This can be easily achieved with sed.  The general way of replacing something with sed is this:</p>
<pre>sed 's/OLD/NEW/'</pre>
<p>OLD is the part that you want to replace and NEW is the part that you want to replace it with. What we want to replace is &#8220;ARTIST=&#8221; (which is our OLD) and what we want to replace it with is nothing (which will essentially remove OLD), so our NEW is empty. And this is what we get:</p>
<pre>sed 's/ARTIST=//'</pre>
<p>But that would only work for the ARTIST tag. A general solution would be to remove anything up to and including the equal sign. I won&#8217;t go into detail on this one, but this would be achieved by setting OLD to &#8220;.*=&#8221; and the line would look like this:</p>
<pre>sed 's/.*=//'</pre>
<p>To make this work, we need to we need to pass the output of metaflac to our sed command, which we would do like this:</p>
<pre>metaflac --show-tag=ARTIST "1 - Let It In.flac" | sed 's/.*=//'</pre>
<p>This way the output of metaflac (&#8220;ARTIST=Josh Woodward&#8221;) is send to our sed command, which then removes the &#8220;ARTIST=&#8221; part and thus we get the output:</p>
<pre>Josh Woodward</pre>
<p>&nbsp;</p>
<h3>Step 3 &#8211; Store the tag</h3>
<p>While the line from Step 2 works, it merely prints the tag. What we need to do is to store the tag somehow, so that we can use it again later for adding the tag to the MP3 file. To store the output of a command in a variable, you generally type:</p>
<p>&lt;var&gt;=`&lt;command&gt;`</p>
<p>(Those are not single quotes in this line, but backticks/grave accents) This will execute &lt;command&gt; and then store the output to the variable &lt;var&gt;.</p>
<p>In this example we could do this:</p>
<p>ARTIST=`metaflac &#8211;show-tag=ARTIST &#8220;1 &#8211; Let It In.flac&#8221; | sed &#8216;s/.*=//&#8217;`</p>
<p>This would execute out metaflac command and save the output (&#8220;Josh Woodward&#8221;) in the variable ARTIST.</p>
<p>We can test if everything worked by printing the value of ARTIST:</p>
<pre>echo $ARTIST</pre>
<p>which should now give us:</p>
<pre>Josh Woodward</pre>
<p>&nbsp;</p>
<h3>Step 4 &#8211; Passing the tags to lame</h3>
<p>In general, calling lame (and using VBR mode) would work like this:</p>
<pre>lame -V &lt;oldfile&gt; &lt;mp3file&gt;</pre>
<p>If you want lame to save metadata to the mp3 file, you can use several options do to this. To continue our example, let&#8217;s assume we want to add the name of the artist (that we have stored in the variable ARTIST in the last step) to the new MP3 file. This can be done with the &#8211;ta option:</p>
<pre>lame -V --ta "$ARTIST" &lt;oldfile&gt; &lt;mp3file&gt;</pre>
<p>In a similar way, we can add other tags to the mp3 file as well. Here is a small table that shows you the options lame offers to add metadata, the name of the FLAC tag that theese options correspond to and what they mean.</p>
<table border="1">
<tbody>
<tr>
<th>FLAC tag</th>
<th>Lame option</th>
<th>Description</th>
</tr>
<tr>
<td>TITLE</td>
<td>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">--tt</div></div>
</td>
<td>The title of the track</td>
</tr>
<tr>
<td>ARTIST</td>
<td>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">--ta</div></div>
</td>
<td>The title artist</td>
</tr>
<tr>
<td>ALBUM</td>
<td>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">--tl</div></div>
</td>
<td>The album name</td>
</tr>
<tr>
<td>DATE</td>
<td>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">--ty</div></div>
</td>
<td>The year of the album</td>
</tr>
<tr>
<td>COMMENT</td>
<td>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">--tc</div></div>
</td>
<td>a comment for this track</td>
</tr>
<tr>
<td>TRACKNUMBER, TRACKTOTAL</td>
<td>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">--tn</div></div>
</td>
<td>The number of the track and the total number of the tracks</td>
</tr>
<tr>
<td>GENRE</td>
<td>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">--tg</div></div>
</td>
<td>the genre of the track</td>
</tr>
</tbody>
</table>
<h2></h2>
<h3>Step 5 &#8211; Passing the FLAC to lame</h3>
<p>We have not solved the original problem yet: you can not pass a flac file to lame. We could decode the FLAC to WAV and then pass the WAV file to lame, but we don&#8217;t need do really create a WAV file, because we can just decode the FLAC and pass the decoded data directly to lame. To do this, we need to call flac with two options:</p>
<ul>
<li>-d to tell it we want to decode a flac file</li>
<li>-c, so that the decoded data is not written to a file, but to stdout</li>
</ul>
<p>Then, we can tell lame that it should read the data from stdin instead of from a file, which can be done by providing a dash for the &lt;oldfile&gt; parameter. Now we can connect them both with a pipe and the decoded flac data will directly flow into our lame command:</p>
<pre>flac -c -d &lt;flacfile&gt;| lame - &lt;mp3file&gt;</pre>
<p>In our example, we would get something like this (which includes adding the ARTIST tag and a VBR quality of 6):</p>
<pre>flac -c -d "1 - Let It In.flac" | lame -V 6 --ta "$ARTIST" - "1 - Let It In.mp3"</pre>
<p>Now that the basic  steps involved are covered, we can let a script do the work.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>The Script</h2>
<p>I wrote a small script that converts a FLAC file to MP3 while preserving  the following tags (=all the tags listed in &#8220;Step 4&#8243; above):</p>
<ul>
<li>Track Title</li>
<li>Track Artist</li>
<li>Album Title</li>
<li>Year</li>
<li>Comment</li>
<li>Tracknumber</li>
<li>Total number of tracks</li>
<li>Genre</li>
</ul>
<h3>Download</h3>
<p>You can download the script here: <a href="http://blog.tordeu.com/downloads/2">flac2mp3.sh</a></p>
<h3>Usage</h3>
<p>The script takes three arguments:</p>
<ul>
<li>The VBR quality (This corresponds to the -V option of lame, which means that you can use a number between 0 and 9, with smaller numbers meaning higher quality and bigger files). If you omit this option, -V 4 will be used.</li>
<li>The filename of the FLAC file you want to convert</li>
<li>The filename of the new MP3 file that you want to create.</li>
<li>You can (but don&#8217;t have to) add &#8220;mtime&#8221; as the fourth argument in which case the script will not start the conversion if the MP3 file is newer than the FLAC file, which indicates that a conversion is not necessary. (If you don&#8217;t add &#8220;mtime&#8221;, the script will convert the files no matter what)</li>
</ul>
<p>Example:</p>
<p>If you want to convert the file &#8220;1 &#8211; Let It In.flac&#8221; to &#8220;1 &#8211; Let It In.mp3&#8243; with a VBR quality level of 3, you would call the script like this:</p>
<pre>flac2mp3.sh 3 "1 - Let It In.flac" "1 - Let It In.mp3"</pre>
<pre>flac2mp3.sh 3 "1 - Let It In.flac" "1 - Let It In.mp3" mtime</pre>
<h3>Source</h3>
<p>The script generally works as described under &#8220;The Solution&#8221;, but instead of repeating the line from &#8220;Step 3&#8243; for every tag, it uses a more elegant approach (which in this case just means less code). But instead of posting the complete source code (which you can look at by download the script), let me just show you  the meat of the script (extracting the 8 tags and passing them to lame for conversion):</p>
<pre>for tag in TITLE ARTIST ALBUM DATE COMMENT TRACKNUMBER TRACKTOTAL GENRE; do
    eval "$tag=\"`metaflac --show-tag=$tag "$FLAC" | sed 's/.*=//'`\""
done

flac -cd "$FLAC" | lame -V "$V" --tt "$TITLE" --ta "$ARTIST" --tl "$ALBUM" --ty "$DATE" --tc "$COMMENT" --tn "$TRACKNUMBER/$TRACKTOTAL" --tg "$GENRE" - "$MP3"</pre>
<p>&nbsp;</p>
<h2>Update (2012-06-05)</h2>
<p>I have updated the script a little. It&#8217;s now possible to append a &#8220;mtime&#8221; after the three arguments. When adding &#8220;mtime&#8221;, the script will only start the conversion if the MP3 file does not exist yet or the FLAC file is newer than the MP3 file.</p>
<p>This will avoid unnecessary conversions in case the MP3 is newer than the FLAC file, which indicates it is up-to-date. This is useful when using this script to somehow manage your library as it will reduce a large number of conversions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tordeu.com/?feed=rss2&#038;p=184</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
