Skip to content

Instantly share code, notes, and snippets.

@reorx
Created February 13, 2014 08:06
Show Gist options
  • Select an option

  • Save reorx/8971484 to your computer and use it in GitHub Desktop.

Select an option

Save reorx/8971484 to your computer and use it in GitHub Desktop.
#!/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 %@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment