On Sat, Jan 19, 2002 at 08:36:29AM +0100, Jurriaan on Alpha wrote: > On Fri, Jan 18, 2002 at 04:03:18PM -0500, Rudy Taraschi wrote: > > Hi folks, > > > > I can't figure out how to hack slrn into showing X-Faces in the same > > terminal window. Check out this screenshot: > > > > http://www.geocities.com/tsca.geo/czytniki/galeria/yetanother.gif > > > > and tell me how it's done, because I don't have a clue. > > > > I've seen something called slrnface (which won't work in Cygwin due > > to lack of FIFO support), but that looks like it puts the X-Face in > > a separate window. > > > I have macros to convert it to an ascii-image, that is displayed in the > same window, if you are interested? > Several people expressed their interest. So here goes, archived for eternity. By all means download the originals that are mentioned in the comments for the scripts following, since I've optimized them for display on my 133x54 console, and you might not have such a big screen :-) put this into a slang macro: define show_xface() { save_current_article("/home/jurriaan/News/art_xfce"); variable header_file, xfce_file; variable fp, xfce_fp; variable line, face; fp = fopen ("/home/jurriaan/News/art_xfce", "r"); if (fp == NULL) return; while (-1 != fgets (&line, fp)) { % X-Face can appear anywhere, even in the subject line % and I've seen it CaPitaLizED differently, even. % Compare first 7 characters of line with X-FACE: if (strncmp(substr(strup(line), 1, 7), "X-FACE:", 7) == 0) { % write headerline with xface xfce_fp = fopen("/home/jurriaan/News/hdr_xface", "w"); if (xfce_fp == NULL) return; () = fputs(line, xfce_fp); () = fputs("\n", xfce_fp); () = fclose(xfce_fp); % display it xfce_fp = popen ("cat /home/jurriaan/News/hdr_xface | /usr/local/bin/view-x-face.sh", "r"); if (xfce_fp == NULL) return; popup_window ("X-Face:", strjoin (fgetslines(xfce_fp), "")); () = pclose (xfce_fp); break; } } () = system ("rm -f /home/jurriaan/News/art_xfce /home/jurriaan/News/hdr_xface /home/jurriaan/News/rslt_xface"); % No need to close files unless we want to check for errors. When % file pointer variables go out of scope, slang will close the file. } definekey ("show_xface", "x", "article"); The script view-x-face.sh looks like this: #! /bin/sh # # $ Id: view-x-face,v 2.0 1998/10/27 10:20:58 roland Exp roland $ # # Read a mail message on stdin and display X-Face, if one exists. # # See http://www.spinnaker.de/mutt/view-x-face for new versions. # # This is not the optimal way to implement X-Face support into a mailreader, # but this works for me. I bound it to "ESC f" in my muttrc with the # following command: # macro pager \ef "|view-x-face\n" # # This script needs the following tools: # uncompface from the compface package, which can be found at # ftp://ftp.cs.indiana.edu/pub/faces/compface/compface.tar.Z # icontopbm from the pbmplus or netpbm package, which you will find # everywhere on the net. # A pbm viewer, e.g. xli, xv or if you don't have X11 running, you may want # to try out image2ascii, a little Shell script, which uses # ImageMagick to convert nearly any graphics file to ASCII. # have a look at http://www.spinnaker.de/mutt/image2ascii # ######################################################################### # # Based on an idea of Ralf Döblitz # # Copyright (C) 1997-1998 Roland Rosenfeld # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################### # Used programms: UNCOMPFACE=uncompface # from compface package ICONTOPBM=icontopbm # from pbmplus/netpbm package VIEWER="small_image2ascii.sh -geometry 48x48" #sed -n -e '/^X-Face:/,/^[^ \t]/ p' $1 \ #| sed -n -e 's/^X-Face://' -e '/^[ \t]/ p' \ #| sed -e 's/^[ \t]\+//' \ if [ -z "$@" ] then file=~/xface.pre1 cat - > $file delete=1 else file=$1 delete=0 fi full_header=`grep -ic "^X-Face: " $file` if [ $full_header -gt 0 ] then grep -i "^X-Face: " $file | head -1 | cut -c9- \ | { echo '/* Width=48, Height=48 */'; $UNCOMPFACE; } \ | $ICONTOPBM \ | $VIEWER else cat $file \ | { echo '/* Width=48, Height=48 */'; $UNCOMPFACE; } \ | $ICONTOPBM \ | $VIEWER echo $@ fi if [ $delete -gt 0 ] then rm $file fi exit 0 And then there is /usr/local/bin/small_image2ascii.sh: #! /bin/sh # # $ Id: image2ascii,v 1.5 1999/11/27 18:07:41 roland Exp $ # # Convert any image to an ASCII-graphic using ImageMagick # ########################################################################## # # Copyright (C) 1997-1999 Roland Rosenfeld # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ########################################################################## CONVERT=convert # The ImageMagick convert binary PBMTOASCII=pbmtoascii # The NetPBM pbmtoascii binary umask 077 tmpdir=${TMPDIR-/tmp}/image2ascii.$$ mkdir $tmpdir || exit 1 trap "rm -rf $tmpdir; exit" 0 1 2 3 15 TMPFILE=$tmpdir/image usage="Usage: $0 [option] [imagefile] -help display this help text -geometry 132x50 define the size of the ascii image" # set default geometry to display width: geometry=`stty size $TMPFILE ;; 1 ) case "$1" in -* ) echo "$usage"; exit 0 ;; * ) cat $1 > $TMPFILE ;; esac ;; 2 ) case "$1" in -geometry ) geometry=$2 cat > $TMPFILE ;; * ) echo "$usage"; exit 0 ;; esac ;; 3 ) case "$1" in -geometry ) geometry=$2 cat $3 > $TMPFILE ;; * ) echo "$usage"; exit 0 ;; esac ;; * ) echo "$usage"; exit 0 ;; esac # multiply x with 1 and y with 2 (pbmtoascii divides by 2x4) geometry=`echo $geometry | awk -Fx '{print 1*$1 "x" 2*$2}'` $CONVERT -geometry $geometry $TMPFILE $TMPFILE.pbm $PBMTOASCII -1x2 < $TMPFILE.pbm Good luck, Jurriaan -- We followed an unlikely star Never thought we'd get this far Now we don't know where we are But hey... we're hanging on... Oysterband - I know it's mine GNU/Linux 2.4.18-pre4 on Debian/Alpha 64-bits 990 bogomips load:0.54 0.15 0.06