I am fairly certain it is impossible to do. The reason seams to be that windowing environments like GNOME expect software to handle this, and software makers expect windowing environments to handle this.
Devilspie is a good idea, but it does pattern matching (ie. if name == 'google-chrome'). So what happens if I open two browsers? They both get moved to the same workspace? I have 6x3=18 workspaces, each one with a particular instance of chrome. It would help if I could rename these programs (ie 'google-chrome1', 'google-chrome2'...) but I can't find a way to do that. So we have to use wmctrl.
wmctrl is a little better b/c in addition to using window titles, you can also use window IDs or just use the currently highlighted window. Window IDs are a pain to get b/c they are not immediately generated. See below
gedit 1.txt
#get window ID by looking at wmctrl -l store in windowID
wmctrl -i -r $windowID -e 0,3660,0,-1,-1
but then control is not returned to the command line until AFTER gedit exits. All we have to do to get around this is put a &
sign
gedit 1.txt &
#get window ID by looking at wmctrl -l store in windowID
wmctrl -i -r $windowID -e 0,3660,0,-1,-1
but now control is, 99.999% of the time, returned to the command line BEFORE the window managers launches the window and there is no way to find the window id. One has to set up a very complex looping technique to test to see if any new windows have been created, and to guess whether it is the window we are looking for.
Checking for the active window via the flag :ACTIVE:
has the same problem, it does not wait for the program to finish running.
wmctrl
strikes me as a very weird program. It seems like it was designed for people without a mouse, or unable to physically drag their programs across workspaces.
1If you always have these programs running, the easiest and simplest way is to load them all up where you want them and 'remember applications when logging out' – Unfundednut – 2011-01-12T01:23:23.540
1@MrStatic : Thanks for the suggestion, but I do need it to be in a shell script for other reasons - and for that I cannot 'remember applications when logging out' – bguiz – 2011-01-12T02:38:46.943