<?xml version="1.0" encoding="iso-8859-1"?>
        <?xml-stylesheet type="text/css" href="http://www.miek.nl/blog/"?>
<rss version="2.0"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:admin="http://webns.net/mvcb/"
 xmlns:atom="http://www.w3.org/2005/Atom"
>
<channel>
<title>Filed under: eeepc | Miek</title>
<atom:link href="http://www.miek.nl/blog/archives/eeepc/index-rss.xml" rel="self" type="application/rss+xml" />
<link>http://www.miek.nl/blog</link>
<description>Thoughts on (technical) stuff</description>
<dc:language>en-us</dc:language>
<dc:creator>Miek Gieben</dc:creator>
<dc:date>2012-02-04T04:15:11+01:00</dc:date>
<admin:generatorAgent rdf:resource="http://nanoblogger.sourceforge.net" />

<item>
<link>http://www.miek.nl/blog/archives/2008/08/12/eeepc_battery_script_for_2_6_24_and_2_6_25/index.html</link>
<guid isPermaLink="true">http://www.miek.nl/blog/archives/2008/08/12/eeepc_battery_script_for_2_6_24_and_2_6_25/index.html</guid>
<title>Eeepc battery script for 2.6.24 AND 2.6.25</title>
<dc:date>2008-08-12T16:48:25+01:00</dc:date>
<dc:creator>Miek Gieben</dc:creator>
<dc:subject> eeepc, linux</dc:subject>
<description><![CDATA[<p>The new kernel for the EeePC (2.6.25) has deprecated the 
<code>/proc/acpi/battery</code> interface, so I had to write a new
script for use in my <code>zsh</code> prompt.</p>

<p>The script will work in both 2.6.24 <em>and</em> 2.6.25, so without
further ado, here it is. It is written as a function for 
easy inclusion in any prompts.</p>

<pre><code>#!/bin/zsh 
bat() {
PROC=/proc/acpi/battery/BAT0
SYS=/sys/class/power_supply/BAT0/uevent
STATE=
# dc: design capacity, rc: remaining capacity
if [ -f $PROC/info ]; then
    STATE=$PROC/state   # 2.6.24
    dc=$(grep 'last full' &lt; $PROC/info | awk '{ print $4 }')
    rc=$(grep 'remaining' &lt; $PROC/state | awk '{ print $3 }')
elif [ -f $SYS ]; then
    STATE=$SYS          # 2.6.25
    dc=$(grep '\&lt;POWER_SUPPLY_CHARGE_FULL\&gt;' &lt; $SYS | awk -F= '{ print $2 }')
    rc=$(grep '\&lt;POWER_SUPPLY_CHARGE_NOW\&gt;' &lt; $SYS | awk -F= '{ print $2 } ')
else
    exit
fi
p=$(echo 3k $rc $dc / 100 \* p | dc )

if grep -iq discharging $STATE; then
    printf " %02d" "$p"
else
    if [ ${p%.*} -lt 100 ]; then
    printf " %02d+" "$p"
    fi
fi
}
bat
</code></pre>

<h2>Update</h2>

<p>Ton Kersten has an even better one which 
saves a few <code>grep</code>s.</p>

<pre><code>#!/bin/zsh 
bat() {
PROC=/proc/acpi/battery/BAT0
SYS=/sys/class/power_supply/BAT0/uevent
STATE=
# dc: design capacity, rc: remaining capacity                                                                           
if [ -f $PROC/info ]
then
    STATE=$PROC/state   # 2.6.24
    dc=$(awk '/last full/ { print $4 }' $PROC/info)
    rc=$(awk '/remaining/ { print $3 }' $PROC/state)
elif [ -f $SYS ]
then
    STATE=$SYS          # 2.6.25
    dc=$(awk -F= '$1 ~ /^POWER_SUPPLY_CHARGE_FULL$/ { print $2 }' $SYS)
    rc=$(awk -F= '$1 ~ /^POWER_SUPPLY_CHARGE_NOW$/  { print $2 }' $SYS)
else
    return 0
fi

p=$(echo 3k $rc $dc / 100 \* p | dc )

if grep -iq discharging $STATE; then
    printf " %02d" "$p"
else
    if [ ${p%.*} -lt 100 ]; then
    printf " %02d+" "$p"
    fi
fi
}
bat
</code></pre>

<h2>Update 2</h2>

<p>Just found that there is also a nice tool, called <code>acpi</code>...which makes
it even more easy:</p>

<pre><code>% acpi -V
Battery 0: Full, 100%
AC Adapter 0: on-line
Thermal 0: ok, 53.0 degrees C
Cooling 0: Processor 0 of 7
</code></pre>]]></description>

