<?xml version="1.0" encoding="iso-8859-15"?>
<!-- generator="Kukkaisvoima version 15" -->
<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/"
>
<channel>
<title>Tim's Bits and Pieces: Linux</title>
<link>http://blog.timp.com.au</link>
<description>My personal blog, covering many random topics</description>
<pubDate>Fri, 17 Jun 2011 23:03:54 +0200</pubDate>
<lastBuildDate>Fri, 17 Jun 2011 23:03:54 +0200</lastBuildDate>
<generator>http://23.fi/kukkaisvoima/</generator>
<language>en</language>
<item>
<title>Sting like a bee
</title>
<link>http://blog.timp.com.au/sting_like_a_bee%3A2011-06-17%3AHumour%2CLinux%2COddities</link>
<comments>http://blog.timp.com.au/sting_like_a_bee%3A2011-06-17%3AHumour%2CLinux%2COddities#comments</comments>
<pubDate>Fri, 17 Jun 2011 23:03:54 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>Humour</category>
<category>Linux</category>
<category>Oddities</category>
<guid isPermaLink="false">http://blog.timp.com.au/sting_like_a_bee%3A2011-06-17%3AHumour%2CLinux%2COddities/</guid>
<description><![CDATA[ <p><a
 [...]]]></description>
<content:encoded><![CDATA[
<p><a
 	href='https://github.com/MrMEEE/bumblebee/commit/a047be85247755cdbe0acce6'>Sting
 	like a [Bumble]bee</a></p>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/sting_like_a_bee%3A2011-06-17%3AHumour%2CLinux%2COddities/feed/</wfw:commentRss>
</item>
<item>
<title>Speedup of Trac Static Content
</title>
<link>http://blog.timp.com.au/speedup_of_trac_static_content%3A2010-08-25%3AComputers%2CLinux%2CWork</link>
<comments>http://blog.timp.com.au/speedup_of_trac_static_content%3A2010-08-25%3AComputers%2CLinux%2CWork#comments</comments>
<pubDate>Wed, 25 Aug 2010 23:03:54 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>Computers</category>
<category>Linux</category>
<category>Work</category>
<guid isPermaLink="false">http://blog.timp.com.au/speedup_of_trac_static_content%3A2010-08-25%3AComputers%2CLinux%2CWork/</guid>
<description><![CDATA[ <p>At <a href='http://codesion.com'>work</a> I recently spent some time working on
 [...]]]></description>
<content:encoded><![CDATA[
<p>At <a href='http://codesion.com'>work</a> I recently spent some time working on
 getting our <a href='http://codesion.com/screenshots/wiki-hosting.shtml'>hosted
 	Trac</a> to run faster. I found one simple little trick that gave up to a
 20% speed improvement, so I thought I'd share it here.</p>
 
 <p>The basic idea is that Trac has a lot of overhead due to executing a pile of
 Python code for each requested file including static content like the logos,
 background images, CSS, <acronym title="Latin: Et Cetera; English: and so
 on">etc</acronym>. If you tell Apache just to skip the Python code
 for the static content you can save a lot of time and processing power. All the
 default static content is under
 "<em>/python/library/path</em>/site-packages/trac/htdocs" which Trac servers up
 as "/chrome/common/". Basically a request for
 http://server.com/trac/chrome/common/logo.png will get a file from somewhere
 like /usr/lib/python2.5/site-packages/trac/htdocs/logo.png on the harddisk. To
 skip Trac for this we want to add something like the following to the Apache
 configuration (AliasMatch is part of <a
 	href='http://httpd.apache.org/docs/2.2/mod/mod_alias.html#aliasmatch'>mod_alias</a>):</p>
 
 <pre class='code'>
 	AliasMatch ^/(.+)/chrome/common(.*) /usr/lib/python2.5/site-packages/trac/htdocs$2
 </pre>
 
 <p>This matches any request for a path that matches
 /<em>something</em>/chrome/common/<em>something_else</em>, and then sends back
 the file located at
 /usr/lib/python2.5/site-packages/trac/htdocs/<em>something_else</em>; preventing
 the Trac Python code from running. Since there is about a dozen images, CSS
 files, and JavaScript files for each Trac page the time saved by this very
 quickly adds up.</p>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/speedup_of_trac_static_content%3A2010-08-25%3AComputers%2CLinux%2CWork/feed/</wfw:commentRss>
</item>
<item>
<title>Slackware 64 Bit
</title>
<link>http://blog.timp.com.au/slackware_64_bit%3A2009-05-20%3AComputers%2CLinux</link>
<comments>http://blog.timp.com.au/slackware_64_bit%3A2009-05-20%3AComputers%2CLinux#comments</comments>
<pubDate>Wed, 20 May 2009 23:03:54 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>Computers</category>
<category>Linux</category>
<guid isPermaLink="false">http://blog.timp.com.au/slackware_64_bit%3A2009-05-20%3AComputers%2CLinux/</guid>
<description><![CDATA[ <p>Slackware now has an official <a href="http://slackware.com/">64-bit
 [...]]]></description>
<content:encoded><![CDATA[
<p>Slackware now has an official <a href="http://slackware.com/">64-bit
     port</a>, so far it's only available for people who run -current, but
 be available as an alternative architecture for the next release (Slackware
 13). Whoo!</p>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/slackware_64_bit%3A2009-05-20%3AComputers%2CLinux/feed/</wfw:commentRss>
</item>
<item>
<title>Awk and Trac.ini
</title>
<link>http://blog.timp.com.au/awk_and_tracini%3A2009-05-05%3AComputers%2CHowto%2CLinux%2CScripting</link>
<comments>http://blog.timp.com.au/awk_and_tracini%3A2009-05-05%3AComputers%2CHowto%2CLinux%2CScripting#comments</comments>
<pubDate>Tue, 05 May 2009 23:03:53 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>Computers</category>
<category>Howto</category>
<category>Linux</category>
<category>Scripting</category>
<guid isPermaLink="false">http://blog.timp.com.au/awk_and_tracini%3A2009-05-05%3AComputers%2CHowto%2CLinux%2CScripting/</guid>
<description><![CDATA[ <p>You'll notice I'm posting late again, for which I blame <a
 [...]]]></description>
<content:encoded><![CDATA[
<p>You'll notice I'm posting late again, for which I blame <a
     href="http://en.wikipedia.org/wiki/Space_Trilogy">C.S. Lewis</a>, and since
 he's dead he can't defend himself from this <strike>unfounded accusation</strike>
 completely serious and non-trivial explanation for my tardiness.</p>
 
 <p>As for actually post, I work as a support guy for a Subversion
 hosting company. We also host <a href="http://trac.edgewall.org/">Trac</a>, so
 part of my job is occasionally setting up <a
     href="http://trac.edgewall.org/wiki/TracTicketsCustomFields">custom ticket
     fields</a> for customers. This involves editing the <a
     href="http://trac.edgewall.org/wiki/TracIni">trac.ini</a>, a simple text
 file. This is fairly easy when you just have to modify one Trac instance, but
 every now and again I have to modify a couple of dozen files. I have tried this
 using <a href="http://en.wikipedia.org/wiki/Sed"><code>sed</code></a> before, but this is a prime example of the the "When
 all you've got is a hammer, every problem is a nail" fallacy. I'd been sort of
 interested in learning more about <a
     href="http://en.wikipedia.org/wiki/AWK"><code>awk</code></a> and this seemed
 like a prime opportunity to "learn by doing", and now I'll reinforce with
 "learning by teaching". So with out further ado here's my short script
 interspersed with an explanation of how it works, and a complete copy of the
 code at the bottom.</p>
 
 <div class="code">
     <font color="#ff1493">BEGIN</font>&nbsp;{ i = <font
         color="#00cd00">0</font>&nbsp;}<br />
 </div>
 <p>The <code>BEGIN</code> section is a special section that is run once before
 processing the file, it can be used for setting variables, as I have done here.
 The <code>i</code> variable, a more descriptive name would have been good,
 stores the state of the script.</p>
 
 <div class="code">
     {<br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>if</b></font>&nbsp;( i ==
     <font color="#00cd00">0</font>&nbsp;) { <font
         color="#0000ff"><b>print</b></font>&nbsp;}<br />
 </div>
 <p>The <code>{</code> starts the main <code>awk</code> script, which is run once
 for each line in the file being processed. This first line simply prints out the
 input line being examined if <code>i</code> equals zero, which it does in the
 initial state of the program.</p>
 
 <div class="code">
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>else</b></font>&nbsp;<br />
     &nbsp;&nbsp;&nbsp;&nbsp;{<br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
         color="#0000ff"><b>if</b></font>&nbsp;( i == <font
         color="#00cd00">1</font>&nbsp;) { <br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
         color="#0000ff"><b>print</b></font>&nbsp;<font color="#00cd00">&quot;#
         Ticket Custom Section</font><font color="#ff1493">\n</font><font
         color="#00cd00">&quot;</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i =
     <font color="#00cd00">2</font>&nbsp;}<br />
 </div>
 <p>The next section is the <code>else</code> clause for the preceding
 <code>if</code> clause, which executes it's own if-else pair. The
 <code>if</code> clause executes if <code>i</code> equals one, which it does if
 we have just passed the "<code>[ticket-custom]</code>" line in the trac.ini
 file. This section prints out the required custom ticket definitions and changes
 <code>i</code> to two, which will prevent anything from being written until it
 gets to the end of the custom ticket section, see below. You need to change the
 <code>print</code> statement to print the the required ticket custom section of
 course; it might be more readable to use a series of individual statements
 rather than just one.</p>
 
 <div class="code">
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
         color="#0000ff"><b>else</b></font>&nbsp;{ <font
         color="#0000ff"><b>if</b></font>&nbsp;( <font
         color="#ff1493">$0</font>&nbsp;~ <font color="#00cd00">/</font><font
         color="#ff1493">\[</font><font color="#ff1493">.*</font><font
         color="#ff1493">\]</font><font color="#00cd00">/</font>&nbsp;) { <font
         color="#0000ff"><b>print</b></font>&nbsp;<font
         color="#ff1493">;</font>&nbsp;i = <font color="#00cd00">0</font>&nbsp;}
     }<br />
     &nbsp;&nbsp;&nbsp;&nbsp;}<br />
 </div>
 <p>This next line is executed if <code>i</code> doesn't equal zero or one,
 meaning that we are currently in the custom field section. It's a single short
 <code>if</code> statement that checks if the line being processed
 (<code>$0</code>) matches (<code>~</code>) a regular expression, in this case
 <code>/\[.*\]/</code>. This will match any line that contains a "[" followed by
 a series of characters, followed by a "]"; basically a trac.ini section head. So
 if it finds the start of a new section in the file it will print it out, and
 then set <code>i</code> back to zero, which means it will just print out the
 rest of the lines in the file.</p>
 
 <div class="code">
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>if</b></font>&nbsp;( <font
         color="#ff1493">$0</font>&nbsp;== <font
         color="#00cd00">&quot;[ticket-custom]&quot;</font>&nbsp;) { i = <font
         color="#00cd00">1</font>&nbsp;}<br />
     }<br />
 </div>
 <p>Then here's the final line which is a simple <code>if</code> that is run for each line
 in the file and checks if the line is the start of the custom field section
 (<code>[ticket-custom]</code>), and if so sets <code>i</code> to one; the result
 of which is show above.</p>
 
 <p>Since the code is probably slightly unclear unless you can see the whole
 thing here it is:</p>
  
 <div class="code">
     <font color="#ff1493">BEGIN</font>&nbsp;{ i = <font
         color="#00cd00">0</font>&nbsp;}<br />
     {<br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>if</b></font>&nbsp;( i ==
     <font color="#00cd00">0</font>&nbsp;) { <font
         color="#0000ff"><b>print</b></font>&nbsp;}<br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>else</b></font>&nbsp;<br />
     &nbsp;&nbsp;&nbsp;&nbsp;{<br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
         color="#0000ff"><b>if</b></font>&nbsp;( i == <font
         color="#00cd00">1</font>&nbsp;) { <br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
         color="#0000ff"><b>print</b></font>&nbsp;<font color="#00cd00">&quot;#
         Ticket Custom Section</font><font color="#ff1493">\n</font><font
         color="#00cd00">&quot;</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i =
     <font color="#00cd00">2</font>&nbsp;}<br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font
         color="#0000ff"><b>else</b></font>&nbsp;{ <font
         color="#0000ff"><b>if</b></font>&nbsp;( <font
         color="#ff1493">$0</font>&nbsp;~ <font color="#00cd00">/</font><font
         color="#ff1493">\[</font><font color="#ff1493">.*</font><font
         color="#ff1493">\]</font><font color="#00cd00">/</font>&nbsp;) { <font
         color="#0000ff"><b>print</b></font>&nbsp;<font
         color="#ff1493">;</font>&nbsp;i = <font color="#00cd00">0</font>&nbsp;}
     }<br />
     &nbsp;&nbsp;&nbsp;&nbsp;}<br />
     &nbsp;&nbsp;&nbsp;&nbsp;<br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>if</b></font>&nbsp;( <font
         color="#ff1493">$0</font>&nbsp;== <font
         color="#00cd00">&quot;[ticket-custom]&quot;</font>&nbsp;) { i = <font
         color="#00cd00">1</font>&nbsp;}<br />
     }<br />
 </div>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/awk_and_tracini%3A2009-05-05%3AComputers%2CHowto%2CLinux%2CScripting/feed/</wfw:commentRss>
</item>
<item>
<title>Countdown in a Shell Script
</title>
<link>http://blog.timp.com.au/countdown_in_a_shell_script%3A2009-04-07%3AComputers%2CScripting%2CLinux</link>
<comments>http://blog.timp.com.au/countdown_in_a_shell_script%3A2009-04-07%3AComputers%2CScripting%2CLinux#comments</comments>
<pubDate>Tue, 07 Apr 2009 23:03:53 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>Computers</category>
<category>Scripting</category>
<category>Linux</category>
<guid isPermaLink="false">http://blog.timp.com.au/countdown_in_a_shell_script%3A2009-04-07%3AComputers%2CScripting%2CLinux/</guid>
<description><![CDATA[ <p>Tuesday's still the <a
 [...]]]></description>
<content:encoded><![CDATA[
<p>Tuesday's still the <a
     href="/archives/2009/04/04/battery_state_monitor_script/index.html">weekend</a> right? ;-)</p>
 
 <p>Anyhow here's a little code snippet for inserting a count down into a shell
 script. Simply put this before whatever you want to delay, and then make sure
 that the first argument you pass to the script is the number of seconds to
 wait. An example of the sort of thing you might want to use this for is taking
 screenshots.</p>
 
 <div class="code">
     <font color="#ee0000">#!/bin/bash</font><br />
 
     <font color="#0000ff"><b>for </b></font>i <font color="#0000ff"><b>in</b></font>
         &nbsp;<font color="#cd00cd">$(</font><font color="#ff1493">seq </font>
         <font color="#cd00cd">$1</font><font color="#ff1493">&nbsp;</font>
         <font color="#00cd00">-1</font><font color="#ff1493">&nbsp;</font>
         <font color="#00cd00">1</font><font color="#cd00cd">)</font>; 
         <font color="#0000ff"><b>do</b></font><br />
     
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>echo</b></font>
         <font color="#00cd00">&nbsp;</font><font color="#cd00cd">$i</font><br />
     
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>sleep</b></font>
         &nbsp;<font color="#00cd00">1</font><br />
     
     <font color="#0000ff"><b>done</b></font><br />
     <font color="#0000ff"><b>echo</b></font><font color="#00cd00">&nbsp;0</font><br />
 
     <font color="#cd00cd">$2</font>
 </div>
 
 <p>For example if you run it like this: <code>./countdown.sh 5 "echo Blast
     Off"</code> you'll get the following output:</p>
 
 <div class="code">
     <b>$ ./countdown.sh 5 "echo Blast Off"</b><br />
     5<br />
     4<br />
     3<br />
     2<br />
     1<br />
     0<br />
     Blast Off<br />
     <b>$</b>
 </div>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/countdown_in_a_shell_script%3A2009-04-07%3AComputers%2CScripting%2CLinux/feed/</wfw:commentRss>
</item>
<item>
<title>Battery State Monitor Script
</title>
<link>http://blog.timp.com.au/battery_state_monitor_script%3A2009-04-04%3AComputers%2CScripting%2CLinux</link>
<comments>http://blog.timp.com.au/battery_state_monitor_script%3A2009-04-04%3AComputers%2CScripting%2CLinux#comments</comments>
<pubDate>Sat, 04 Apr 2009 23:03:53 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>Computers</category>
<category>Scripting</category>
<category>Linux</category>
<guid isPermaLink="false">http://blog.timp.com.au/battery_state_monitor_script%3A2009-04-04%3AComputers%2CScripting%2CLinux/</guid>
<description><![CDATA[ <p>Oops, completely missed posting last weekend, mostly just because I'm too
 [...]]]></description>
<content:encoded><![CDATA[
<p>Oops, completely missed posting last weekend, mostly just because I'm too
 easily distracted. Such is life, hopefully I'll do two or three posts this weekend
 to even it up.</p> 
 <p>This is a simple script I wrote to notify me whenever my battery is running
 low on power. Basically to use it you just create a new shell script with the
 following in it and then run it using <code>bash ~/bin/battery_monitor.sh &amp;</code>
 in your .xinitrc script. This should then check your battery status every minute
 and if it's below ten minutes remaining it will produce a warning message, after
 generating a warning it will wait five minutes before checking again to make
 sure it doesn't get really annoying.</p>
 <div class="code">
     <font color="#ee0000">#!/bin/bash</font><br />
     <font color="#ee0000"># Simple shell script that runs as a daemon to check the status of a Laptops</font><br />
     <font color="#ee0000"># battery and produce an error message every five minutes if it get's to</font><br />
     <font color="#ee0000"># less than 10 minutes of charge remaining and is not plugged in.</font><br />
     <br />
     <font color="#ee0000"># Copyright (c) 2009, Timothy Pollard</font><br />
     <font color="#ee0000"># </font><br />
     <font color="#ee0000"># Redistribution and use with or without modification, are permitted provided</font><br />
     <font color="#ee0000"># that the above Copyright notification remains complete.</font><br />
     <br />
     <font color="#ee0000"># The file that contains the state of the Battery</font><br />
     <font color="#008b8b">PROC_FILE</font>=/proc/acpi/battery/BAT1/state<br />
     <br />
     <font color="#0000ff"><b>while </b></font><font color="#0000ff"><b>true</b></font><font color="#0000ff"><b>;</b></font><font color="#0000ff"><b>&nbsp;</b></font><font color="#0000ff"><b>do</b></font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#ee0000"># Get the charging state from the PROC_FILE, this should be one of &quot;charged&quot;,</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#ee0000"># &quot;charging&quot;, or &quot;discharging&quot;</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#008b8b">CHARGING_STATE</font>=<font color="#cd00cd">$(</font><font color="#ff1493">cat </font><font color="#cd00cd">$PROC_FILE</font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>grep</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">^charging state:</font><font color="#0000ff"><b>&quot;</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>sed</b></font><font color="#ff1493">&nbsp;-e </font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">s/charging state: *//g</font><font color="#0000ff"><b>&quot;</b></font><font color="#cd00cd">)</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;<br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#cd00cd">$CHARGING_STATE</font>&nbsp;<font color="#0000ff"><b>==</b></font>&nbsp;<font color="#00cd00">&quot;discharging&quot;</font>&nbsp;<font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ee0000"># Get the current rate and remaining capacity</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008b8b">CURRENT_RATE</font>=<font color="#cd00cd">$(</font><font color="#ff1493">cat </font><font color="#cd00cd">$PROC_FILE</font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>grep</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">^present rate:</font><font color="#0000ff"><b>&quot;</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>sed</b></font><font color="#ff1493">&nbsp;-e </font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">s/present rate: *//g</font><font color="#0000ff"><b>&quot;</b></font><font color="#ff1493">&nbsp;-e </font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">s/ mW//g</font><font color="#0000ff"><b>&quot;</b></font><font color="#cd00cd">)</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008b8b">REMAINING_CAPACITY</font>=<font color="#cd00cd">$(</font><font color="#ff1493">cat </font><font color="#cd00cd">$PROC_FILE</font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>grep</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">^remaining capacity:</font><font color="#0000ff"><b>&quot;</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>sed</b></font><font color="#ff1493">&nbsp;-e </font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">s/remaining capacity: *//g</font><font color="#0000ff"><b>&quot;</b></font><font color="#ff1493">&nbsp;-e </font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">s/ mWh//g</font><font color="#0000ff"><b>&quot;</b></font><font color="#cd00cd">)</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;<br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ee0000"># Remaining battery life in minutes</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008b8b">REMAINING_TIME</font>=<font color="#cd00cd">$(</font><font color="#ff1493">echo </font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">scale=4; </font><font color="#cd00cd">$REMAINING_CAPACITY</font><font color="#00cd00">/</font><font color="#cd00cd">$CURRENT_RATE</font><font color="#00cd00">*60</font><font color="#0000ff"><b>&quot;</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;bc </font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>sed</b></font><font color="#ff1493">&nbsp;-e </font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">s/\..*//g</font><font color="#0000ff"><b>&quot;</b></font><font color="#cd00cd">)</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;<br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#cd00cd">$REMAINING_TIME</font>&nbsp;<font color="#0000ff"><b>-lt</b></font>&nbsp;<font color="#00cd00">10</font>&nbsp;<font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmessage -center <font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">There are currently only </font><font color="#cd00cd">$REMAINING_TIME</font><font color="#00cd00">&nbsp;minutes of battery life remaining.</font><font color="#0000ff"><b>&quot;</b></font><br />
     <br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ee0000"># Sleep for 4 minutes (4*60=240), this combined with the default</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ee0000"># sleep of 60 seconds assures that you are only alerted once every 5</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ee0000"># minutes</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>sleep</b></font>&nbsp;<font color="#00cd00">240</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>fi</b></font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>fi</b></font><br />
     <br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#ee0000"># Delay the next run for 60 seconds</font><br />
     &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>sleep</b></font>&nbsp;<font color="#00cd00">60</font><br />
     <font color="#0000ff"><b>done</b></font><br />
 </div>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/battery_state_monitor_script%3A2009-04-04%3AComputers%2CScripting%2CLinux/feed/</wfw:commentRss>
</item>
<item>
<title>Some tips on speeding up Slackware 12.2 Boot
</title>
<link>http://blog.timp.com.au/some_tips_on_speeding_up_slackware_122_boot%3A2009-02-14%3AComputers%2CHowto%2CLinux</link>
<comments>http://blog.timp.com.au/some_tips_on_speeding_up_slackware_122_boot%3A2009-02-14%3AComputers%2CHowto%2CLinux#comments</comments>
<pubDate>Sat, 14 Feb 2009 23:03:54 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>Computers</category>
<category>Howto</category>
<category>Linux</category>
<guid isPermaLink="false">http://blog.timp.com.au/some_tips_on_speeding_up_slackware_122_boot%3A2009-02-14%3AComputers%2CHowto%2CLinux/</guid>
<description><![CDATA[ <p>My <a href="http://slackware.com">Slackware</a> laptop had decently fast boot
 [...]]]></description>
<content:encoded><![CDATA[
<p>My <a href="http://slackware.com">Slackware</a> laptop had decently fast boot
 times (a little over a minute), but I'm impatient and decided to see if I could
 speed it up some more. Here's the changes I made and the results down the
 bottom. This is on a Dell Vostro 1510, with 4GB of ram and a 2.1GHz Core 2 Duo.
 Obviously the results will vary depending on your hardware.</p>
 
 <ul>
     <li><a href="#lilo_and_kernel">Lilo and the Kernel</a></li>
     <li><a href="#rc.M">/etc/rc.d/rc.M</a></li>
     <li><a href="#rc.inet1">/etc/rc.d/rc.inet1</a></li>
     <li><a href="#results">The Results</a></li>
     <li><a href="#refs">References</a></li>
 </ul>
 
 <h3 id="lilo_and_kernel">Lilo and the Kernel</h3>
 <p>Probably the easiest piece of low hanging fruit is Lilo's "compact" option.
 This gets rid of the "Loading Linux................" pause straight after the
 Lilo prompt.</p>
 <blockquote class="code">
 <font color="#ee0000"># Start LILO global section</font><br />
 <font color="#0000ff"><b>boot</b></font>&nbsp;<font color="#ff1493">=</font>&nbsp;<font color="#00cd00">/dev/sda</font><br />
 <font color="#0000ff"><b>compact</b></font><br />
 </blockquote>
 
 <p>Another popular step that can provide not inconsiderable speed advantages is to compile
 yourself a <a href="http://slackwiki.org/Kernel_Compilation">custom
 kernel</a>.</p>
 
 <h3 id="rc.M">/etc/rc.d/rc.M</h3>
 <p>There are quite a few options in rc.M that you can either run in the
 background (add &amp; to the line) to speed up the boot times, and there's even a few that you can just
 comment out and ignore.</p>
 
 <p>Starting from the top and going down we have the optical drive symlinks,
 simply add an "&amp;" to the end of the "<span class="code">/bin/sh
     /lib/udev/rc.optical-symlinks</span>" line in the following code segment:</p>
 <blockquote class="code">
 <font color="#ee0000"># If we're using udev, make /dev/cdrom and any other optical drive symlinks</font><br />
 <font color="#ee0000"># if some udev rule hasn't made them already:</font><br />
 <font color="#0000ff"><b>if </b></font>grep -wq sysfs /proc/mounts <font color="#0000ff"><b>&amp;&amp;</b></font>&nbsp;grep -wq tmpfs /proc/filesystems<font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;&nbsp;<font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>!</b></font>&nbsp;grep -wq nohotplug /proc/cmdline <font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/lib/udev/rc.optical-symlinks <font color="#0000ff"><b>-a</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/etc/rc.d/rc.udev <font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/bin/sh /lib/udev/rc.optical-symlinks <font color="#0000ff"><b>&amp;</b></font><br />
 &nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff"><b>fi</b></font><br />
 &nbsp;&nbsp;<font color="#0000ff"><b>fi</b></font><br />
 <font color="#0000ff"><b>fi</b></font><br />
 </blockquote>
 
 <p>After that there's fc-cache, gtk-update-icon-cache, and ldconfig; these can be run
 manually whenever you install a new Font, icon set, or library, so I simply
 commented out these lines:</p>
 
 <blockquote class="code">
 <font color="#ee0000">## Update the X font indexes:</font><br />
 <font color="#ee0000">#if [ -x /usr/bin/fc-cache ]; then</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;echo &quot;Updating X font indexes:&nbsp;&nbsp;/usr/bin/fc-cache -f &amp;&quot;</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;/usr/bin/fc-cache -f</font><br />
 <font color="#ee0000">#fi</font><br />
 </blockquote>
 
 <blockquote class="code">
 <font color="#ee0000">## Update any existing icon cache files:</font><br />
 <font color="#ee0000">#if find /usr/share/icons 2&gt; /dev/null | grep -q icon-theme.cache ; then</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;for theme_dir in /usr/share/icons/* ; do</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;&nbsp;&nbsp;if [ -r ${theme_dir}/icon-theme.cache ]; then</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Updating icon-theme.cache in ${theme_dir}...&quot;</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/bin/gtk-update-icon-cache -t -f ${theme_dir} 1&gt; /dev/null 2&gt; /dev/null</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;&nbsp;&nbsp;fi</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;done</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;# This would be a large file and probably shouldn't be there.</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;if [ -r /usr/share/icons/icon-theme.cache ]; then</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;Deleting icon-theme.cache in /usr/share/icons...&quot;</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;&nbsp;&nbsp;/usr/bin/gtk-update-icon-cache -t -f /usr/share/icons 1&gt; /dev/null 2&gt; /dev/null</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;&nbsp;&nbsp;rm -f /usr/share/icons/icon-theme.cache</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;fi</font><br />
 <font color="#ee0000">#fi</font><br />
 </blockquote>
 
 <blockquote class="code">
 <font color="#ee0000">## Update all the shared library links:</font><br />
 <font color="#ee0000">## Can do this manually after installing new libraries</font><br />
 <font color="#ee0000">#if [ -x /sbin/ldconfig ]; then</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;echo &quot;Updating shared library links:&nbsp;&nbsp;/sbin/ldconfig&quot;</font><br />
 <font color="#ee0000">#&nbsp;&nbsp;/sbin/ldconfig</font><br />
 <font color="#ee0000">#fi</font><br />
 </blockquote>
 
 <p>Then there's another stack of services that I start running in the background
 by adding ampersands:</p>
 
 <blockquote class="code">
 <font color="#ee0000"># Start networking daemons:</font><br />
 <font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/etc/rc.d/rc.inet2 <font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;<font color="#0000ff"><b>&nbsp;. </b></font>/etc/rc.d/rc.inet2 <font color="#0000ff"><b>&amp;</b></font><br />
 <font color="#0000ff"><b>fi</b></font><br />
 </blockquote>
 
 <blockquote class="code">
 <font color="#ee0000"># Start the Network Time Protocol daemon:</font><br />
 <font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/etc/rc.d/rc.ntpd <font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;&nbsp;sh /etc/rc.d/rc.ntpd start <font color="#0000ff"><b>&amp;</b></font><br />
 <font color="#0000ff"><b>fi</b></font><br />
 </blockquote>
 
 <blockquote class="code">
 <font color="#ee0000"># SCIM and other GTK+ input methods like this file kept updated:</font><br />
 <font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/usr/bin/gtk-query-immodules<font color="#00cd00">-2</font>.<font color="#00cd00">0</font>&nbsp;<font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;&nbsp;<font color="#0000ff"><b>echo</b></font><font color="#00cd00">&nbsp;</font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">Updating gtk.immodules:&nbsp;&nbsp;gtk-query-immodules-2.0 &gt; /etc/gtk-2.0/gtk.immodules</font><font color="#0000ff"><b>&quot;</b></font><br />
 &nbsp;&nbsp;/usr/bin/gtk-query-immodules<font color="#00cd00">-2</font>.<font color="#00cd00">0</font>&nbsp;<font color="#0000ff"><b>&gt;</b></font>&nbsp;/etc/gtk<font color="#00cd00">-2</font>.<font color="#00cd00">0</font>/gtk.immodules <font color="#00cd00">2</font><font color="#0000ff"><b>&gt;</b></font>&nbsp;/dev/null <font color="#0000ff"><b>&amp;</b></font><br />
 <font color="#0000ff"><b>fi</b></font><br />
 </blockquote>
 
 <blockquote class="code">
 <font color="#ee0000"># Start the print spooling system.&nbsp;&nbsp;This will usually be LPRng (lpd) or CUPS.</font><br />
 <font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/etc/rc.d/rc.cups <font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;&nbsp;<font color="#ee0000"># Start CUPS:</font><br />
 &nbsp;&nbsp;/etc/rc.d/rc.cups start <font color="#0000ff"><b>&amp;</b></font><br />
 <font color="#0000ff"><b>elif</b></font>&nbsp;<font color="#0000ff"><b>[</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/etc/rc.d/rc.lprng <font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;&nbsp;<font color="#ee0000"># Start LPRng (lpd):</font><br />
 &nbsp;<font color="#0000ff"><b>&nbsp;. </b></font>/etc/rc.d/rc.lprng start <font color="#0000ff"><b>&amp;</b></font><br />
 <font color="#0000ff"><b>fi</b></font><br />
 </blockquote>
 
 <blockquote class="code">
 <font color="#ee0000"># Start netatalk. (a file/print server for Macs using Appletalk)</font><br />
 <font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/etc/rc.d/rc.atalk <font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;&nbsp;/etc/rc.d/rc.atalk <font color="#0000ff"><b>&amp;</b></font><br />
 <font color="#0000ff"><b>fi</b></font><br />
 </blockquote>
 
 <blockquote class="code">
 <font color="#ee0000"># Start the sendmail daemon:</font><br />
 <font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/etc/rc.d/rc.sendmail <font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;<font color="#0000ff"><b>&nbsp;. </b></font>/etc/rc.d/rc.sendmail start <font color="#0000ff"><b>&amp;</b></font><br />
 <font color="#0000ff"><b>fi</b></font><br />
 </blockquote>
 
 <blockquote class="code">
 <font color="#ee0000"># Load ALSA (sound) defaults:</font><br />
 <font color="#0000ff"><b>if </b></font><font color="#0000ff"><b>[</b></font>&nbsp;<font color="#0000ff"><b>-x</b></font>&nbsp;/etc/rc.d/rc.alsa <font color="#0000ff"><b>]</b></font><font color="#0000ff"><b>;</b></font>&nbsp;<font color="#0000ff"><b>then</b></font><br />
 &nbsp;<font color="#0000ff"><b>&nbsp;. </b></font>/etc/rc.d/rc.alsa <font color="#0000ff"><b>&amp;</b></font><br />
 <font color="#0000ff"><b>fi</b></font><br />
 </blockquote>
 
 <h3 id="rc.inet1">/etc/rc.d/rc.inet1</h3>
 <p>Finally I recommend decreasing the DHCP timeout used in rc.inet1; the default
 is 30 seconds (it used to be 60), I decreased mine further down to 15 seconds:
 </p>
 <blockquote class="code">
 <font color="#ee0000"># 30 seconds should be a reasonable default DHCP timeout.&nbsp;&nbsp;60 was too much.&nbsp;&nbsp;:-)</font><br />
 <font color="#0000ff"><b>echo</b></font><font color="#00cd00">&nbsp;</font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">/etc/rc.d/rc.inet1:&nbsp;&nbsp;/sbin/dhcpcd -d -t </font><font color="#cd00cd">${</font><font color="#cd00cd">DHCP_TIMEOUT</font><font color="#cd00cd">[</font><font color="#cd00cd">$i</font><font color="#cd00cd">]</font><font color="#0000ff"><b>:-</b></font><span style="background-color: #ff0000"><font color="#ffffff">15</font></span><font color="#cd00cd">}</font><font color="#00cd00">&nbsp;</font><font color="#cd00cd">${</font><font color="#cd00cd">DHCP_OPTIONS</font><font color="#cd00cd">}</font><font color="#00cd00">&nbsp;</font><font color="#cd00cd">${</font><font color="#cd00cd">1</font><font color="#cd00cd">}</font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">&nbsp;</font>| <font color="#cd00cd">$LOGGER</font><br />
 /sbin/dhcpcd <font color="#ff1493">-d</font>&nbsp;<font color="#ff1493">-t</font>&nbsp;<font color="#cd00cd">${</font><font color="#cd00cd">DHCP_TIMEOUT</font><font color="#cd00cd">[</font><font color="#cd00cd">$i</font><font color="#cd00cd">]</font><font color="#0000ff"><b>:-</b></font><span style="background-color: #ff0000"><font color="#ffffff">15</font></span><font color="#cd00cd">}</font>&nbsp;<font color="#cd00cd">${</font><font color="#cd00cd">DHCP_OPTIONS</font><font color="#cd00cd">}</font>&nbsp;<font color="#cd00cd">${</font><font color="#cd00cd">1</font><font color="#cd00cd">}</font><br />
 </blockquote>
 
 <h3 id="results">The Results</h3>
 <p>Boot time from Lilo to login prompt was approximately one minute thirty
 before I performed these changes, and that decreased to twenty-five seconds.
 Once you include the time from first power on till Lilo it comes to about 35-40
 seconds boot time, plus another five seconds to login and start X. The biggest
 speed increase seems to be from using compact in Lilo and the custom kernel.</p>
 
 <h3 id="refs">References</h3>
 <p>There where a couple other resources on the Internet that got me started on this, and pointed out several of the ideas that I used:
 The <a
     href="http://www.fprimex.com/computers/slackware-linux/tips#booting-faster">section
     on boot speed</a> in the <a
     href="http://www.fprimex.com/computers/slackware-linux/tips#booting-faster">Slackware
     tips</a> article on <a href="http://fprimex.com">f'(x)</a> and an <a
     href="http://groups.google.com/group/alt.os.linux.slackware/">alt.os.linux.slackware</a>
 thread on <a
     href="http://groups.google.com/group/alt.os.linux.slackware/browse_thread/thread/52a606bf38649d3a">boot
     time</a>.</p>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/some_tips_on_speeding_up_slackware_122_boot%3A2009-02-14%3AComputers%2CHowto%2CLinux/feed/</wfw:commentRss>
</item>
<item>
<title>Stuff
</title>
<link>http://blog.timp.com.au/stuff%3A2008-12-12%3AGeneral%2CLinux%2CLinkage%2CMeta</link>
<comments>http://blog.timp.com.au/stuff%3A2008-12-12%3AGeneral%2CLinux%2CLinkage%2CMeta#comments</comments>
<pubDate>Fri, 12 Dec 2008 23:03:54 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>General</category>
<category>Linux</category>
<category>Linkage</category>
<category>Meta</category>
<guid isPermaLink="false">http://blog.timp.com.au/stuff%3A2008-12-12%3AGeneral%2CLinux%2CLinkage%2CMeta/</guid>
<description><![CDATA[ <p>A few things of note:</p>
 [...]]]></description>
<content:encoded><![CDATA[
<p>A few things of note:</p>
 
 <ol>
 <li>I missed a post last week, I'll try and get an extra post up on Sunday or
 Monday to make up for it.</li>
 
 <li>I had one of my pictures posted on <a
 href="http://www.insectpod.com/2008/12/10/wasp-3/">InsectPOD</a></li>
 
 <li><a href="http://slackware.com/">Slackware 12.2</a> was released a couple of
 days ago.</li>
 
 <li>Today's Word of the Day is <a
 href="http://wordsmith.org/words/pollard.html">pollard</a>, cool. :-)</li>
 </ol>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/stuff%3A2008-12-12%3AGeneral%2CLinux%2CLinkage%2CMeta/feed/</wfw:commentRss>
</item>
<item>
<title>Random Backgrounds Script
</title>
<link>http://blog.timp.com.au/random_backgrounds_script%3A2008-08-06%3ALinux%2CComputers%2CScripting</link>
<comments>http://blog.timp.com.au/random_backgrounds_script%3A2008-08-06%3ALinux%2CComputers%2CScripting#comments</comments>
<pubDate>Wed, 06 Aug 2008 23:03:54 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>Linux</category>
<category>Computers</category>
<category>Scripting</category>
<guid isPermaLink="false">http://blog.timp.com.au/random_backgrounds_script%3A2008-08-06%3ALinux%2CComputers%2CScripting/</guid>
<description><![CDATA[ <p>I recently wrote this simple script to allow me to set a random image as my
 [...]]]></description>
<content:encoded><![CDATA[
<p>I recently wrote this simple script to allow me to set a random image as my
 background:</p>
 <blockquote class="code">
     <font color="#ee0000">#!/bin/bash</font><br>
     <font color="#ee0000"># Selects a random jpeg file in the ~/backgrounds/ directory (or it's</font><br>
     <font color="#ee0000"># sub-directories) and makes it the background image.</font><br>
     <font color="#008b8b">file_list</font>=<font color="#cd00cd">$(</font><font color="#0000ff"><b>find</b></font><font color="#ff1493">&nbsp;~/backgrounds/ -name </font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">*.jpg</font><font color="#0000ff"><b>&quot;</b></font><font color="#cd00cd">)</font><br>
     <font color="#008b8b">num_files</font>=<font color="#cd00cd">$(</font><font color="#ff1493">echo </font><font color="#cd00cd">$file_list</font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;wc -w</font><font color="#cd00cd">)</font><br>
     <font color="#008b8b">ran_line_number</font>=<font color="#cd00cd">$((</font><font color="#cd00cd">$RANDOM</font><font color="#ff1493">%</font><font color="#cd00cd">$num_files</font><font color="#ff1493">+</font><font color="#00cd00">1</font><font color="#cd00cd">))</font><br>
     <font color="#008b8b">selected_file</font>=<font color="#cd00cd">$(</font><font color="#ff1493">echo </font><font color="#cd00cd">$file_list</font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;tr </font><font color="#0000ff"><b>&quot;</b></font><font color="#00cd00">&nbsp;</font><font color="#0000ff"><b>&quot;</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>&quot;</b></font><font color="#ff1493">\n</font><font color="#0000ff"><b>&quot;</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>|</b></font><font color="#ff1493">&nbsp;</font><font color="#0000ff"><b>sed</b></font><font color="#ff1493">&nbsp;-n </font><font color="#cd00cd">${</font><font color="#cd00cd">ran_line_number</font><font color="#cd00cd">}</font><font color="#ff1493">p</font><font color="#cd00cd">)</font><br>
     fbsetbg <font color="#cd00cd">$selected_file</font><br>
 </blockquote>
 <p>On most light-weight window managers, like <a
 href="http://blackboxwm.sourceforge.net/">Blackbox</a>, simply copy any images
 you want to use as backgrounds into ~/backgrounds/ and you're good to go. Some
 other Window Managers/Desktop environments look after the desktop background
 themselves so you would have to disable that in their configuration first. If
 you wanted to run this every half hour or something you could put it in your
 crontab, or else you can just set it up so it runs when you start your window
 manager.</p>
 <p class="post_edit">-- Edit 09/05/2009 --</p>
 <p>I've modified the code very slightly, to fix a bug which either didn't exist
 when run with the older version of bash/find I was have been using when I wrote
 this. I've also cleaned up the code a little.</p>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/random_backgrounds_script%3A2008-08-06%3ALinux%2CComputers%2CScripting/feed/</wfw:commentRss>
</item>
<item>
<title>Installing Kazehakase 0.5.1 on Slackware 12
</title>
<link>http://blog.timp.com.au/installing_kazehakase_051_on_slackware_12%3A2008-01-30%3AHowto%2CLinux%2CComputers</link>
<comments>http://blog.timp.com.au/installing_kazehakase_051_on_slackware_12%3A2008-01-30%3AHowto%2CLinux%2CComputers#comments</comments>
<pubDate>Wed, 30 Jan 2008 23:03:54 +0200</pubDate>
<dc:creator>TimP</dc:creator>
<category>Howto</category>
<category>Linux</category>
<category>Computers</category>
<guid isPermaLink="false">http://blog.timp.com.au/installing_kazehakase_051_on_slackware_12%3A2008-01-30%3AHowto%2CLinux%2CComputers/</guid>
<description><![CDATA[ <p>I recently decided to install <a
 [...]]]></description>
<content:encoded><![CDATA[
<p>I recently decided to install <a
 href="http://kazehakase.sourceforge.jp/">Kazehakase</a> 0.5.1 on my computer. As with any
 software installation of Slackware my first step was to check for a SlackBuild
 on <a href="http://slackbuilds.org">SlackBuilds.org</a>. There is <a
 href="http://slackbuilds.org/repository/12.0/network/kazehakase/">one</a> but
 it is for version 0.4.7. OK, that's often not a problem, you just change the
 <code>$VERSION</code> variable to the version you actually want. So I tried that, the
 SlackBuild printed out the usual range of progress reports, <acronym
     title="Latin: Et Cetera; English: and so on">etc</acronym>, then gave me
 this:</p>
 <blockquote class="code">
     gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src -I../../src/bookmarks -I../../src/libegg/pixbufthumbnail -DGTK_DISABLE_DEPRECATED=1 -DGDK_DISABLE_DEPRECATED=1 -DG_LOG_DOMAIN=\"Kazehakase-Utils\" -DG_DISABLE_DEPRECATED=1 -O2 -march=i486 -mtune=i686 -Wall -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wcast-align -MT glib-utils.lo -MD -MP -MF .deps/glib-utils.Tpo -c glib-utils.c  -fPIC -DPIC -o .libs/glib-utils.o<br />
     In file included from glib-utils.c:27:<br />
     glib-utils.h:24:18: error: glib.h: No such file or directory<br />
     glib-utils.h:25:21: error: gtk/gtk.h: No such file or directory<br />
     In file included from glib-utils.c:27:<br />
     glib-utils.h:32: error: expected '=', ',', ';', 'asm' or '__attribute__' before
     'G_END_DECLS'<br />
     make[5]: *** [glib-utils.lo] Error 1<br />
     make[5]: Leaving directory `/tmp/SBo/kazehakase-0.5.1/src/utils'<br />
     make[4]: *** [all] Error 2<br />
     make[4]: Leaving directory `/tmp/SBo/kazehakase-0.5.1/src/utils'<br />
     make[3]: *** [all-recursive] Error 1<br />
     make[3]: Leaving directory `/tmp/SBo/kazehakase-0.5.1/src'<br />
     make[2]: *** [all] Error 2<br />
     make[2]: Leaving directory `/tmp/SBo/kazehakase-0.5.1/src'<br />
     make[1]: *** [all-recursive] Error 1<br />
     make[1]: Leaving directory `/tmp/SBo/kazehakase-0.5.1'<br />
     make: *** [all] Error 2<br />
 </blockquote>
 
 <p>What the? It can't find the libraries? Isn't that what <code>configure</code>
 is supposed to do? Oh, well I guess I'll just modify the SlackBuild to pass the
 locations of the libraries required. It can't find some others as well? Darn, I
 guess I'll have to add them as well.</p>
 <p>Fortunately before I went through adding a dozen different libraries
 locations to the SlackBuild, I noticed to following way up in the
 <code>configure</code> output:</p>
 
 <blockquote class="code">
     checking for GTK+ - version &gt;= 2.12.0... no<br />
     *** Could not run GTK+ test program, checking why...<br />
     *** The test program failed to compile or link. See the file config.log for the<br />
     *** exact error that occured. This usually means GTK+ is incorrectly installed.<br />
 </blockquote>
 
 <p>Wait so one of the required libraries is not present (or in my case the
 version was too low), but <code>configure</code> happily lets my continue with
 the build process anyhow? It should just return an error and quit.</p>
 <p>Fortunately, this is not going to stop me, I'll simply upgrade GTK, so I go
 to the <a href="ftp://ftp.slackware.com/pub/">Slackware FTP site</a> find the
 <a
     href="ftp://ftp.slackware.com/pub/slackware/slackware-12.0/source/l/gtk+2">GTK+2</a>
 official SlackBuild and change the <code>$VERSION</code> to 2.12.5 and
 compile the source from <a href="ftp://ftp.gtk.org/pub/gtk/">ftp.gtk.org</a>. 
 There now I should be able to compile Kazehakase, wait no I need to upgrade <a
     href="ftp://ftp.slackware.com/pub/slackware/slackware-12.0/source/l/glib2">glib2</a> 
 and <a
     href="ftp://ftp.slackware.com/pub/slackware/slackware-12.0/source/l/pango">pango</a>
 before I can upgrade GTK+, so I upgrade them to 2.14.5 and 1.18.4 respectively
 and now I can compile GTK+ 2.12.5, and then finally compile Kazehakase 0.5.1.</p>
 <p>Aaah, the joy of a job well done.</p>
 ]]></content:encoded>
<wfw:commentRss>http://blog.timp.com.au/installing_kazehakase_051_on_slackware_12%3A2008-01-30%3AHowto%2CLinux%2CComputers/feed/</wfw:commentRss>
</item>
</channel>
</rss>
