# @(#$Id: mimeview,v 1.16 2008-09-15 08:03:37 dockes Exp $  (C) 2004 J.F.Dockes

## ##########################################
# External viewers, launched by the recoll GUI when you click on a result
# 'edit' link

# Mime types which we should not uncompress if they are found gzipped or
# bzipped because the native viewer knows how to handle. These would be
# exceptions and the list is normally empty
#nouncompforviewmts = 

# For releases 1.18 and later: exceptions when using the x-all entry: these
# types will use their local definition. This is useful, e.g.: 
#
#  - for pdf, where we can pass additional parameters like page to open and
#    search string
#  - For pages of CHM and EPUB documents where we can choose to open the 
#    parent document instead of a temporary html file.
# Use xallexcepts- and xallexcepts+ in a user file to add or remove from
# the default xallexcepts list

# Visio xml is in there because the desktops tend to try and open it as an
# archive
xallexcepts = application/pdf application/postscript application/x-dvi \
 text/html|gnuinfo text/html|chm text/html|epub text/html|rclman \
 application/vnd.ms-visio.drawing application/x-ipynb+json \
 text/x-orgmode text/x-orgmode-sub application/x-joplin-note


[view]
# Pseudo entry used if the 'use desktop' preference is set in the GUI.
# Note that we use %U to url-encode the parameter
application/x-all = xdg-open %U
# But do use the uncoded url for help (F1) because the fragment in there must
# actually be processed. The way we process URLs is preposterous and needs a complete overhaul
text/html|rclman = xdg-open %u

application/epub+zip = ebook-viewer %f
# Open the parent epub document for epub parts instead of opening them as
# html documents. This is almost always what we want.
text/html|epub = ebook-viewer %F;ignoreipath=1

application/x-ipynb+json = jupyter notebook %f

application/x-gnote = gnote %f

# Note %u not U hence the exception?
application/x-joplin-note = xdg-open %u

application/x-mobipocket-ebook = ebook-viewer %f

application/x-kword = kword %f
application/x-abiword = abiword %f
application/x-hwp = libreoffice

# Note: the evince clones, atril and xread, have the same options
application/pdf  = evince --page-index=%p --find=%S %f
# Or:
#application/pdf  = qpdfview --search %s %f#%p
# Or okular. Old versions had no --find option so you may need to edit this.
#application/pdf  = okular --unique --find %s -p %p %f

application/postscript = evince --page-index=%p --find=%s %f
application/x-dvi = evince --page-index=%p --find=%s  %f

application/x-lyx = lyx %f
application/x-scribus = scribus %f

application/msword = libreoffice %f
application/vnd.ms-excel = libreoffice %f
application/vnd.ms-powerpoint = libreoffice %f

application/vnd.oasis.opendocument.text = libreoffice %f
application/vnd.oasis.opendocument.presentation = libreoffice %f
application/vnd.oasis.opendocument.spreadsheet = libreoffice %f
application/vnd.oasis.opendocument.graphics = libreoffice %f
application/vnd.oasis.opendocument.presentation-flat-xml = libreoffice %f
application/vnd.oasis.opendocument.spreadsheet-flat-xml = libreoffice %f
application/vnd.oasis.opendocument.text-flat-xml = libreoffice %f
application/vnd.oasis.opendocument.text-template = libreoffice %f

application/vnd.openxmlformats-officedocument.wordprocessingml.document = libreoffice %f
application/vnd.openxmlformats-officedocument.wordprocessingml.template = libreoffice %f
application/vnd.openxmlformats-officedocument.presentationml.template = libreoffice %f
application/vnd.ms-visio.drawing = libreoffice %f
application/vnd.openxmlformats-officedocument.presentationml.presentation = libreoffice %f
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet = libreoffice %f
application/vnd.openxmlformats-officedocument.spreadsheetml.template = libreoffice %f
application/vnd.sun.xml.calc = libreoffice %f
application/vnd.sun.xml.calc.template = libreoffice %f
application/vnd.sun.xml.draw = libreoffice %f
application/vnd.sun.xml.draw.template = libreoffice %f
application/vnd.sun.xml.impress = libreoffice %f
application/vnd.sun.xml.impress.template = libreoffice %f
application/vnd.sun.xml.math = libreoffice %f
application/vnd.sun.xml.writer = libreoffice %f
application/vnd.sun.xml.writer.global = libreoffice %f
application/vnd.sun.xml.writer.template = libreoffice %f
application/vnd.wordperfect = libreoffice %f
application/vnd.apple.pages = libreoffice %f
application/vnd.apple.numbers = libreoffice %f
application/vnd.apple.keynote = libreoffice %f
text/rtf = libreoffice %f
application/rtf = libreoffice %f

application/x-dia-diagram = dia %f

# Both dolphin and nautilus can pre-select a file inside a directory. Thunar can't afaik. xdg-open
# can't pass additional parameters, so the directory MIME types used to be included in xallexcepts,
# but this caused problems to Mint Cinnamon (nemo) users. So the default for directories is now
# switched back to using desktop default, to be customized by adventurous users.
application/x-fsdirectory = dolphin %f
inode/directory = dolphin %f
application/x-fsdirectory|parentopen = dolphin --select %(childurl) %f
inode/directory|parentopen = dolphin --select %(childurl) %f
#application/x-fsdirectory|parentopen = nautilus -w -s %(childurl)
#inode/directory|parentopen = nautilus -w -s %(childurl)

application/x-gnuinfo = xterm -e "info -f %f"
application/x-gnumeric = gnumeric %f

