reorx
2/13/2014 - 8:06 AM

thunderbird_start.sh

#!/bin/bash

#wait for internet connection up to 15 seconds
host=baidu.com
CONNECTED=$(ping -w5 -c1 $host > /dev/null 2>&1 && echo "up" || echo "down")
STOPWATCH=0
while [ "$CONNECTED" = "down" ] && [ $STOPWATCH -lt 15 ]; do
    sleep 1;
    CONNECTED=$(ping -w5 -c1 $host > /dev/null 2>&1 && echo "up" || echo "down")
    let STOPWATCH++
done

#run Thunderbird
thunderbird &

#Search for Thunderbird window
TB=$(xdotool search --class thunderbird)
while [ -z "$TB" ]; do
    sleep 10 #Adjust this to your system needs
    TB=$(xdotool search --class thunderbird)
done

#dispose Thunderbird window
xdotool search --class thunderbird windowunmap %@