diff --git a/CHANGES b/CHANGES index 183cbee..d58f196 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +0.3-1 | 2024-02-25 08:48:09 +0100 + + * Add helpers using qlview from mutt. + 0.3 | 2024-02-10 13:11:55 +0100 * Notarize distribution. diff --git a/Makefile b/Makefile index 7ec5ac8..ae8b465 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ zip: rm -rf build/dist mkdir -p build/dist cp -R build/Release/qlview build/dist + cp -R mutt build/dist cd build/dist && zip -r ../qlview-$(VERSION).zip * ls build/*.zip | sed 's/^/> /' diff --git a/README.md b/README.md index e9f43c2..147c461 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,24 @@ Run it from the command line: If you execute `qlview` without any arguments, it'll open an empty window where you can drag a document into. +## Mutt integration + +To use `qlview` with [mutt](http://www.mutt.org), there's a helper +script +[mutt-qlview](https://github.com/rsmmr/qlview/blob/main/mutt/mutt-qlview) +coming with the distribution. Put both that script and `qlview` itself +into your `PATH` and then add [these mailcap +entries](https://github.com/rsmmr/qlview/blob/main/mutt/mailcap) to +your mutt configuration; see [mutt's +manual](http://www.mutt.org/doc/manual/#mailcap) for more on that. + +You can also add the following to your `.muttrc` to quickly open the +first HTML attachment in `qlview`: + +``` +macro index,pager V /html\n +``` + ## Feedback Feel free to open issues or pull requests. diff --git a/VERSION b/VERSION index be58634..89d2d99 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3 +0.3-1 diff --git a/mutt/mailcap b/mutt/mailcap new file mode 100644 index 0000000..903aeab --- /dev/null +++ b/mutt/mailcap @@ -0,0 +1,6 @@ +application/*; mutt-qlview %s +audio/*; mutt-qlview %s +image/*; mutt-qlview %s +text/*; mutt-qlview %s +text/html; mutt-qlview %s; nametemplate=%s.html; +video/*; mutt-qlview %s diff --git a/mutt/mutt-qlview b/mutt/mutt-qlview new file mode 100755 index 0000000..ee81e0b --- /dev/null +++ b/mutt/mutt-qlview @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Wrapper around qlview for use from mutt's mailcap. qlview must be in same +# path as this script, or inside $PATH. The script initially retain a copy of +# the file being viewed, which will it will delete when running for the 1st +# time day later, or when run again with the same file name. + +prog=$0 + +usage() { + echo "usage: $(basename "${prog}") " + exit 1 +} + +error() { + echo "$(basename "${prog}"): $*" >&2 + exit 1 +} + +qlview="$(cd "$(dirname "$0")" && pwd)/qlview" +test -f "${qlview}" -a -x "${qlview}" || qlview="$(command -v qlview 2>/dev/null)" + +test -n "${qlview}" || error "qlview not found" +test $# -eq 1 || usage + +file="$1" +test -f "${file}" || error "no file '${file}'" + +tmpdir="${HOME:?}/.cache/mutt" +mkdir -m 0700 -p "${tmpdir}" +find "${tmpdir}" -maxdepth 1 -type f -mtime +1d -delete + +tmpfile="${tmpdir}/$(basename "${file}")" +mkdir -p "${tmpdir}" +cp -f "${file}" "${tmpfile}" + +nohup "${qlview}" "${tmpfile}" >/dev/null 2>&1 /html\n diff --git a/qlview/Info.plist b/qlview/Info.plist index fa456b2..2075fde 100644 --- a/qlview/Info.plist +++ b/qlview/Info.plist @@ -11,6 +11,6 @@ CFBundleName qlview CFBundleVersion - 0.3 + 0.4