One of the functionalities that was demanded of me prior to switching systems over to Linux was the "right click -> attach to email" that existed in Windows. I'm not sure the exact command, but basically it was incredibly easy to send a file to someone via email. After all, why should you have to go hunting for a file in both the file manager and in the email application? Windows (or whatever) would also resize any attached images so that they were 'email worthy' instead of being 3 megs a piece and since the business this was written for is heavy into sending photos back and forth, this was a necessity. So, I wrote up a rather primitive but effective script to do so. The script 'belongs' to me, but as far as I'm concerned, anyone can have it.
Instructions on use:
Put the following in /usr/share/kde4/services/ServiceMenus/thunderbird_attachment.desktop
- Code: Select all
[Desktop Entry]
Type=Service
Actions=attachToEmail
Encoding=UTF-8
ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/all;
ExcludeServiceTypes=application/x-iso
[Desktop Action attachToEmail]
Exec=/opt/thunderbird_extra/compress_and_send.sh %F
Name=Attach to Thunderbird Mail
Icon=/usr/share/icons/mozilla-thunderbird.png
Put the following in /opt/thunderbird_extra/compress_and_send.sh
- Code: Select all
#!/bin/bash
SAVE_IFS=$IFS
folder=`mktemp -d`
declare files=()
IFS="
"
fileList=("$@")
for i in "${fileList[@]}"; do
thefile=$i
type=`mimetype $i`
type=`echo $type | grep -oE "([^: ]+)$"`
echo "$thefile $type"
case $type in
"inode/directory")
for mi in `ls -1 "$thefile"`; do
fileList+=("$thefile/$mi")
done
;;
esac
done
for i in "${fileList[@]}"; do
thefile=$i
type=`mimetype $i`
type=`echo $type | grep -oE "([^: ]+)$"`
echo "$thefile $type"
filepath=''
case $type in
"image/jpeg")
filename=${thefile##*/}
filepath="$folder/$filename"
`convert -scale 640x480 "$thefile" "$filepath"`
filename=$(echo "$filename" | sed -e 's/%/%25/g' -e 's/ /%20/g' -e 's/!/%21/g' -e 's/"/%22/g' -e 's/#/%23/g' -e 's/\$/%24/g' -e 's/\&/%26/g' -e 's/'\''/%27/g' -e 's/(/%28/g' -e 's/)/%29/g' -e 's/\*/%2a/g' -e 's/+/%2b/g' -e 's/,/%2c/g' -e 's/-/%2d/g' -e 's/\./%2e/g' -e 's/\//%2f/g' -e 's/:/%3a/g' -e 's/;/%3b/g' -e 's//%3e/g' -e 's/?/%3f/g' -e 's/@/%40/g' -e 's/\[/%5b/g' -e 's/\\/%5c/g' -e 's/\]/%5d/g' -e 's/\^/%5e/g' -e 's/_/%5f/g' -e 's/`/%60/g' -e 's/{/%7b/g' -e 's/|/%7c/g' -e 's/}/%7d/g' -e 's/~/%7e/g')
filepath="$folder/$filename"
;;
"inode/directory" | "application/x-sqlite3")
;;
*)
filepath="$thefile"
;;
esac
if [ "$filepath" != "" ]; then
files+=("file://$filepath")
fi
done
IFS=","
filesJoined="${files[*]}"
IFS=$SAVE_IFS
thunderbird -compose "attachment=`echo $filesJoined | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g'`"
Make sure that compress_and_send.sh is executable.
Close out of all dolphin windows and then open up a window. You should be able to 'right click' and then go to 'Actions' and then 'Attach to thunderbird mail'.
If the mageia folks would like to clean this up and wrap it in somehow, that'd be awesome. I think it only requires 'convert' from the imagemagik library/program/what-have-you.