]> git.friedersdorff.com Git - max/dotfiles.git/blob - mail/.local/bin/muttmailto
feat: Use mutt for mailto links
[max/dotfiles.git] / mail / .local / bin / muttmailto
1 #!/bin/bash
2
3 # NoSuck.org
4 # Mutt Mailto Handler for XDG Environment
5 # From https://github.com/NoSuck/MuttMailto
6
7 if [[ "$1" == mailto:* ]] ; then
8         sStart="${1%%\?*}"
9         sEnd="&${1##*\?}"
10         # The whitelist.
11         sValidAttributes=( "Subject" )
12         for sAttribute in "${sValidAttributes[@]}" ; do
13                 sHit="$( echo "$sEnd" | sed "s/^.*&$sAttribute=\([^&]*\).*/$sAttribute=\1/" )"
14                 if [[ "$sEndNew" ]] ; then
15                         sEndNew="$sEndNew&$sHit"
16                 else
17                         sEndNew="?$sHit"
18                 fi
19         done
20 fi
21 sNewMailto="$sStart$sEndNew"
22 # Modify as necessary.
23 i3-sensible-terminal -e /bin/sh -c "mutt -F ~/.mutt/mutt.uk.ac.aber.maf54_online ${sNewMailto:+ \"$sNewMailto\"}" &