John Floren

Home | Blog | Uses | Links
Back to blog archive

Posted 2024/3/1

Using xfaces with Maildir

xfaces is a neat old application that displays a “personal icon” (picon) for each piece of mail in your mail spool file.

Of course, most people don’t use a local spool file these days! I use offlineimap to sync a Maildir from my mail server, and then I read my mail with mu4e. xfaces doesn’t support Maildir directly, but it does allow you to pass it the name of a command that outputs usernames & hostnames in a format xfaces recognizes.

Here’s a script (I put it into ~/bin/xfaces-unread-maildir) to do just that with mu:

#!/bin/sh
# unused first line, xfaces requires this but doesn't use it.
echo foo	example.org
# This tells xfaces to draw 5 icons in a single column. Change the values if you prefer horizontal/grid display
echo Cols=1 Rows=5
# Get the senders of unread messages, then extract just the email addresses.
# xfaces expects to see "username<TAB>hostname".
mu find -q -f f flag:unread 2>/dev/null | sed -E -e 's/.*<([^<]*)@([^>]*)>.*/\1\t\2/g' -e 's/^([^<]+)@([^>]+).*/\1\t\2/g'

Then I just invoke xfaces like this:

xfaces -e xfaces-unread-maildir