#!/usr/bin/env python # Copyright (C) 2006 Matthew Good # # "THE BEER-WARE LICENSE" (Revision 42): # wrote this file. As long as you retain this notice you # can do whatever you want with this stuff. If we meet some day, and you think # this stuff is worth it, you can buy me a beer in return. Matthew Good # (Beer-ware license written by Poul-Henning Kamp # http://people.freebsd.org/~phk/) # # Author: Matthew Good import email from email.Header import decode_header import os import sys import scrape def escape(s): return s.replace('<', '&lt;').replace('>', '&gt;') msg = email.message_from_file(sys.stdin) sender = decode_header(msg['From'])[0][0] subject = decode_header(msg['Subject'])[0][0] txt = scrape.striptags(unicode(msg.get_payload()))[:100] txt = 'From %s:\n%s' % (escape(sender), escape(txt)) os.execlp('notify-send', 'notify-send', subject, txt)