<<< Date Index >>>     <<< Thread Index >>>

Automatic display of X-Face



Hello,

For those who'd like to display the X-Face of a message
automatically, here's a dirty way to do it:

--- xfacefilter.sh ---
#!/bin/sh
###################################################################
# display_filter for mutt                                         #
# to automatically show X-Faces in pager at end of message        #
#                                                                 #
# Required programs:                                              #
# formail, uncompface, icontopbm, image2ascii                     #
#                                                                 #
# Usage examples muttrc:                                          #
# unignore X-Face                                                 #
# set display_filter=xfacefilter.sh                               #
## in case you want to write tmpfile only if needed:              #
# message-hook ~A "set display_filter=''"                         #
# message-hook "~h ^X-Face:." "set display_filter=xfacefilter.sh" #
## at end of filter chain:                                        #
# set display_filter="sed -f myfilter.sed|xfacefilter.sh"         #
###################################################################
set -e
self=${0##*/}
CLEANUP()
{
        rm -f "$tf"
}
trap "CLEANUP" 0 1 2 3 15
tf=`mktemp -t ${self}.XXXXXXXXXX` || exit 1
tee "$tf"
xface=`formail -zcx X-Face: <"$tf"`
if [ -n "$xface" ]
then
        printf "\n\n===== X-Face displayed by $self =====\n\n"
        echo "$xface" | {
                echo '/* Width=48, Height=48 */'
                uncompface
        } |
        icontopbm |
        image2ascii
fi
exit $?
--- end ---

If you don't like ascii-graphics in the pager removing the
printf... line and using "xli -fork stdin" or something similar
instead of image2ascii should work too, but I wanted to keep the
example small.

In python I could think of ways to avoid the tempfile creation,
but this is faster.

c
-- 
_B A U S T E L L E N_ lesen!  --->> <http://www.blacktrash.org/baustellen.html>