Let's say I have a program open on another virtual desktop. Is there a way I can bring that program to the current desktop through a script?

The following command is the closest I can get:

wmctrl -a program

This will switch to the desktop where the program is open and make it the foremost window. However, instead of going to the desktop where the program is, I want to bring the program to the current desktop. There is also this command:

wmctrl -R program

The documentation says that this will do what I want, but it just does the same thing as the former command.

1 Answer
1

Turns out the -R switch works fine when using Metacity (the default window manager for GNOME) but not so much when using Compiz (the default window manager nowadays for Ubuntu I believe). You can check this out yourself by switching to Metacity using metacity --replace (use compiz --replace to switch back to Compiz).

Irritatingly enough I haven't been able to figure out why this doesn't work with Compiz, I still thought it would be nice to share what I've found out so far, which is:

For me wmctrl -d lists a desktop geometry (DG) of 7680x1200 (I have a resolution of 1920x1200 and use 4 workspaces).

In this case one could move the window to the second workspace by using wmctrl -e 0,1920,-1,-1,-1 (gravity, pixels from left, pixels from top, window width, window height -- the value -1 is used to indicate that the current value should not be modified).

You can among other things use wnckprop or xwininfo to get the geometry values for the current window.

With the Put plugin activated one can use the following command to move the current active/focused window to the second workspace (viewport?):