#!/bin/bash # open a kml/kmz file in an already started Google Earth instance # 2007116 - JJL - http://kubuntu.free.fr/ # needs : # wmctrl : http://www.sweb.cz/tripie/utils/wmctrl/ # xautomation : http://hoopajoo.net/projects/xautomation.html # xclip : http://people.debian.org/~kims/xclip/ # PUB : utilisez WiKiss http://wikiss.tuxfamily.org # AD : use WiKiss http://wikiss.tuxfamily.org dialog=`which kdialog || which zenity || echo echo -e` # test arguments if [ -z "$1" ] then $dialog --error "Missing argument\nusage: $0 " exit 1 fi # test presence of needed programs # $1: program, $2 url function needed { if [ -z `which $1` ] then $dialog --error "Missing $1\nSee $2" exit 1 fi } needed "wmctrl" "http://www.sweb.cz/tripie/utils/wmctrl/" needed "xte" "http://hoopajoo.net/projects/xautomation.html" needed "xclip" "http://people.debian.org/~kims/xclip/" ## MAIN ## # get GE window id GE_ID=$(wmctrl -l|grep "Google Earth$"|cut -f 1 -d ' ') if [ -z "$GE_ID" ] then # first start of ge googleearth "$1" & exit 0 fi # raise GE in front wmctrl -i -a "$GE_ID" # open the file dialog xte 'keydown Control_L' 'key o' 'keyup Control_L' # copy file to clipboard echo -n "$1"|xclip -sel clip # paste into GE xte 'sleep 1' 'keydown Control_L' 'key v' 'keyup Control_L' 'key Return' exit 0