</item>
<item>
<link>http://www.miek.nl/blog/archives/2008/08/11/eeepc_doc-purge_script/index.html</link>
<guid isPermaLink="true">http://www.miek.nl/blog/archives/2008/08/11/eeepc_doc-purge_script/index.html</guid>
<title>EeePC doc-purge script</title>
<dc:date>2008-08-11T12:30:23+01:00</dc:date>
<dc:creator>Miek Gieben</dc:creator>
<dc:subject> eeepc, linux</dc:subject>
<description><![CDATA[<p>You want to clean up <code>/usr/share/doc</code> every time you install a package
to safe space. Here is how to do it.</p>

<p>Completely inspired by <code>localepurge</code> (and I stole some code from it).</p>

<p><em>But</em> I wanted to purge stuff in <code>/usr/share/doc/$package</code> too as this
takes too much disk space on <em>my precious</em> (talking about the EeePC
here). If I <em>really</em> need the documentation I will also install the 
package on my server and look at it there.</p>

<p><code>localepurge</code> consists out of two important parts, a hook for <code>dpkg</code>
which is called after each installation. This hook is placed in
<code>/etc/apt/apt.conf.d</code>. And a script that will
actually remove the locales (<code>/usr/sbin/localepurge</code>).</p>

<p>For my needs a actually need to tweak the hook a little and write
a little script. My first thought was to actually look at the
package being installed and only remove the doc-dir for that
package, but a quick search yielded no clue on how to give the name
of the package to <code>DPkg::Post-Invoke</code>. So the next best thing I could
come up with was to delete everything in <code>/usr/share/doc</code> every time.</p>

<h2>DPkg::Post-Invoke</h2>

<p>The <code>Post-Invoke</code> from <code>localepurge</code> looks like this:</p>

<pre><code>DPkg
{
Post-Invoke {"if [ -x /usr/sbin/localepurge ] &amp;&amp; [ $(ps w -p "$PPID"
    | grep -c remove) != 1 ]; then /usr/sbin/localepurge; else exit 0; fi";};
};
</code></pre>

<p>This needs to be tweaked a little for my purposes. I'm storing the
scripts in the dir <code>/home/miekg/bin</code> -- as I'm the sole user of my
EeePC.</p>

<pre><code>DPkg
{
Post-Invoke {"if [ -x /home/miekg/bin/docpurge ] &amp;&amp; [ $(ps w -p "$PPID"
    | grep -c remove) != 1 ]; then /home/miekg/bin/docpurge; else exit 0; fi";};
};
</code></pre>

<p>Save this file in <code>/etc/apt/apt.conf.d</code> as <code>99-docpurge</code>.</p>

<h2>docpurge</h2>

<p>I've named my script <code>docpurge</code> and its a stupid script that just
deletes stuff in <code>/usr/share/doc</code>. For completeness here it is:</p>

<pre><code>#!/bin/bash
# delete stuff in /usr/share/doc

