#!/bin/sh
# run-thunderbird.sh
#
# 1) Download this script to /usr/local/bin
# 2) chmod 755 run-thunderbird.sh
# 3) Set Mail Reader in Preferred Applications as "run-thunderbird.sh %s"
#

export MOZILLA_FIVE_HOME=/usr/lib/thunderbird
 
url=`echo "$1" | sed -e's/^mailto://'`
 
# thunderbird is already running
if [ $(ps aux | grep thunderbird | wc -l) -gt 4 ]; then
        $MOZILLA_FIVE_HOME/thunderbird -remote "mailto($url)"
 
# thunderbird is NOT running
else
        $MOZILLA_FIVE_HOME/thunderbird -P default -compose $1;
fi
