<?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>The Captain's (B)log &#187; shell</title>
	<atom:link href="http://www.threshold-zero.com/cblog/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.threshold-zero.com/cblog</link>
	<description>Noos you can uoos</description>
	<lastBuildDate>Sun, 22 Jan 2012 14:25:59 +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>Conky, Dell i8k Modules, and My First Ubuntu Bash Script</title>
		<link>http://www.threshold-zero.com/cblog/2009/02/15/conky-dell-i8k-modules-and-my-first-ubuntu-bash-script/</link>
		<comments>http://www.threshold-zero.com/cblog/2009/02/15/conky-dell-i8k-modules-and-my-first-ubuntu-bash-script/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 19:29:19 +0000</pubDate>
		<dc:creator>el capitan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Science and Technology]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[conky]]></category>
		<category><![CDATA[i8kutils]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.threshold-zero.com/cblog/?p=186</guid>
		<description><![CDATA[Well, I started playing around with Conky yesterday &#8212; if you haven&#8217;t heard of it before, just know that it&#8217;s a neat little Linux program that runs in your background and uses very little resources that displays a very neat desktop overlay.  (Like in the picture in the Lifehacker article.) Now, some of the stock [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-188 alignleft" title="Conky Screenshot" src="http://www.threshold-zero.com/cblog/wp-content/uploads/2009/02/screenshot.png" alt="Conky Screenshot" width="215" height="139" /></p>
<p>Well, I started playing around with <a href="http://lifehacker.com/5152819/to+dos-weather-and-twitter-on-a-linux-desktop">Conky</a> yesterday &#8212; if you haven&#8217;t heard of it before, just know that it&#8217;s a neat little Linux program that runs in your background and uses very little resources that displays a very neat desktop overlay.  (Like in the picture in the Lifehacker article.)</p>
<p>Now, some of the stock Conky scripts were more than adequate, but I had always wanted my laptop&#8217;s CPU temperature to be displayed as well, so I had to figure out a way to do that.</p>
<p>Now, if you&#8217;re somewhat familiar with tinkering in Linux, you&#8217;ve probably heard of the wonderful &#8220;lm_sensors&#8221; package &#8212; it&#8217;s a neat package for Linux that helps display lots of information about motherboard temps and whatnot.  Unfortunately, due to most laptops &#8220;prorietary-ness,&#8221; lm_sensors does very little for you if you&#8217;re trying to get it to work on a laptop.</p>
<p>Now, I had heard of the &#8220;i8kutils&#8221; package for Linux &#8212; this was a package designed for Dell laptops in particular, to display and control fan and temperature information.</p>
<p>So, with that, I was off to work!</p>
<p>(Note &#8212; these instructions are mostly for Ubuntu/Debian installations, because that&#8217;s what I use.)</p>
<p>First, install the package &#8220;i8kutils&#8221; using your Linux computer&#8217;s package manager (Synaptic, if you&#8217;re using Ubuntu).</p>
<p>Second, add the module &#8220;i8k&#8221; to your &#8220;/etc/modules&#8221; file.  (This will start the process at boottime.)  Restart your laptop.</p>
<p>Third, you&#8217;ll have to create some Conky script files.  I assume you&#8217;ve already had a bit of experience at least installing Conky and starting it up.  If not, play around with the instructions in that Lifehacker article and come back here afterwards.</p>
<p>Now, I noticed that one of my conky script files was a file called &#8220;hddmonit.sh&#8221; which contained the text:</p>
<blockquote><p>#!/bin/bash<br />
echo &#8220;$(nc localhost 7634 | cut -d&#8217;|&#8217; -f4)&#8221;</p></blockquote>
<p>Now, using a little bit of deduction, I figured that this file used a command called &#8220;nc localhost 7634&#8243; to display a little bit of information, and then used pipe commands (the little &#8220;|&#8221; symbol) to further splice the info, extracting just the temperature of my laptop&#8217;s hard drive.</p>
<p>So, while &#8220;nc localhost 7634&#8243; outputted this:</p>
<blockquote><p>|/dev/sda|ST980815A|43|C|</p></blockquote>
<p>Using the command &#8220;(nc localhost 7634 | cut -d&#8217;|&#8217; -f4&#8243; would output just &#8220;43&#8243;, which was the temperature of my hard drive.</p>
<p>(The &#8220;cut&#8221; command splices out specific text from a string it&#8217;s given, in this case the fourth (-f4) chunk of text seperated by a &#8220;|&#8221; chracter.)</p>
<p>Now, I learned that the &#8220;i8k&#8221; module, once loaded, could be accessed with the file at  &#8220;/proc/i8k&#8221;, which just contains a string like:</p>
<blockquote><p>1.0 A32 7GGGGGG 53 -22 1 -22 90300 -1 2</p></blockquote>
<p>From this you can see various Dell-specific information, the important part being &#8220;53&#8243;, which was my current processor temp.  (The items in the string are separated by spaces.)</p>
<p>So, I quickly made myself a new script file called &#8220;i8ktemps.sh&#8221; copying the contents of &#8220;hddmonit.sh&#8221; and changing them to:</p>
<blockquote><p>#!/bin/bash<br />
echo &#8220;$(head /proc/i8k | cut -d&#8217; &#8216; -f4)&#8221;</p></blockquote>
<p>This file, when executed, will just output the fourth &#8220;chunk&#8221; in the file &#8220;/proc/i8k&#8221;, which as you remember is my current processor temp.</p>
<p>Now, I needed to edit my Conky configuration file, which is located in your home folder and is called &#8220;.conkyrc&#8221;.</p>
<p>Then I simply located the line:</p>
<blockquote><p>${font weather:size=28}x ${font}HDD ${execi 1 ~/scripts/hddmonit.sh}C</p></blockquote>
<p>Which displayed my hard drive temperature, and changed it to:</p>
<blockquote><p>${font weather:size=28}x ${font}CPU ${execi 1 ~/scripts/i8ktemps.sh}C HDD ${execi 1 ~/scripts/hddmonit.sh}C</p></blockquote>
<p>Which, when Conky was restarted, would display my hard drive temperature <em>and</em> my current processor temperature.</p>
<p>See?  It&#8217;s not that hard to program this stuff!  I did this all, both programming in the Linux &#8220;Bash&#8221; shell and coding in Conky&#8217;s personal configuration code, without any experience in either.  I just looked at what was there, and changed it.</p>
<p>Relevant Links:</p>
<p><a href="http://www.arachnoid.com/linux/shell_programming.html">http://www.arachnoid.com/linux/shell_programming.html</a></p>
<p><a href="http://ubuntuforums.org/showthread.php?t=411800">http://ubuntuforums.org/showthread.php?t=411800</a></p>
<p><a href="http://www.linuxcommand.org/wss0010.php">http://www.linuxcommand.org/wss0010.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.threshold-zero.com/cblog/2009/02/15/conky-dell-i8k-modules-and-my-first-ubuntu-bash-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

