<?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>handyfloss &#187; cli</title>
	<atom:link href="http://handyfloss.net/tag/cli/feed/" rel="self" type="application/rss+xml" />
	<link>http://handyfloss.net</link>
	<description>Because FLOSS is handy, isn&#039;t it?</description>
	<lastBuildDate>Mon, 21 May 2012 06:44:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Desktop environment manipulation from the command line</title>
		<link>http://handyfloss.net/2011.01/desktop-environment-manipulation-from-the-command-line/</link>
		<comments>http://handyfloss.net/2011.01/desktop-environment-manipulation-from-the-command-line/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 12:59:34 +0000</pubDate>
		<dc:creator>isilanes</dc:creator>
				<category><![CDATA[Free software and related beasts]]></category>
		<category><![CDATA[about me]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[Compiz]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[gaming]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[regnum online]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://handyfloss.net/?p=1189</guid>
		<description><![CDATA[I recently discovered Regnum Online, a very good MMORPG, with two interesting properties: it has a native Linux version, and is free to download and play (NGD, its owner, gets revenue through so called &#8220;premium items&#8221;, which are sold for real money. Premium items are not really necessary to play, but include convenience items like [...]]]></description>
			<content:encoded><![CDATA[<p>I recently discovered <a href="http://www.regnumonlinegame.com/">Regnum Online</a>, a very good <a href="http://en.wikipedia.org/wiki/MMORPG">MMORPG</a>, with two interesting properties: it has a native Linux version, and is free to download and play (NGD, its owner, gets revenue through so called &#8220;premium items&#8221;, which are sold for real money. Premium items are not really necessary to play, but include convenience items like mounts, to travel faster than on foot).</p>
<p>It so happens that Regnum can be played either in windowed mode, or fullscreen. Obviously the latter takes advantage of the whole screen, but sadly it can not be minimized or alt-tabbed to a different window. Being able to minimize the Regnum window and switching to another task is interesting, for example, to leave your character resting after a battle (it takes some time to heal back to normality), and checking your e-mail meanwhile. However, playing in windowed mode feels uncomfortable, with not all the screen being used, and having your desktop bars above and/or below the window you are playing on.</p>
<p>To have the advantages of both windowed and fullscreen mode at the same time (and none of their disadvantages), I thought of the following: I can play on 1440&#215;900 resolution (my whole screen), hiding the top and bottom bars (I use <a href="http://en.wikipedia.org/wiki/GNOME">GNOME</a>, with both bars), and getting rid of the window decoration of the Regnum window (which would eat some of the 900 vertical pixels). While we are at it, it would be cool to stop <a href="http://en.wikipedia.org/wiki/Compiz Fusion">Compiz Fusion</a> before running Regnum (to dedicate the whole video card to the game), and starting it again after closing it.</p>
<p>The problem is, I do not like to have autohiding panels in GNOME, and I like window decorations and Compiz effects, so the desktop settings for playing would have to be turned on before playing, and off after that. The next problem in the line is that I don&#8217;t like performing repetitive tasks such as pointing, clicking and choosing options from menus every time I feel like playing a game. Since I already click a button to start Regnum, it would be cool to have all configuration stuff happen by just clicking that same button. Obviously, that means automating all the configuration by placing the corresponding commands in a script, and making the Regnum button execute that script.</p>
<p><b>Stopping Compiz</b></p>
<p>That part was easy. We want to switch from Compiz to <a href="http://en.wikipedia.org/wiki/Metacity">Metacity</a>, which can be done with:</p>
<p><code>metacity --replace</code></p>
<p><b>Autohiding GNOME panels</b></p>
<p>Some googling yielded <a href="http://ubuntu-tutorials.com/2009/09/21/completely-hide-gnome-panel/">this ubuntu-tutorials page</a>, which led me to:</p>
<p><code>gconftool-2 --set "/apps/panel/toplevels/top_panel_screen0/auto_hide" --type bool "true"<br />
gconftool-2 --set "/apps/panel/toplevels/bottom_panel_screen0/auto_hide" --type bool "true"</code></p>
<p><b>Eliminating window decorations</b></p>
<p>All you can google about it will lead you to a little wonder called <a href="http://burtonini.com/blog/computers/devilspie/">Devil&#8217;s Pie</a>. In short, it&#8217;s a kind of daemon that checks for windows that match some user-defined rules, and performs on them the corresponding user-defined actions.</p>
<p>In my case, I defined a rule (in <tt>~/.devilspie/regnum.ds</tt>):</p>
<pre>
<code>(if
    (is (application_name) "Untitled window")
    (begin
        (undecorate)
    )
)</code>
</pre>
<p>Running <tt>devilspie</tt> from the command line will show the properties of all open windows, which will help you create the appropriate condition for the rule. In my case, apparently the final Regnum window is identified only as &#8220;Untitled window&#8221;.</p>
<p><b>Running Regnum, and waiting for it to finish</b></p>
<p>Waiting for Regnum to finish is not trivial, since once fully running it returns the control to the shell. For that reason, the following will not work:</p>
<pre>
<code>$ echo "start"
$ regnum-online
$ echo "end"</code>
</pre>
<p>It will echo &#8220;start&#8221;, then start Regnum, then echo &#8220;end&#8221;, while Regnum is still running. To fix that, I added a loop to my script, which only exits once Regnum has finished. There must be more elegant and less hacky ways of doing it, but this one works:</p>
<pre>
<code>while [[ -n "`ps aux| grep -e regnum-online -e "./game" | grep -v grep`" ]]
do
    sleep 5
done</code>
</pre>
<p>Every 5 seconds, it runs some <tt>ps</tt> command, and exits when the output is empty. The command itself is a simple <tt>grep</tt> to a <tt>ps</tt>, adding the <tt>grep -v grep</tt> so that the <tt>grep</tt> command is not catched by itself.</p>
<p><b>After closing Regnum, and whole script</b></p>
<p>So, after the while loop above exits, all we have to do is undo the settings changes we just did, and exit. The whole script would read:</p>
<pre>
<code>#!/bin/bash

# Substitute Compiz with Metacity:
metacity --replace &amp;

# Autohide top and bottom pannels:
gconftool-2 --set "/apps/panel/toplevels/top_panel_screen0/auto_hide" --type bool "true"
gconftool-2 --set "/apps/panel/toplevels/bottom_panel_screen0/auto_hide" --type bool "true"

# Run devilspie, to remove decoration in Regnum Online windows:
/usr/bin/devilspie &amp;

# Run Regnum Online:
/usr/bin/regnum-online

# Wait until RO finishes:
while [[ -n "`ps aux| grep -e regnum-online -e "./game" | grep -v grep`" ]]
do
    sleep 5
done

# Kill devilspie:
killall devilspie

# Show top and bottom pannels:
gconftool-2 --set "/apps/panel/toplevels/top_panel_screen0/auto_hide" --type bool "false"
gconftool-2 --set "/apps/panel/toplevels/bottom_panel_screen0/auto_hide" --type bool "false"

# Run Compiz again:
compiz --replace --sm-disable --ignore-desktop-hints ccp --loose-binding --indirect-rendering &amp;</code>
</pre>
<p>Finally, I just named this script &#8220;RegnumRun.sh&#8221;, made it executable, placed it in a suitable place, and associated the Regnum icon on my top panel with RegnumRun.sh, instead of with <tt>regnum-online</tt> directly, and voilà: every time I click on that icon I get to play Regnum with purpose-chosen settings, and I get my regular settings back once I exit Regnum.</p>
]]></content:encoded>
			<wfw:commentRss>http://handyfloss.net/2011.01/desktop-environment-manipulation-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trivial use of md5sum</title>
		<link>http://handyfloss.net/2009.11/trivial-use-of-md5sum/</link>
		<comments>http://handyfloss.net/2009.11/trivial-use-of-md5sum/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 13:52:50 +0000</pubDate>
		<dc:creator>isilanes</dc:creator>
				<category><![CDATA[Free software and related beasts]]></category>
		<category><![CDATA[about me]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://handyfloss.net/?p=886</guid>
		<description><![CDATA[I just made use of the md5sum command in a rather simple situation which could have been more troublesome to handle with other means. The following scenario highlights, IMHO, how command line greatly simplifies some tasks. I have a file file.txt, and a collection of files file.txt.N, where N = 1, 2, 3&#8230; I know [...]]]></description>
			<content:encoded><![CDATA[<p>I just made use of the <a href="http://en.wikipedia.org/wiki/md5sum">md5sum</a> command in a rather simple situation which could have been more troublesome to handle with other means. The following scenario highlights, IMHO, how <a href="http://en.wikipedia.org/wiki/command line">command line</a> greatly simplifies some tasks.</p>
<p>I have a file <tt>file.txt</tt>, and a collection of files <tt>file.txt.N</tt>, where N = 1, 2, 3&#8230; I know that the former is a copy of one of the latter, but I don&#8217;t know which. I could have run <a href="http://en.wikipedia.org/wiki/diff">diff</a> on all the possible matches, but I would have had to run it for every N until a match was found. However, md5sum comes to rescue. I can just run:</p>
<div class="codeblock">
% md5sum file.txt*
</div>
<p>And check which <tt>file.txt.N</tt> has a MD5 signature equal to <tt>file.txt</tt>, so that one would be the match. This solution is still a bit annoying, because I have to visually search matches for a long string. Not to worry! Unix is our friend once again. Recover the above command with a single press to the &#8220;up&#8221; arrow, then extend the command a tiny bit:</p>
<div class=" codeblock">
% md5sum file.txt* | sort
</div>
<p>Now, since the MD5 signatures are sorted, the match for our <tt>file.txt</tt> (if there is any), will appear right after the line for <tt>file.txt</tt>.</p>
<p>I challenge the reader to accomplish the same task as readily, comfortably and successfully in Windows or Mac, or in Linux without the command line.</p>
]]></content:encoded>
			<wfw:commentRss>http://handyfloss.net/2009.11/trivial-use-of-md5sum/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

