This is my solution. The automation is done by a python script using the "subprocess" command and the "xdotool" command.
The code is rustic, but it works.
Here is the file:
#!/usr/bin/python
import subprocess
import shlex
import os
import time
from Xlib import X, display
# The following was installed using Ubuntu Software Center
# python-xlib
# xdotool
def TrackMouseCoordinates():
#import time
#from Xlib import X, display
while True:
d = display.Display()
s = d.screen()
root = s.root
a=root.query_pointer()
b=a._data
print b["root_x"], b["root_y"]
d.sync()
time.sleep(1)
def GetActiveWindowTitle():
return subprocess.Popen(["xprop", "-id", subprocess.Popen(["xprop", "-root", "_NET_ACTIVE_WINDOW"], stdout=subprocess.PIPE).communicate()[0].strip().split()[-1], "WM_NAME"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].strip().split('"', 1)[-1][:-1]
def GetWindowIdOfOpenActiveWindow(windowName):
p = subprocess.Popen(["xdotool", "search", "--name",
windowName],
shell=False,stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
p.wait()
out = p.stdout.read()
idwin = out.split("\n")[0]
return idwin
def OpenAllDesiredTerminalsAndReturnActiveTerminal():
# create terminals
#activeWinTitle = ""
# geometry is widthxheight+x+y 50x10+1935+20
subprocess.call(["xdotool", "exec", "gnome-terminal", "--geometry=100x10+1935+20", "--working-directory=sam"])
#subprocess.call(["xdotool", "exec", "gnome-terminal", "--geometry=40x5+20+20", "--working-directory=SQ_bin"])
#time.sleep(5) # Necessary to let processes complete
# click on a terminal to activate it (activating sam terminal at 705,37)
#subprocess.call(["xdotool", "mousemove", "705", "37","click", "1"])
#activeWinTitle = GetActiveWindowTitle()
#print 'Active window title: ', activeWinTitle
#return activeWinTitle
def sendKeystrokesToWindow(windowID,keystrokes):
#print "sending command %s " %command
#subprocess.call(["xdotool", "key", "%s" % command ])
subprocess.call(["xdotool", "type", "--window", "windowID", keystrokes])
def openROSrelatedApplications():
# Home Folder GUI
subprocess.call(["xdotool", "exec", "nautilus"])
# Chromium Browser
subprocess.call(["xdotool", "exec", "chromium-browser"]) #, "%U"])
# Tomboy Notes
subprocess.call(["xdotool", "exec", "tomboy", "--search"]) #, "%U"])
# 4 Terminals
#----------------Main-----------------
#TrackMouseCoordinates()
# open applications
openROSrelatedApplications()
# create terminals
OpenAllDesiredTerminalsAndReturnActiveTerminal()
#terminalName=OpenAllDesiredTerminalsAndReturnActiveTerminal()
# get window id of active terminal
#terminID=GetWindowIdOfOpenActiveWindow(terminalName)
# send keystrokes to active terminal
#sendKeystrokesToWindow(terminID,"ls\n") #roscd beginner_tutorials
#----------------Main-----------------