From 346e838672e86076aa5ef6fb4a79c7bc76797817 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 22 Mar 2018 08:23:46 -0700 Subject: mailcap fix, clarification for logins --- etc/mailcap | 6 +-- etc/view_attachment.sh | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ mutt-wizard.sh | 2 +- view_attachment.sh | 127 ------------------------------------------------- 4 files changed, 131 insertions(+), 131 deletions(-) create mode 100755 etc/view_attachment.sh delete mode 100755 view_attachment.sh diff --git a/etc/mailcap b/etc/mailcap index 45b54f3..18dd471 100644 --- a/etc/mailcap +++ b/etc/mailcap @@ -1,8 +1,8 @@ #text/html; qutebrowser %s &; test=test -n "$DISPLAY"; needsterminal; -text/html; w3m -I %{charset} -T text/html; copiousoutput; -#text/html; mv %s %s.html && qutebrowser %s.html > /dev/null; needsterminal; -# +text/html; $BROWSER %s 2>/dev/null & disown; copiousoutput; +#text/html; w3m -I %{charset} -T text/html; copiousoutput; + application/pdf; mv %s %s.pdf && i3 exec mupdf %s.pdf > /dev/null; needsterminal; image/*; ~/.config/mutt/etc/muttimage.sh %s ; copiousoutput diff --git a/etc/view_attachment.sh b/etc/view_attachment.sh new file mode 100755 index 0000000..df8b9a1 --- /dev/null +++ b/etc/view_attachment.sh @@ -0,0 +1,127 @@ +#!/bin/bash +# +# Author: Eric Gebhart +# +# Purpose: To be called by mutt as indicated by .mailcap to handle mail attachments. +# +# Function: Copy the given file to a temporary directory so mutt +# Won't delete it before it is read by the application. +# +# Along the way, discern the file type or use the type +# That is given. +# +# Finally use 'open' or 'open -a' if the third argument is +# given. +# +# +# Arguments: +# +# $1 is the file +# $2 is the type - for those times when file magic isn't enough. +# I frequently get html mail that has no extension +# and file can't figure out what it is. +# +# Set to '-' if you don't want the type to be discerned. +# Many applications can sniff out the type on their own. +# And they do a better job of it too. +# +# Open Office and MS Office for example. +# +# $3 is open with. as in open -a 'open with this .app' foo.xls +# +# Examples: These are typical .mailcap entries which use this program. +# +# Image/JPEG; /Users/vdanen/.mutt/view_attachment %s +# Image/PNG; /Users/vdanen/.mutt/view_attachment %s +# Image/GIF; /Users/vdanen/.mutt/view_attachment %s +# +# Application/PDF; /Users/vdanen/.mutt/view_attachment %s +# +# #This HTML example passes the type because file doesn't always work and +# #there aren't always extensions. +# +# text/html; /Users/vdanen/.mutt/view_attachment %s html +# +# # If your Start OpenOffice.org.app is spelled with a space like this one, <-- +# # then you'll need to precede the space with a \ . I found that too painful +# # and renamed it with an _. +# +# Application/vnd.ms-excel; /Users/vdanen/.mutt/view_attachment %s "-" '/Applications/OpenOffice.org1.1.2/Start_OpenOffice.org.app' +# Application/msword; /Users/vdanen/.mutt/view_attachment %s "-" '/Applications/OpenOffice.org1.1.2/Start_OpenOffice.org.app' +# +# +# Debugging: If you have problems set debug to 'yes'. That will cause a debug file +# be written to /tmp/mutt_attach/debug so you can see what is going on. +# +# See Also: The man pages for open, file, basename +# + +# the tmp directory to use. +tmpdir="$HOME/.tmp/mutt_attach" + +# the name of the debug file if debugging is turned on. +debug_file=$tmpdir/debug + +# debug. yes or no. +#debug="no" +debug="yes" + +type=$2 +open_with=$3 + +# make sure the tmpdir exists. +mkdir -p $tmpdir + +# clean it out. Remove this if you want the directory +# to accumulate attachment files. +rm -f $tmpdir/* + +# Mutt puts everything in /tmp by default. +# This gets the basic filename from the full pathname. +filename=`basename $1` + +# get rid of the extenson and save the name for later. +file=`echo $filename | cut -d"." -f1` + +if [ $debug = "yes" ]; then + echo "1:" $1 " 2:" $2 " 3:" $3 > $debug_file + echo "Filename:"$filename >> $debug_file + echo "File:"$file >> $debug_file + echo "===========================" >> $debug_file +fi + +# if the type is empty then try to figure it out. +if [ -z $type ]; then + file $1 + type=`file -bi $1 | cut -d"/" -f2` +fi + +# if the type is '-' then we don't want to mess with type. +# Otherwise we are rebuilding the name. Either from the +# type that was passed in or from the type we discerned. +if [ $type = "-" ]; then + newfile=$filename +else + newfile=$file.$type +fi + +newfile=$tmpdir/$newfile + +# Copy the file to our new spot so mutt can't delete it +# before the app has a chance to view it. +cp $1 $newfile + +if [ $debug = "yes" ]; then + echo "File:" $file "TYPE:" $type >> $debug_file + echo "Newfile:" $newfile >> $debug_file + echo "Open With:" $open_with >> $debug_file +fi + +# If there's no 'open with' then we can let preview do it's thing. +# Otherwise we've been told what to use. So do an open -a. + +if [ -z $open_with ]; then + open $newfile +else + open -a "$open_with" $newfile +fi diff --git a/mutt-wizard.sh b/mutt-wizard.sh index f8c8482..ed487c9 100755 --- a/mutt-wizard.sh +++ b/mutt-wizard.sh @@ -148,7 +148,7 @@ EOF fi realname=$( dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Enter the full name you'd like to be identified by on this email account." 10 60 3>&1 1>&2 2>&3 3>&- ) title=$( dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Give a short, one-word name for this email account that will differentiate it from other email accounts." 10 60 3>&1 1>&2 2>&3 3>&- ) -login=$(dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Enter your login for the \"$title\" account.\n(If left empty, the full email address will be used instead.)" 10 60 3>&1 1>&2 2>&3 3>&- ) +login=$(dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "If you have a username for the \"$title\" account which is different from your email address, enter it here. Otherwise leave this prompt blank." 10 60 3>&1 1>&2 2>&3 3>&- ) # Sets the repo type and other variables for the sed regex. if [[ "$service" == "gmail.com" ]]; then diff --git a/view_attachment.sh b/view_attachment.sh deleted file mode 100755 index df8b9a1..0000000 --- a/view_attachment.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash -# -# Author: Eric Gebhart -# -# Purpose: To be called by mutt as indicated by .mailcap to handle mail attachments. -# -# Function: Copy the given file to a temporary directory so mutt -# Won't delete it before it is read by the application. -# -# Along the way, discern the file type or use the type -# That is given. -# -# Finally use 'open' or 'open -a' if the third argument is -# given. -# -# -# Arguments: -# -# $1 is the file -# $2 is the type - for those times when file magic isn't enough. -# I frequently get html mail that has no extension -# and file can't figure out what it is. -# -# Set to '-' if you don't want the type to be discerned. -# Many applications can sniff out the type on their own. -# And they do a better job of it too. -# -# Open Office and MS Office for example. -# -# $3 is open with. as in open -a 'open with this .app' foo.xls -# -# Examples: These are typical .mailcap entries which use this program. -# -# Image/JPEG; /Users/vdanen/.mutt/view_attachment %s -# Image/PNG; /Users/vdanen/.mutt/view_attachment %s -# Image/GIF; /Users/vdanen/.mutt/view_attachment %s -# -# Application/PDF; /Users/vdanen/.mutt/view_attachment %s -# -# #This HTML example passes the type because file doesn't always work and -# #there aren't always extensions. -# -# text/html; /Users/vdanen/.mutt/view_attachment %s html -# -# # If your Start OpenOffice.org.app is spelled with a space like this one, <-- -# # then you'll need to precede the space with a \ . I found that too painful -# # and renamed it with an _. -# -# Application/vnd.ms-excel; /Users/vdanen/.mutt/view_attachment %s "-" '/Applications/OpenOffice.org1.1.2/Start_OpenOffice.org.app' -# Application/msword; /Users/vdanen/.mutt/view_attachment %s "-" '/Applications/OpenOffice.org1.1.2/Start_OpenOffice.org.app' -# -# -# Debugging: If you have problems set debug to 'yes'. That will cause a debug file -# be written to /tmp/mutt_attach/debug so you can see what is going on. -# -# See Also: The man pages for open, file, basename -# - -# the tmp directory to use. -tmpdir="$HOME/.tmp/mutt_attach" - -# the name of the debug file if debugging is turned on. -debug_file=$tmpdir/debug - -# debug. yes or no. -#debug="no" -debug="yes" - -type=$2 -open_with=$3 - -# make sure the tmpdir exists. -mkdir -p $tmpdir - -# clean it out. Remove this if you want the directory -# to accumulate attachment files. -rm -f $tmpdir/* - -# Mutt puts everything in /tmp by default. -# This gets the basic filename from the full pathname. -filename=`basename $1` - -# get rid of the extenson and save the name for later. -file=`echo $filename | cut -d"." -f1` - -if [ $debug = "yes" ]; then - echo "1:" $1 " 2:" $2 " 3:" $3 > $debug_file - echo "Filename:"$filename >> $debug_file - echo "File:"$file >> $debug_file - echo "===========================" >> $debug_file -fi - -# if the type is empty then try to figure it out. -if [ -z $type ]; then - file $1 - type=`file -bi $1 | cut -d"/" -f2` -fi - -# if the type is '-' then we don't want to mess with type. -# Otherwise we are rebuilding the name. Either from the -# type that was passed in or from the type we discerned. -if [ $type = "-" ]; then - newfile=$filename -else - newfile=$file.$type -fi - -newfile=$tmpdir/$newfile - -# Copy the file to our new spot so mutt can't delete it -# before the app has a chance to view it. -cp $1 $newfile - -if [ $debug = "yes" ]; then - echo "File:" $file "TYPE:" $type >> $debug_file - echo "Newfile:" $newfile >> $debug_file - echo "Open With:" $open_with >> $debug_file -fi - -# If there's no 'open with' then we can let preview do it's thing. -# Otherwise we've been told what to use. So do an open -a. - -if [ -z $open_with ]; then - open $newfile -else - open -a "$open_with" $newfile -fi -- cgit v1.2.3