<?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>Sam Lanning</title>
	<atom:link href="http://samlanning.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://samlanning.com</link>
	<description>Student Web Developer with a passion for technology</description>
	<lastBuildDate>Mon, 01 Apr 2013 00:49:05 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>My Festive Desktop Setup</title>
		<link>http://samlanning.com/2012/12/03/my-festive-desktop-setup/</link>
		<comments>http://samlanning.com/2012/12/03/my-festive-desktop-setup/#comments</comments>
		<pubDate>Mon, 03 Dec 2012 20:35:58 +0000</pubDate>
		<dc:creator>Sam Lanning</dc:creator>
				<category><![CDATA[Geeky Goodness]]></category>
		<category><![CDATA[Random Jabberings]]></category>

		<guid isPermaLink="false">http://samlanning.com/?p=75</guid>
		<description><![CDATA[Term has now finished, and I haven&#8217;t yet posted a blog post since my first one announcing the new site. So forgive me in advance for any mistakes, or anything that isn&#8217;t written perfectly, or not explained well&#8230; I need to find my footing with this whole blog thing. Of course corrections are welcome! It&#8217;s [...]]]></description>
				<content:encoded><![CDATA[<p>Term has now finished, and I haven&#8217;t yet posted a blog post since my first one announcing the new site. So forgive me in advance for any mistakes, or anything that isn&#8217;t written perfectly, or not explained well&#8230; I need to find my footing with this whole blog thing. Of course corrections are welcome!</p>

<p>It&#8217;s December, so it&#8217;s time to turn my computer desktop into a catalyst for festive spirits. Just because it&#8217;s the holidays, it does not mean I&#8217;m going to be using my computer less, or even working less. If anything it means that I&#8217;ll be using my computer more, as I will not be doing academic work on paper (eww paper!).</p>

<p>I find that ensuring that you listen to plenty of Christmas music, have decorations up, and have plenty of green red and yellow on your monitors can really help get you in the Christmas Spirit, lift your mood, and keep you there! A couple of years before, I hadn&#8217;t done any of this, listened to my usual music while coding, and had my usual bland (in comparison) desktop. This resulted in the feeling that I had effectively missed Christmas. Christmas day came around and I didn&#8217;t even feel like it was Christmas, I had none of the &#8220;build up&#8221; and excitement beforehand, didn&#8217;t watch any Christmas films, and come January, I felt like I had missed out. I vowed never again to let Christmas slip by my this way again!</p>

<span id="more-75"></span>

<h2>The Setup</h2>

<p>Before I start explaining what&#8217;s what, here&#8217;s a screenshot of the setup when I have an additional monitor plugged into my laptop</p>

<p><a href="/wp-content/uploads/2012/12/2012-12-03-160513_3280x1050_scrot.png"><img src="/wp-content/uploads/2012/12/2012-12-03-160513_3280x1050_scrot.png" alt="" title="2012-12-03-160513_3280x1050_scrot" width="100%"/></a></p>

<h3>Wallpaper</h3>
<p>Now, the Wallpaper is probably the most attractive feature of this whole setup, it is certainly the centrepiece. You can grab your own copy of it here: <a href="http://overkill766.deviantart.com/art/Xmas-Wallpaper-187303984" title="Wallpaper Source" target="_blank">http://overkill766.deviantart.com/art/Xmas-Wallpaper-187303984</a>. I use <a href="http://feh.finalrewind.org/" target="_blank">feh</a> to set my wallpaper in my x session.</p>

<h3>Window Manager</h3>
<p>I&#8217;ve been using Linux for quite a while now (specifically <a href="http://fedoraproject.org/" title="Fedora" target="_blank">Fedora</a>). A while a go, I noticed Gnome was beginning to freeze sporadically, for minutes at a time sometimes, and I was starting to get tired of the feel for gnome, and the &#8220;clunkyness&#8221; of it. It was certainly time for a new window manager. A <a href="http://mikejsavage.github.com/" title="mate of mine" target="_blank">mate of mine</a> introduced me to the window manager <a href="http://dwm.suckless.org/" title="dwm" target="_blank">dwm</a>, and I have to say it is a work of art. Less than 2000 lines of C code, the idea is you edit a configuration file config.h (which is yet another c script) and compile whenever you want to change anything, as a result, it is blazing fast and works brilliantly with no dependencies other than X itself. The developers also <a href="http://dwm.suckless.org/patches/" title="encourage patching" target="_blank">encourage patching</a> (modifying the source code) by it&#8217;s users to add/remove features and customise functionality. I am using a patched version (I&#8217;ve forgotten what was patched, it may have been the colours for the tabs). I start dwm in run-level 3 after starting X (I haven&#8217;t set up my own login manager yet&#8230; mey do that if/when I switch to arch linux).</p>

<h4>Status Bar Text</h4>
<p>DWM allows you to change the text in the top right hand corner of the active screen (this is it&#8217;s placement in an unmodified version of dwm) via the command <code>xsetroot</code> which is part of the X library. Specifically using the <code>-name</code> parameter. DWM uses the current name of the root window as the text for this status area, this allows you to write programs using anything you like that call this system command to change the status text.</p>
<p>For example, this shell command will set the status text to my name:</p>
<pre>
&gt; xsetroot -name Sam\ Lanning
</pre>
<p>The Result:</p>
<p style="text-align: center"><img src="/wp-content/uploads/2012/12/2012-12-03-192931_153x42_scrot.png" alt="" title="2012-12-03-192931_153x42_scrot" width="153" height="42" class="alignnone size-full wp-image-90" /></p>
<p>You can quickly see how you can easily have a lot of fun with this&#8230; I decided to create a python script that would have a loop, and wait 1 second at the end of each iteration. It would be super basic, not have a large footprint, and I got an excuse to write a little python script. This is not the most beautiful of python scripts, and there&#8217;s plenty of string manipulation and concatenation, I needed something quick and dirty at the time of writing, and have no real need to change it because well&#8230; it works, and i dont need any more functionality for the time being&#8230;</p>
<pre>
<span style="color:#036a07">'''
    Custom Status Bar Program for DWM
'''</span>

<span style="color:#0c450d;font-weight:700">import</span> subprocess
<span style="color:#0c450d;font-weight:700">import</span> time
<span style="color:#0c450d;font-weight:700">import</span> re

<span style="color:#00f;font-weight:700">while</span> <span style="color:#585cf6;font-weight:700">True</span>:
    status <span style="color:#00f;font-weight:700">=</span> <span style="color:#036a07"><span style="color:#00f;font-weight:700">u</span>''</span>
    
    <span style="color:#06f;font-style:italic"># Battery</span>
    acpi_1 <span style="color:#00f;font-weight:700">=</span> subprocess.Popen(<span style="color:#036a07">'acpi'</span>, <span style="font-style:italic">shell</span><span style="color:#00f;font-weight:700">=</span><span style="color:#585cf6;font-weight:700">False</span>, <span style="font-style:italic">stdout</span><span style="color:#00f;font-weight:700">=</span>subprocess.PIPE)
    batt_status_all <span style="color:#00f;font-weight:700">=</span> acpi_1.communicate()
    <span style="color:#00f;font-weight:700">if</span> batt_status_all[<span style="color:#0000cd">0</span>] <span style="color:#00f;font-weight:700">==</span> <span style="color:#036a07">''</span>:
        status <span style="color:#00f;font-weight:700">+=</span> <span style="color:#036a07">'NO BATT'</span>
    <span style="color:#00f;font-weight:700">else</span>:
        batt_status <span style="color:#00f;font-weight:700">=</span> batt_status_all[<span style="color:#0000cd">0</span>][<span style="color:#0000cd">11</span>:<span style="color:#00f;font-weight:700">-</span><span style="color:#0000cd">1</span>] <span style="color:#06f;font-style:italic"># Trim batt number and \n</span>
        batt_status_split <span style="color:#00f;font-weight:700">=</span> re.compile(<span style="color:#036a07">'(,?)\s'</span>).split( batt_status )
        batt_percent <span style="color:#00f;font-weight:700">=</span> batt_status_split[<span style="color:#0000cd">2</span>][:<span style="color:#00f;font-weight:700">-</span><span style="color:#0000cd">1</span>]
        no_batt <span style="color:#00f;font-weight:700">=</span> <span style="color:#3c4c72;font-weight:700">len</span>( batt_status_split )
        batt_low <span style="color:#00f;font-weight:700">=</span> batt_percent <span style="color:#00f;font-weight:700">&lt;</span> <span style="color:#0000cd">20</span>
        batt_discharging <span style="color:#00f;font-weight:700">=</span> batt_status_split[<span style="color:#0000cd">0</span>] <span style="color:#00f;font-weight:700">==</span> <span style="color:#036a07">'Discharging'</span>
    
        <span style="color:#00f;font-weight:700">if</span> batt_discharging:
            <span style="color:#00f;font-weight:700">if</span> batt_low:
                status <span style="color:#00f;font-weight:700">+=</span> <span style="color:#036a07">'LOW BATT: '</span> <span style="color:#00f;font-weight:700">+</span>  batt_status_split[<span style="color:#0000cd">2</span>]
            <span style="color:#00f;font-weight:700">else</span>:
                status <span style="color:#00f;font-weight:700">+=</span> batt_status_split[<span style="color:#0000cd">2</span>]
                <span style="color:#00f;font-weight:700">if</span> <span style="color:#3c4c72;font-weight:700">len</span>( batt_status_split ) <span style="color:#00f;font-weight:700">>=</span> <span style="color:#0000cd">5</span>:
                    status <span style="color:#00f;font-weight:700">+=</span> <span style="color:#036a07">' | Remaining: '</span> <span style="color:#00f;font-weight:700">+</span> batt_status_split[<span style="color:#0000cd">4</span>]
        <span style="color:#00f;font-weight:700">else</span>:
            status <span style="color:#00f;font-weight:700">+=</span> <span style="color:#036a07">'CHARGING: '</span> <span style="color:#00f;font-weight:700">+</span> batt_status_split[<span style="color:#0000cd">2</span>]
    
    <span style="color:#06f;font-style:italic"># Termal</span>
    acpi_2 <span style="color:#00f;font-weight:700">=</span> subprocess.Popen([<span style="color:#036a07">'acpi'</span>,<span style="color:#036a07">'-t'</span>], <span style="font-style:italic">shell</span><span style="color:#00f;font-weight:700">=</span><span style="color:#585cf6;font-weight:700">False</span>, <span style="font-style:italic">stdout</span><span style="color:#00f;font-weight:700">=</span>subprocess.PIPE)
    temp_status <span style="color:#00f;font-weight:700">=</span> acpi_2.communicate()[<span style="color:#0000cd">0</span>][<span style="color:#0000cd">11</span>:<span style="color:#00f;font-weight:700">-</span><span style="color:#0000cd">1</span>];
    temp_status_split <span style="color:#00f;font-weight:700">=</span> re.compile(<span style="color:#036a07">"(,?)\s"</span>).split( temp_status )
    <span style="color:#00f;font-weight:700">if</span> temp_status_split[<span style="color:#0000cd">0</span>] <span style="color:#00f;font-weight:700">==</span> <span style="color:#036a07">'ok'</span>:
        status <span style="color:#00f;font-weight:700">+=</span> <span style="color:#036a07"><span style="color:#00f;font-weight:700">u</span>' | '</span> <span style="color:#00f;font-weight:700">+</span> temp_status_split[<span style="color:#0000cd">2</span>] <span style="color:#00f;font-weight:700">+</span> <span style="color:#036a07"><span style="color:#00f;font-weight:700">u</span>'C'</span>
    <span style="color:#00f;font-weight:700">else</span>:
        status <span style="color:#00f;font-weight:700">+=</span> <span style="color:#036a07">' | TEMP ERROR '</span>
    

    <span style="color:#06f;font-style:italic"># Time</span>
    status <span style="color:#00f;font-weight:700">+=</span> <span style="color:#036a07">' | '</span> <span style="color:#00f;font-weight:700">+</span> time.strftime(<span style="color:#036a07">'<span style="color:#c5060b;font-weight:700">%A</span> <span style="color:#c5060b;font-weight:700">%d</span>/<span style="color:#c5060b;font-weight:700">%m</span>/<span style="color:#c5060b;font-weight:700">%Y</span> <span style="color:#c5060b;font-weight:700">%I</span>:<span style="color:#c5060b;font-weight:700">%M</span>:<span style="color:#c5060b;font-weight:700">%S</span> <span style="color:#c5060b;font-weight:700">%p</span>'</span>)

    
    <span style="color:#06f;font-style:italic"># Update Status Bar</span>
    subprocess.Popen([<span style="color:#036a07">'xsetroot'</span>,<span style="color:#036a07">'-name'</span>,status])
    
    time.sleep(<span style="color:#0000cd">1</span>)

</pre>
<p>I plan to add stuff like Dropbox statuses, network connectivity and what I have mounted later on, at which point I will probably make it a little more prettier.</p>

<h4>How it all works together</h4>
<p>As my computer is set to boot into run level 3 (multi user mode with no graphics), the first thing I get is a shell asking for username and password. After I login, I am immediately in bash, so run <code>startx</code> which launches the x server and session, and then runs <code>~.xinitrc</code>.
<p>Here&#8217;s my <code>~/.xinitrc</code> file:</p>
<pre>
<span style="color:#06f;font-style:italic">#!/bin/sh</span>
<span style="color:#06f;font-style:italic">#</span>
<span style="color:#06f;font-style:italic"># ~/.xinitrc</span>
<span style="color:#06f;font-style:italic">#</span>
<span style="color:#06f;font-style:italic"># Executed by startx (run your window manager from here)</span>

python <span style="color:#00f;font-weight:700">~</span>/Programs/desktop-environment/status/status.py <span style="color:#00f;font-weight:700">&amp;</span>

feh  --bg-center <span style="color:#036a07">'/home/sam/wallpapers/xmas/screen1.jpg'</span> <span style="color:#036a07">'/home/sam/wallpapers/xmas/screen2.jpg'</span> <span style="color:#00f;font-weight:700">&amp;</span>

dwm
</pre>

<h4>Source</h4>
<p>I&#8217;ve packaged my patched version of dwm, slock and dmenu along with the config header for dwm, my status script and additional scripts I use for media control. I cant remember exactly what I&#8217;ve changed from the original, and producing diffs would take too much time and could be something you do yourself if you are interested in that. I would also encourage you to download the latest versions of <a href="http://dwm.suckless.org/" title="dwm" target="_blank">dwm</a>, <a href="http://tools.suckless.org/slock" target="_blank">slock</a> and <a href="http://tools.suckless.org/dmenu/" target="_blank">dmenu</a>, and then modify them yourself. It&#8217;s the <em>proper</em> way to do it.</p>

<p><ul><li><a href="https://samlanning.com/wp-content/uploads/2012/12/desktop-environment.tar.gz" target="_blank">desktop-environment.tar.gz</a></li><li><a href="https://samlanning.com/wp-content/uploads/2012/12/desktop-environment.zip" title="desktop-environment.zip" target="_blank">desktop-environment.zip</a></li></ul><p>

<h3>Terminal Emulator</h3>
<p>Now what I consider probably the most important part of this makeover, the terminal emulator. Now some of you might cringe at this but&#8230; I use <code>gnome-terminal</code>. Now hold up, the reason I still use it is, well, because it works, and it works nicely. It has good customisation options and works straight out of the box with fonts and well, it&#8217;s there. I haven&#8217;t found a need to switch, it works, it&#8217;s not slow enough that i can tell a difference, and it plays nicely with dwm. In fact, most of the gnome apps play nicely, I use <code>gnome-calculator</code> when I need a calculator, and I use <code>gnome-control-center</code> when I need to manage stuff like audio cards or networks. Anyway enough of the excuses, I have basically changed the colour scheme, as you can tell in the screenshot, and I think it&#8217;s pretty&#8230; Some people may not like the colours, but it&#8217;s difficult to keep the colours sensibly ranged over christmas-y colours while making the distinguishable enough and readable. I think I have struck a right balance here, and its entirely up to you to agree or disagree otherwise&#8230;</p>
<p>Here&#8217;s a preview:</p>
<p><a href="/wp-content/uploads/2012/12/2012-12-03-201512_1293x678_scrot.png"><img src="/wp-content/uploads/2012/12/2012-12-03-201512_1293x678_scrot.png" alt="" title="Terminal Preview" width="100%"/></a></p>
<p><a href="/wp-content/uploads/2012/12/gconf.xml_.tar.gz">You can download the profile here</a></p>

<p>That&#8217;s about as festive as my desktop goes! Hope you liked the post, there&#8217;s much more to come!</p>]]></content:encoded>
			<wfw:commentRss>http://samlanning.com/2012/12/03/my-festive-desktop-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Website!</title>
		<link>http://samlanning.com/2012/10/31/new-website/</link>
		<comments>http://samlanning.com/2012/10/31/new-website/#comments</comments>
		<pubDate>Wed, 31 Oct 2012 04:17:10 +0000</pubDate>
		<dc:creator>Sam Lanning</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Random Jabberings]]></category>

		<guid isPermaLink="false">http://samlanning.com/?p=24</guid>
		<description><![CDATA[So i finally took the time to redo my website, this time in the form of a WordPress Blog. Created a WordPress theme from scratch, using BootStrap. It didn&#8217;t take as long as I thought it would, after recently coding up a new theme for my College&#8217;s JCR Website (http://jcr.stcatz.ox.ac.uk) creating themes have come with [...]]]></description>
				<content:encoded><![CDATA[<p>So i finally took the time to redo my website, this time in the form of a WordPress Blog. Created a <a href="http://wordpress.org" target="_blank">WordPress</a> theme from scratch, using <a href="http://twitter.github.com/bootstrap/" target="_blank">BootStrap</a>. It didn&#8217;t take as long as I thought it would, after recently coding up a new theme for my College&#8217;s JCR Website (<a href="http://jcr.stcatz.ox.ac.uk" target="_blank">http://jcr.stcatz.ox.ac.uk</a>) creating themes have come with more and more ease. Granted this is by no means a complete theme, there are plenty more things I need to do to tidy it up, and there&#8217;s plenty of stuff that is hardcoded that needs to be moved over to the admin panel. But I got it to a state where it is functional, and I can start to use it.</p>

<p>Eventually I plan to release this theme as Open Source, but there&#8217;s a long way to go until then. And much tidying up to do. But a milestone has been reached today!</p>

<p>I have to say, after working with <a href="http://twitter.github.com/bootstrap/" target="_blank">BootStrap</a> for two projects now, I&#8217;m beginning to like it more and more. It really does insanely speed up the process of front-end development. I would recommend that those who haven&#8217;t give it a try as soon as you get the chance!</p>

<p>Anyway, I think I&#8217;ll call this a day! It&#8217;s 5 am and a job well done i think! <img src='http://samlanning.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://samlanning.com/2012/10/31/new-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
