<?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>hmmm.... &#187; shell</title>
	<atom:link href="http://michael.thegrebs.com/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://michael.thegrebs.com</link>
	<description></description>
	<lastBuildDate>Thu, 27 Oct 2011 18:48:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Weather in Screen Statusbar</title>
		<link>http://michael.thegrebs.com/2008/06/05/weather-in-screen-statusbar/</link>
		<comments>http://michael.thegrebs.com/2008/06/05/weather-in-screen-statusbar/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 03:06:14 +0000</pubDate>
		<dc:creator>mikegrb</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://michael.thegrebs.com/?p=117</guid>
		<description><![CDATA[Caspar Clemens Mierau recently wrote about a nifty Debian package named weather-util and his method for embedding the current temperature into the screen status bar. Quite nifty. I did the same with one small exception, including the predicted probability of &#8230; <a href="http://michael.thegrebs.com/2008/06/05/weather-in-screen-statusbar/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://michael.thegrebs.com/wp-content/uploads/2008/06/screen-weather.png" alt="" title="Weather in Screen" width="279" height="49" class="alignright size-full wp-image-120" /><br />
Caspar Clemens Mierau <a href="http://www.screenage.de/blog/2008/06/04/my-package-of-the-day-weather-util-weather-report-and-forecast-for-the-console/">recently wrote</a> about a nifty Debian package named <tt>weather-util</tt> and his method for embedding the current temperature into the screen status bar.  Quite nifty.  I did the same with one small exception, including the predicted probability of precipitation if it exists.</p>
<p>My one liner that runs from cron (split to multiple lines for readability):</p>
<div class="codecolorer-container text vibrant" 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">&nbsp;weather -iKACY -f | head -n 9 &nbsp;| \<br />
&nbsp; &nbsp; &nbsp;awk '/Temperature/ { print $2 &quot;F&quot; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /Relative/ { print $3 } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /precipitation/ { sub (/ chance of.+$/, &quot;&quot;); print &quot;POP &quot; $NF }' | \<br />
&nbsp; &nbsp; &nbsp;xargs echo &gt; /home/michael/.weather</div></div>
<p>More details on the full implementation in the original post over at <a href="http://www.screenage.de/blog/2008/06/04/my-package-of-the-day-weather-util-weather-report-and-forecast-for-the-console/">Caspar Clemens Mierau&#8217;s blog</a>.  And yes, I stole his loadavg stuff too ;)</p>
<p><strong>UPDATE:</strong></p>
<p>Silly me, upon further investigation, two things to note.  First, the -i option applies only to current conditions and not to the forecast.  In my case I actually want <tt>weather -f ACY</tt> and <tt>/etc/weatherrc</tt> takes care of the rest.  Secondly, the field number for the precipitation percentage changes, oops.  I&#8217;ve correctly accounted for this in the updated awk script above.</p>
<p>After making these changes I decided the awk script was getting a bit long for a single line so I went all out creating <tt>~/bin/weather.awk</tt>:</p>
<div class="codecolorer-container awk vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="awk codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#808080;">#!/usr/bin/awk -f</span><br />
<br />
<span style="color:black;">/</span>Temperature<span style="color:black;">/</span> &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#123;</span> temp = <span style="color:#000088;">$2</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<span style="color:black;">/</span>Relative Humidity<span style="color:black;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> rh = <span style="color:#000088;">$3</span> &nbsp; <span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<span style="color:black;">/</span>precipitation<span style="color:black;">/</span> &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #07D589; font-weight: bold;">sub</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color:black;">/</span> chance of.<span style="color:black;">+</span>$<span style="color:black;">/</span>, <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; precip = <span style="color:#000088;">$NF</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
<span style="color: #C20CB9; font-weight: bold;">END</span><span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #0BD507; font-weight: bold;">print</span> temp <span style="color: #ff0000;">&quot;F &quot;</span> rh <span style="color: #ff0000;">&quot; POP &quot;</span> precip <span style="color: #7a0874; font-weight: bold;">&#125;</span></div></div>
<p>My crontab entry now looks like:</p>
<div class="codecolorer-container text vibrant" 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">*/5 * * * * &nbsp; &nbsp; weather -f ACY | /home/michael/bin/weather.awk &gt; /home/michael/.weather</div></div>
<p>Much simpler.</p>
]]></content:encoded>
			<wfw:commentRss>http://michael.thegrebs.com/2008/06/05/weather-in-screen-statusbar/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

