# USAGE: <type> <command> <flags>
# Style: text/plain
# Command: cmd %s
# Flags:
#   - copiousoutput         use pager
#   - needsterminal         open in new terminal
#   - text=xxx              rule is valid if program xxx returns true
#   - textualnewlines=0     turn off newline conversation for text
#   - compose=xxx %s        use program xxx to compose this type
#   - edit=xxx              use program xxx to edit this type
#   - description=xxx       set description
#   - nametemplate=%s.html  define temporary file name
# Format:
#   - %s      - Filename (if %s is not used, data will be sent to stdin)
#   - %t      - Mime Type
#   - %{var1} - Specified by: var1=foobar;
#
# Env Variables:
#   METAMAIL_PAGER=less
#
# Tests:
#   test -n "$DISPLAY"      true when X is running

# html
text/html; ~/.mutt/scripts/call-browser.sh %s; test=test -n "$DISPLAY"; needsterminal;
text/html; w3m -I %{charset} -T %t -cols "$COLUMNS" -s -no-graph -o display_link=1 -o display_link_number=1; copiousoutput;

# documents
application/pdf; ~/.mutt/scripts/call.sh mupdf %s; nametemplate=%s.pdf;
application/vnd.openxmlformats-officedocument.wordprocessingml.document; ~/.mutt/scripts/call.sh libreoffice %s;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; ~/.mutt/scripts/call.sh libreoffice %s;
application/vnd.openxmlformats-officedocument.presentationml.presentation; ~/.mutt/scripts/call.sh libreoffice %s;
application/vnd.oasis.opendocument.text; ~/.mutt/scripts/call.sh libreoffice %s;
application/vnd.oasis.opendocument.spreadsheet; ~/.mutt/scripts/call.sh libreoffice %s;
application/vnd.oasis.opendocument.presentation; ~/.mutt/scripts/call.sh libreoffice %s;

# media
image/*; ~/.mutt/scripts/call.sh nsxiv %s;
video/*; mpv %s; needsterminal;
audio/*; mpv %s; needsterminal;
application/ogg; mpv %s; needsterminal;

# calendar
text/calendar; clear && ~/.mutt/scripts/mutt-ical.py -i -e "stefan.hagen@sap.com" %s; nametemplate=%s.ics
application/ics; clear && ~/.mutt/scripts/mutt-ical.py -i -e "stefan.hagen@sap.com" %s; nametemplate=%s.ics
 
# winmail.dat fix
application/ms-tnef; tnef -w %s

# fallback
application/*; vim %s; needsterminal;
text/*; cat %s; copiousoutput;
message/rfc822; emldump -a %s; copiousoutput;
