#!/bin/bash
#Send email in thunderbird. First, try to connect to a running process; then start a new process if required.
#Argument 1 is "To" and argument 2 is "Subject"
if [ -n "$1" ]; then TO="$1" ; else TO="nobody@example.com" ; fi
if [ -n "$2" ]; then SUBJECT="$2" ; else SUBJECT="" ; fi
( $HOME/bin/mozilla-thunderbird -remote "openurl(mailto:$TO?subject=$SUBJ)" || $HOME/bin/mozilla-thunderbird "mailto:$TO?subject=$SUBJ" ) &
exit 0