DOCDIR=/usr/share/doc
for i in $DOCDIR/*; do
rm -rf $i
done
</code></pre>]]></description>

</item>
<item>
<link>http://www.miek.nl/blog/archives/2008/04/18/playing_music_on_the_eeepc_with_a_sd_disk_and_mpd_and_gmpcmpc/index.html</link>
<guid isPermaLink="true">http://www.miek.nl/blog/archives/2008/04/18/playing_music_on_the_eeepc_with_a_sd_disk_and_mpd_and_gmpcmpc/index.html</guid>
<title>Playing music on the EeePC with a SD disk and mpd and gmpc/mpc</title>
<dc:date>2008-04-18T20:20:04+01:00</dc:date>
<dc:creator>Miek Gieben</dc:creator>
<dc:subject> eeepc</dc:subject>
<description><![CDATA[<p>I've installed DebianEeepc as per 
<a href="http://wiki.debian.org/DebianEeePC/">this howto</a>. And then did
a <code>apt-get install mpd gmpc mpc</code> for my music.</p>

<h2>suspend script</h2>

<p>I want my suspend to work, but every time I suspended <code>xfdesktop</code>
crashed. Turns out this is due to the stopping of <code>dbus</code>. I've modified
the suspend script to not meddle with <code>dbus</code>. This seemed to have
fixed this particular issue. I've also added an:</p>

<pre><code>fuser -k /media/disk    # kill all users of /media/disk
umount /dev/sdb1        # now it can be umounted
</code></pre>

<p>to the script. This unmounts the disk on suspend. I'm now letting 
<code>xfdesktop</code> (re)mount <code>/dev/sdb1</code> on resume. This
works fine.</p>

<h2>mpd</h2>

<p>Install mpd, and make a symlink from <code>/var/lib/mpd/music</code> to
<code>/media/disk/music</code>. <code>/media/disk</code> is the spot where the SD disk is
mounted by <code>xfdesktop</code>.</p>

<p>The problem with <code>mpd</code> is that is will not start if it cannot find its
music directory. With this symlink trick, this directory is always there
even if the mounting of <code>/dev/sdb1</code> went wrong.</p>

<p>Also modify <code>/etc/mpd.conf</code> to comment out <code>bind_to_address</code> by putting
a <code>#</code> in front of that line. Next restart <code>mpd</code>: <code>/etc/init.d/mpd restart</code></p>

<h2>mpc</h2>

<p><code>mpc</code> rocks. Actually I only need <code>gmpc</code> to load the playlist in <code>mpd</code>.
From then on I use <code>mpc</code>: <code>mpc next</code>,  <code>mpc play</code>, etc. Real easy from 
the cmdline; <code>mpc update</code> also rocks.</p>

<blockquote>
  <p>Now I just plugin my headset, start the music and start compiling and
writing software in the train.</p>
</blockquote>

<p>The EeePC really rocks!</p>]]></description>

</item>
<item>
<link>http://www.miek.nl/blog/archives/2008/04/12/battery_shell_script_for_the_eeepc/index.html</link>
<guid isPermaLink="true">http://www.miek.nl/blog/archives/2008/04/12/battery_shell_script_for_the_eeepc/index.html</guid>
<title>battery shell script for the EeePC</title>
<dc:date>2008-04-12T09:43:04+01:00</dc:date>
<dc:creator>Miek Gieben</dc:creator>
<dc:subject> eeepc, linux</dc:subject>
<description><![CDATA[<p>The battery applet from xfce is a bit flaky, so I've written a shell scriptlet
that will calculate the remaining capacity in the battery.</p>

<p>I'm using zsh here, but this script will work in any shell. 
I'm putting the output of the script on the right side of my 
<a href="http://www.miek.nl/blog/archives/2008/02/20/my_zsh_prompt_setup/index.html">prompt</a>
in
a subdewed grey color. It adds a <code>+</code> on the right when it is charging.</p>

<h2>script</h2>

<pre><code>#!/bin/zsh
dc=$(cat /proc/acpi/battery/BAT0/info | grep 'last full' | awk ' { print $4 }')
rc=$(cat /proc/acpi/battery/BAT0/state | grep 'remaining' | awk ' { print $3 } ')

p=$(echo 3k $rc $dc / 100 \* p | dc ) 
if grep -q discharging /proc/acpi/battery/BAT0/state; then
    printf "%02d" "$p"
else
    printf "%02d+" "$p"
fi
</code></pre>

<h2>xbattbar-acpi</h2>

<p><code>xbattbar-acpi</code> is Anothor tool you will need. It will display a small bar at the bottom of
your (X) screen, showing the remaining capacity. It keeps out of your
way, uses only 3 pixels and works just like the script above.</p>]]></description>

</item>
</channel>
</rss>

