Bring an open window to the current desktop in Linux

4

2

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.

tony_sid

Posted 2010-08-02T14:46:41.700

Reputation: 11 651

Are you using Gnome as your window manager? (It is the default one for Ubuntu) – Jarvin – 2010-08-02T15:43:34.223

Yes, that's what I'm using. – tony_sid – 2010-08-02T21:52:23.663

Answers

3

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.

Related

Resources

Bruce van der Kooij

Posted 2010-08-02T14:46:41.700

Reputation: 242