From ac9ed58abe59bc10b9252843824b64f42547569f Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 16 Feb 2021 15:25:16 +0100 Subject: [PATCH] feat: neomutt open file through mailcap + xdg-open --- .config/mutt/mailcap | 9 +++++++++ .config/mutt/neomutt.muttrc | 1 + .config/paru/pkglist.txt | 1 + .local/bin/mutt-openfile | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 .config/mutt/mailcap create mode 100755 .local/bin/mutt-openfile diff --git a/.config/mutt/mailcap b/.config/mutt/mailcap new file mode 100644 index 0000000..3e0243c --- /dev/null +++ b/.config/mutt/mailcap @@ -0,0 +1,9 @@ +text/plain; $EDITOR %s ; +text/html; lynx -assume_charset=%{charset} -display_charset=utf-8 -dump %s; nametemplate=%s.html; copiousoutput; +text/html; mutt-openfile %s ; nametemplate=%s.html +image/*; mutt-openfile %s ; +video/*; setsid mpv --quiet %s &; copiousoutput +audio/*; mpv %s ; +application/pdf; mutt-openfile %s ; +application/pgp-encrypted; gpg -d '%s'; copiousoutput; +application/pgp-keys; gpg --import '%s'; copiousoutput; diff --git a/.config/mutt/neomutt.muttrc b/.config/mutt/neomutt.muttrc index e5081a3..fa2da99 100644 --- a/.config/mutt/neomutt.muttrc +++ b/.config/mutt/neomutt.muttrc @@ -5,6 +5,7 @@ # This file contains part of mutt-wizard's default settings. # mutt-wizard will have this file sourced from your muttrc. +set mailcap_path = /home/swytch/.config/mutt/mailcap:$mailcap_path set mime_type_query_command = "file --mime-type -b %s" set date_format="%y/%m/%d %I:%M%p" set index_format="%2C %Z %?X?A& ? %D %-15.15F %s (%-4.4c)" diff --git a/.config/paru/pkglist.txt b/.config/paru/pkglist.txt index a083aa8..c069d9b 100644 --- a/.config/paru/pkglist.txt +++ b/.config/paru/pkglist.txt @@ -39,6 +39,7 @@ libnotify libtool linux linux-firmware +lynx m4 make man-db diff --git a/.local/bin/mutt-openfile b/.local/bin/mutt-openfile new file mode 100755 index 0000000..52068d7 --- /dev/null +++ b/.local/bin/mutt-openfile @@ -0,0 +1,19 @@ +#!/usr/bin/env sh + +###################################################################### +# @author : swytch (adapted from Luke Smith - lukesmith.xyz) +# @file : mutt-openfile +# @license : GPLv3 +# @created : Tuesday Feb 16, 2021 11:50:16 CET +# +# @description : open a file with xdg-open from mutt +###################################################################### + + +tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt/files" +file="$tempdir/$(basename "$1")" +opener="setsid -f xdg-open" +mkdir -p "$tempdir" +cp -f "$1" "$file" +$opener "$file" >/dev/null 2>&1 +find "${tempdir:?}" -mtime +1 -type f -delete