Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Are you using Gnome as your window manager? (It is the default one for Ubuntu) – Jarvin Aug 2 '10 at 15:43
Yes, that's what I'm using. – tony_sid Aug 2 '10 at 21:52
up vote 2 down vote accepted

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?):

    dbus-send --type=method_call --dest=org.freedesktop.compiz /org/freedesktop/compiz/put/allscreens/put_viewport_2_key org.freedesktop.compiz.activate

That's pretty much it, hopefully somebody else can offer more insight into the matter.



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.