#!/usr/bin/perl

#######################################
# Based on thunderbird_wrapper.sh, v1.0
# by David LaPorte (09/23/05)
# 
# rewritten in Perl by
# Christian Schoemmer (01/13/06)
#######################################

use strict;

my($SENDER,$SUBJECT,$MESSAGESIZE,$SIZE_FORMAT,$APP,$GROWLNOTIFY);

$SUBJECT = $ARGV[0];
$SENDER = $ARGV[1];
$MESSAGESIZE = $ARGV[3];

$APP = "Thunderbird";

# Location of growlnotify (located in Growl distribution)
# You will need to move it from the DMG to a local path
$GROWLNOTIFY="/usr/local/bin/growlnotify";

if ($MESSAGESIZE >= 1000000){
    $SIZE_FORMAT = ($MESSAGESIZE/1000000)." MegaBytes";
}elsif ($MESSAGESIZE >= 1000 && $MESSAGESIZE < 1000000){
    $SIZE_FORMAT = ($MESSAGESIZE/1000)." kBytes";
}else{
    $SIZE_FORMAT = $MESSAGESIZE." Bytes";
}

system("$GROWLNOTIFY -a \"$APP\" -t \"Subject: $SUBJECT\" -m \"From: $SENDER\nSize: $SIZE_FORMAT\"");