application/x-flac = vlc --start-time %p %f
audio/flac = vlc --start-time %p %f
audio/mpeg = vlc --start-time %p %f
audio/aac = vlc --start-time %p %f
audio/ape = vlc --start-time %p %f
audio/mp4 = vlc --start-time %p %f
audio/ogg = vlc --start-time %p %f
audio/x-musepack = vlc --start-time %p %f
audio/x-wavpack = vlc --start-time %p %f
application/ogg = vlc --start-time %p %f

audio/x-karaoke = kmid %f

image/vnd.djvu = djview %f

image/jpeg = ristretto %f
image/jp2 = ristretto %f
image/png = ristretto %f
image/tiff = ristretto %f
image/gif  = ristretto %f
image/bmp = ristretto %f
image/x-ms-bmp = ristretto %f
image/x-xpmi = ristretto %f
image/heic = ristretto %f
image/heic-sequence = ristretto %f
image/heif = ristretto %f
image/heif-sequence = ristretto %f
image/avif = ristretto %f

image/x-xcf = gimp %f
image/x-nikon-nef = ufraw %f
image/svg+xml = inkview %f

# Opening email messages: the method will depend on your email client.
# See: https://www.recoll.org/faqsandhowtos/email-opening.html
#  - Evolution: you need to extract and store the Message-Id headers. See page linked above.
#  - Thunderbird: will only open a single-message file if it has an .eml
#    extension, else they will open a 'create message' window with the file as an attachment.
#    Use an intermediate shell script to create a symbolic link with a ".eml" extension. The script
#    is distributed with recoll, so just enable it.
#  - "sylpheed %f" seems to work ok as of version 3.3
#  - "kmail --view %u" works
#  - "claws-mail --select %f" works
message/rfc822 = thunderbird-open-message.sh %f
# Evolution: this needs the following in $RECOLL_CONFDIR/fields:
#   [stored]
#   msgid=
#   [mail]
#   Message-Id = msgid
#message/rfc822 = evolution mid:%(msgid)

text/x-mail = thunderbird -file %f
application/x-mimehtml = thunderbird -file %f

text/calendar = evolution %f

application/x-okular-notes = okular %f

application/x-rar = ark %f
application/x-tar = ark %f
application/zip = ark %f
application/x-7z-compressed = ark %f

application/javascript = emacsclient --no-wait %f
application/x-awk = emacsclient --no-wait %f
application/x-bibtex = emacsclient --no-wait %f
application/x-csharp = emacsclient --no-wait %f
application/x-java = emacsclient --no-wait %f
application/x-perl = emacsclient --no-wait %f
application/x-php = emacsclient --no-wait %f
application/x-ruby = emacsclient --no-wait %f 
application/x-shellscript = emacsclient --no-wait %f
text/x-bibtex = emacsclient --no-wait %f
text/css = emacsclient --no-wait %f
text/x-csharp = emacsclient --no-wait %f
text/x-java = emacsclient --no-wait %f
text/x-lisp = emacsclient --no-wait %f
text/x-perl = emacsclient --no-wait %f
text/x-ruby = emacsclient --no-wait %f 
text/x-shellscript = emacsclient --no-wait %f
text/x-srt = emacsclient --no-wait %f
text/x-tcl = emacsclient --no-wait %f

# Or firefox -remote "openFile(%u)"
text/html = firefox %u
application/x-chm-html = %u
text/x-chm-html = %u

# gnu info nodes are translated to html with a "gnuinfo"
# rclaptg. rclshowinfo knows how to start the info command on the right
# node
text/html|gnuinfo = rclshowinfo %F %(title);ignoreipath=1

application/x-webarchive = konqueror %f
application/x-mac-webarch = safari %f
text/x-fictionbook = ebook-viewer %f

application/x-javascript = emacsclient --no-wait  %f
application/sql = emacsclient --no-wait  %f
application/x-tex = emacsclient --no-wait  %f
application/xml = emacsclient --no-wait  %f
text/xml = emacsclient --no-wait  %f
text/x-tex = emacsclient --no-wait  %f
text/markdown = emacsclient --no-wait  %f
text/plain = emacsclient --no-wait  %f
text/x-awk = emacsclient --no-wait  %f
text/x-c = emacsclient --no-wait  %f
text/x-lua = emacsclient --no-wait  %f
text/x-c+ = emacsclient --no-wait  %f
text/x-c++ = emacsclient --no-wait  %f
text/x-csv = libreoffice %f
text/x-html-sidux-man = konqueror %f
text/x-html-aptosid-man = iceweasel %f
text/x-orgmode-sub = emacsclient --no-wait  %F
text/x-orgmode = emacsclient --no-wait  %f

application/x-chm = kchmviewer %f
# Html pages inside a chm have a chm rclaptg set by the filter. Kchmviewer
# knows how to use the ipath (which is the internal chm path) to open the
# file at the right place
text/html|chm = kchmviewer --url %i %F

text/x-ini = emacsclient --no-wait %f
text/x-man = xterm -u8 -e "groff -T ascii -man %f | more"
text/x-python = idle %f
text/x-gaim-log = emacsclient --no-wait  %f
text/x-purple-html-log = emacsclient --no-wait  %f
text/x-purple-log = emacsclient --no-wait  %f

# The video types will usually be handled by the desktop default, but they need entries here to get
# an "Open" link (this is not the case any more). Anyway, could be used to set exceptions.
video/3gpp = vlc --start-time %p %f
video/mp2p = vlc --start-time %p %f
video/mp2t = vlc --start-time %p %f
video/mp4 = vlc --start-time %p %f
video/mpeg = vlc --start-time %p %f
video/quicktime = vlc --start-time %p %f
video/x-matroska = vlc --start-time %p %f
video/x-ms-asf = vlc --start-time %p %f
video/x-msvideo = vlc --start-time %p %f

