<?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>martin-grandrath.de &#187; Tools</title>
	<atom:link href="http://martin-grandrath.de/tags/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://martin-grandrath.de</link>
	<description>Ein neues WordPress-Weblog</description>
	<lastBuildDate>Fri, 23 Oct 2009 22:35:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How does your Conky setup look like?</title>
		<link>http://martin-grandrath.de/2008/05/how-does-your-conky-setup-look-like/</link>
		<comments>http://martin-grandrath.de/2008/05/how-does-your-conky-setup-look-like/#comments</comments>
		<pubDate>Thu, 15 May 2008 08:59:54 +0000</pubDate>
		<dc:creator>Martin Grandrath</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Conky]]></category>
		<category><![CDATA[Konfiguration]]></category>
		<category><![CDATA[Screenshot]]></category>
		<category><![CDATA[Setup]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.martin-grandrath.de/?p=48</guid>
		<description><![CDATA[Pavs shows his Conky configuration and asks for other examples.  Here is mine:


# conky configuration ~/.conkyrc

# set to yes if you want Conky to be forked in the background
background no

# Use Xft?
use_xft yes

# Xft font when Xft is enabled
#xftfont Bitstream Vera Sans Mono:size=8
xftfont Terminus:size=8

# Text alpha when using Xft
xftalpha 0.8

# Print everything to console?
# [...]]]></description>
			<content:encoded><![CDATA[<p>Pavs shows his <a href="http://conky.sourceforge.net/" rel="external">Conky</a> configuration and <a href="http://www.linuxhaxor.net/2008/05/14/how-does-your-conky-setup-look-like/" rel="external">asks</a> for other examples.  Here is mine:</p>
<p><a href='http://www.martin-grandrath.de/wp-content/uploads/2008/05/screenshot_2008-05-15.jpg'><img src="http://www.martin-grandrath.de/wp-content/uploads/2008/05/screenshot_2008-05-15-300x240.jpg" alt="Screenshot of my desktop running fvwm and conky" title="Screenshot of my desktop running fvwm and conky" width="300" height="240" class="aligncenter size-medium wp-image-49" /></a></p>
<p><span id="more-48"></span></p>
<pre class="code"># conky configuration ~/.conkyrc

# set to yes if you want Conky to be forked in the background
background no

# Use Xft?
use_xft yes

# Xft font when Xft is enabled
#xftfont Bitstream Vera Sans Mono:size=8
xftfont Terminus:size=8

# Text alpha when using Xft
xftalpha 0.8

# Print everything to console?
# out_to_console no

# mail spool
mail_spool $MAIL

# Update interval in seconds
update_interval 2.0

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window no

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Maximum width of window
maximum_width 140

# Minimum size of text area
minimum_size 140 5

# Draw shades?
draw_shades yes

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Stippled borders?
stippled_borders 8

# border margins
border_margin 0

# border width
border_width 1

# Default colors and also border colors
default_color white
default_shade_color black
default_outline_color white

# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 20
gap_y 5

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about?  This only affects certain objects.
use_spacer yes
#Note: doesn't work in conky 1.2 =(

# stuff after 'TEXT' will be formatted on screen

TEXT
${color slate grey}${time %a, } ${color }${time %e %B %G}
${color slate grey}${time %Z,    }${color }${time %H:%M:%S}
${color slate grey}UpTime: ${color }$uptime
${color slate grey}Kern:${color }$kernel
${color slate grey}CPU:${color } $cpu% ${acpitemp}C
${cpugraph 20,130 000000 ffffff}
${color slate grey}Load: ${color }$loadavg
${color slate grey}Processes: ${color }$processes
${color slate grey}Running:   ${color }$running_processes

${color slate grey}Highest CPU:
${color #ddaa00} ${top name 1}${top_mem cpu 1}
${color lightgrey} ${top name 2}${top cpu 2}
${color lightgrey} ${top name 3}${top cpu 3}
${color lightgrey} ${top name 4}${top cpu 4}

${color slate grey}Highest MEM:
${color #ddaa00} ${top_mem name 1}${top_mem mem 1}
${color lightgrey} ${top_mem name 2}${top_mem mem 2}
${color lightgrey} ${top_mem name 3}${top_mem mem 3}
${color lightgrey} ${top_mem name 4}${top_mem mem 4}

${color slate grey}MEM:  ${color } $memperc%
${membar 3,100}
${color slate grey}SWAP: ${color }$swapperc%
${swapbar 3,100}

${color slate grey}NET:
${color}Up: ${color }${upspeed eth0} k/s
${upspeedgraph eth0 20,130 000000 ffffff}
${color}Down: ${color }${downspeed eth0}k/s${color}
${downspeedgraph eth0 20,130 000000 ffffff}

${color slate grey}Mail:
${color lightgrey} ${new_mails} Inbox
${color lightgrey} ${new_mails $MAIL/some_maildir_folder/} More mail
# ... other mailboxes in the same fashion</pre>
]]></content:encoded>
			<wfw:commentRss>http://martin-grandrath.de/2008/05/how-does-your-conky-setup-look-like/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>&#187;pgp_autoencrypt&#171; für mutt automatisieren</title>
		<link>http://martin-grandrath.de/2008/04/pgp_autoencrypt-fuer-mutt-automatisieren/</link>
		<comments>http://martin-grandrath.de/2008/04/pgp_autoencrypt-fuer-mutt-automatisieren/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 07:41:18 +0000</pubDate>
		<dc:creator>Martin Grandrath</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[GPG]]></category>
		<category><![CDATA[Mutt]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.martin-grandrath.de/?p=15</guid>
		<description><![CDATA[Mutt bietet von sich aus keine Möglichkeit Nachrichten an Empfänger, für die ein öffentlicher GPG-Schlüssel vorhanden ist, automatisch zu verschlüsseln. Man kann zwar die Option pgp_autoencrypt aktivieren, dies führt aber dazu, dass mutt versucht jede E-Mail zu verschlüsseln, was man dann regelmäßig vor dem Absenden deaktivieren muss, wenn der Empfänger keinen public key hat. Die [...]]]></description>
			<content:encoded><![CDATA[<p>Mutt bietet von sich aus keine Möglichkeit Nachrichten an Empfänger, für die ein öffentlicher GPG-Schlüssel vorhanden ist, automatisch zu verschlüsseln. Man kann zwar die Option <code>pgp_autoencrypt</code> aktivieren, dies führt aber dazu, dass mutt versucht <em>jede</em> E-Mail zu verschlüsseln, was man dann regelmäßig vor dem Absenden deaktivieren muss, wenn der Empfänger keinen public key hat. Die Alternative (<code>pgp_autoencrypt</code> deaktivieren) ist auch nicht sehr benutzerfreundlich, weil man hier viel zu leicht vergessen kann, die Verschlüsselung im Einzelfall zu aktivieren.<br />
<span id="more-15"></span></p>
<h3>Abhilfe</h3>
<p>Abhilfe schafft die Möglichkeit die automatische Verschlüsselung zunächst global zu deaktivieren und mit so genannten <code>send-hook</code>s für einzelne Empfängeradressen (eben diejenigen, für die ein Schlüssel vorhanden ist) wieder zu aktivieren. In der <code>~/.muttrc</code> sieht das Ganze dann so aus:</p>
<pre class="code">send-hook . 'unset pgp_autoencrypt'
send-hook '~t my-friend@example.com' 'set pgp_autoencrypt'</pre>
<p>Die erste Zeile deaktiviert (unset) automatische Verschlüsselung für alle Empfänger (der &#8216;.&#8217; trifft immer zu). In der zweiten Zeile wird nun die Verschlüsselung wieder aktiviert und zwar immer dann, wenn eine Mail an <code>my-friend@example.com</code> adressiert wird (der Schalter &#8216;<code>~t</code>&#8216; bezieht das Suchmuster auf das Empfänger-Feld (To:). Den passenden Schlüssel kann mutt dann selbst ermitteln, sofern <code>pgp_list_pubring_command</code> korrekt gesetzt ist.</p>
<p>Nun ist es alles andere als praktikabel für jeden einzelnen Empfänger, der einen GPG-Schlüssel besitzt, eine separate Zeile in der Konfigurationsdatei hinzuzufügen, zumal diese Information ja bereits existiert: im public keyring. Netterweise bietet GPG eine komfortable Möglichkeit, die Liste der vorhandenen Schlüssel automatisiert zu verarbeiten und zwar mit Hilfe der Schalter &raquo;<code>--list-keys --with-colons</code>&raquo;. Das Ergebnis ist eine Liste mit 15 durch Doppelpunkte getrennten Feldern. Für unsere Zwecke benötigen wir nur drei davon:</p>
<ul>
<li>Feld 1 enthält den Typ der Zeile. Uns interessieren nur diejenigen vom Typ <code>pub</code> und <code>uid</code>.</li>
<li>Feld 2 enthält den berechneten trust level. Ich habe mich dafür entschieden, alle Schlüssel zu berücksichtigen, denen ich mindestens &raquo;marginally&laquo; (&#8217;m') vertraue. Des Weiteren steht &#8216;f&#8217; für &raquo;fully&laquo; und &#8216;u&#8217; für &raquo;ultimately&laquo; trusted.</li>
<li>Feld 10 enthält die eigentliche UID, also den Namen und die E-Mail-Adresse.</li>
</ul>
<p>Als regulärer Ausdruck ergibt sich damit</p>
<pre class="code">/^(uid|pub):[mfu]:(.*:){7}.* &lt;(.+@.+)&gt;:/</pre>
<p>Die vollständige Dokumentation dieses Formats findet sich übrigens in der Datei <code>DETAILS.gz</code> im Dokumentationsverzeichnis von GnuPG (z.B. bei Debian <code>/usr/share/doc/gnupg/</code>).</p>
<h3>Alles zusammen</h3>
<p>Das folgende Script prüft zunächst, ob eine Cache-Datei existiert und diese neuer als der public keyring ist. Wenn das der Fall ist, wird einfach diese Datei ausgegeben. Andernfalls die oben beschriebene Liste aller Schlüssel mit <code>gpg --list-keys --with-colons</code> und daraus entsprechende Konfigurationszeilen für mutt erzeugt. Eingebunden wird das Script mit der Zeile</p>
<pre class="code">source ~/.muttrc.gpg.pl|</pre>
<p>in der <code>~/.muttrc</code> (das Pipe-Symbol (|) am Ende nicht vergessen!).</p>
<p>Falls die Cache-Datei nicht existiert und der Keyring einigermaßen groß ist (bei mir sind es derzeit etwas über 1800 Zeilen), verzögert sich der Start von mutt um wenige Sekunden, was durchaus im Rahmen des Erträglichen liegt.</p>
<pre class="code perl">#!/usr/bin/perl

# file:    ~/.muttrc.gpg.pl
# author:  Martin Grandrath &lt;mail@martin-grandrath.de&gt;
# date:    2008-04-19
#
# description:
#   Creates .muttrc lines in the form
#   ,----
#   | send-hook '~t trusted@example.com' 'set pgp_autoencrypt'
#   `----
#   for each trusted uid in your gpg public keyring.  The output is
#   stored in a cache file that will be refreshed whenever the keyring
#   is newer than the cache file (mtime).
#
#   This script can be included in ~/.muttrc with the following line
#   (don't forget the trailing pipe (|))
#   ,----
#   | source ~/.muttrc.gpg.pl|
#   `----

use strict;
use warnings;
use File::stat;

my $cachefile="$ENV{HOME}/.cache/muttrc.gpg";
my $keyring="$ENV{HOME}/.gnupg/pubring.gpg";

if (-s $cachefile &amp;&amp; -s $keyring &amp;&amp;
    stat($cachefile)-&gt;mtime &gt; stat($keyring)-&gt;mtime)
{
    # Just dump cachefile to stdout if it exists and is not older than
    # keyring
    open FILE, $cachefile or die "ERROR: $!\n";
    print while (&lt;FILE&gt;);
    close FILE;
}
else
{
    my %count;   # count adresses (we want no duplicates)
    my $address; # email addresses from keyring

    # Create new muttrc config and "tee" it to stdout and the
    # cachefile
    open STDOUT, "| tee $cachefile" or die "ERROR: $!\n";
    open GPG, '/usr/bin/gpg --list-keys --with-colons |' or die "Error: $!\n";

    # let mutt reset all autoencrypt settings
    print "send-hook . 'unset pgp_autoencrypt'\n";

    while (&lt;GPG&gt;)
    {
        # Get all keys which we at least "marginally" trust
        if (/^(uid|pub):[mfu]:(.*:){7}.* &lt;(.+@.+)&gt;:/)
        {
            $address = lc($3);
            $count{$address} += 1;

            # Output new send-hook line if address is no duplicate
            print "send-hook '~t $address' 'set pgp_autoencrypt'\n"
                if ($count{$address} &lt; 2);
        }
    }
    close GPG;
    close STDOUT;
}</pre>
<p>Ich setze hier voraus, dass alle E-Mails verschlüsselt werden sollen, sobald die Möglichkeit dazu besteht. Möchte man einzelne Empfänger von dieser Regel ausnehmen, kann man für diese natürlich nach der Einbindung des Scriptes weitere <code>send-hook</code>s anlegen, die die automatische Verschlüsselung wieder deaktivieren.</p>
]]></content:encoded>
			<wfw:commentRss>http://martin-grandrath.de/2008/04/pgp_autoencrypt-fuer-mutt-automatisieren/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS-Dateien optimieren</title>
		<link>http://martin-grandrath.de/2008/04/css-dateien-optimieren/</link>
		<comments>http://martin-grandrath.de/2008/04/css-dateien-optimieren/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 17:43:30 +0000</pubDate>
		<dc:creator>Martin Grandrath</dc:creator>
				<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.martin-grandrath.de/?p=14</guid>
		<description><![CDATA[Online-Optimierer für CSS (und andere Formate) gibt es zuhauf im Netz. Ich war aber auf der Suche nach einem kleinen (Perl-)Skript, das diese Aufgabe auf meinem Rechner erledigt und war erstaunt, dass es in dieser Richtung recht wenig zu geben scheint. Fündig geworden bin ich auf thinkvitamin. Hier ist meine angepasste Variante:
#!/usr/bin/perl

use strict;

my $data = [...]]]></description>
			<content:encoded><![CDATA[<p>Online-Optimierer für CSS (und andere Formate) gibt es zuhauf im Netz. Ich war aber auf der Suche nach einem kleinen (Perl-)Skript, das diese Aufgabe auf meinem Rechner erledigt und war erstaunt, dass es in dieser Richtung recht wenig zu geben scheint. Fündig geworden bin ich auf <a href="http://www.thinkvitamin.com/features/webapps/serving-javascript-fast" rel="external">thinkvitamin</a>. Hier ist meine angepasste Variante:</p>
<pre class="code perl">#!/usr/bin/perl

use strict;

my $data = '';
open F, $ARGV[0] or die "Can't open source file: $!";
$data .= $_ while &lt;F&gt;;
close F;

$data =~ s!/\*(.*?)\*/!!sg;   # remove comments
$data =~ s!\r?\n!!g;          # remove newlines
$data =~ s!\s+! !g;           # collapse space
$data =~ s! ?([{}:;]) ?!$1!g; # remove more dispensable space

print $data;</pre>
<p>Dieses Script macht nichts weiter, als alle Kommentare, Zeilenumbrüche und sonstigen unnötigen Zeichen aus einer CSS-Datei zu entfernen und hat das CSS-Volumen dieser Seite immerhin von 37kB auf 32kB geschrumpft.</p>
]]></content:encoded>
			<wfw:commentRss>http://martin-grandrath.de/2008/04/css-dateien-optimieren/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

