# $Id: x-face.procmailrc,v 64ce8d95ec79 2007-10-27 10:06 +0200 blacktrash $
# filter procmailrc to display (X-)Face images with VIEWER
# (c) 2004 Christoph Berg, GNU GPL.
# tweaked by Christian Ebert

# customize X11 viewer (has to accept stdin)
VIEWER="/sw/bin/xli -fork stdin"

PRINTF="/usr/bin/printf"
UNCOMPFACE="/sw/bin/uncompface"
OPENSSL="/usr/bin/openssl"
FORMAIL="/usr/local/bin/formail"
TR="/usr/bin/tr"

:0
# check if $DISPLAY is non-empty (needs procmail -p)
* DISPLAY ?? .
{
	:0
	# extract X-Face: header (at least 16 chars, cf. "X-Face: ;-)")
	* ^X-Face: *\/.................*
	{
		:0 ci
		# pipe it through uncompface
		| $PRINTF '%s\n' $MATCH | $UNCOMPFACE -X | $VIEWER
		:0 fhw
		# remove the header for mutt
		| $FORMAIL -f -I 'X-Face:'
	}

	:0
	* ^Face: *\/.................*
	{
		:0 ci
		| $PRINTF '%s\n' $MATCH | $TR -s ' \t' '\n' \
		| $OPENSSL base64 -d | $VIEWER
		:0 fhw
		| $FORMAIL -f -I 'Face:'
	}
}

# spit mail back to stdout
:0
|

# EOF vim:ft=procmail
