Monday, August 2, 2010

Nautilus sendto thunderbird

Problem: In ubuntu sending a file as an email attachment, while browsing files in graphical file manager

Solution:
Nautilus already has a send-to plugin to support the same. I hit the barrier as I am a thunderbird user and this utility supports evolution by default. Even changing System->Preferences->Preferred Application also did not help. There are some solution available to install a thunderbird plugin to send-to. It seemed to cause a segfault for nautilus-sendto.
Then found out a pretty simple solution to the problem -
1. Created a file in ~/.gnome2/nautilus-scripts named mySend as executable with the following content
thunderbird -compose attachment="file://$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
2. Restart nautilus: killall nautilus
Now you should have an option on nautilus right click
Scripts > mySend

For this there is no need to remove sendto plugin.

Also wrote a brief shell script to do it from commandline
$ cat ~/bin/mySend

if [ $# -ne 1 ]
then
echo "Usage:mySend "
exit
fi

if [ -d "$1" ]
then
echo "Don't provide a directory name"
exit
fi

RLTV_PATH=1
FILENAME=$PWD"/""$1"

if [ ! -f "$FILENAME" ]
then
if [ ! -f "$1" ]
then
echo "File does not exist!!!"
exit 1
else
RLTV_PATH=0
fi
fi

if [ $RLTV_PATH -eq 1 ]
then
atchment_str="file://"$FILENAME
else
atchment_str="file://"$1
fi

#debug
#echo "RLTV: "$RLTV_PATH "FILE: "$FILENAME "ATCH: "$atchment_str

thunderbird -compose attachment="$atchment_str"