Ubuntu – how to shift applications from workspace 1 to 2 using command

command lineworkspaces

Is there any way I can switch the application running in one workspace to another on command line? I use Ubuntu 10.04

UPDATE1
As per suggestions below

 wmctrl -l
0x02200003 -1 bond Bottom Expanded Edge Panel
0x02200049 -1 bond Top Expanded Edge Panel
0x02000020  0 bond x-nautilus-desktop
0x04e00004  0 bond bond@bond: ~
0x0482a380  0 bond OMG! Ubuntu! | wmctrl - Chromium
0x05000072  0 bond how to shift applications from workspace 1 to 2 using command - Ask Ubuntu - Stack Exchange - Google Chrome

now when I type

wmctrl -r :OMG! Ubuntu! | wmctrl - Chromium: -t 2 No window was specified.

So how to use it properly what is the mistake in above?

UPDATE2
I tried

wmctrl -r 0x05000072 -t 2

but the windows had no effect and they remained in same work space.

Best Answer

If you are using a compliant window manager like Metacity (Unity 2-d) you can use wmctrl to switch a window to another desktop. The syntax is wmctrl -r :ACTIVE: -t <DESKTOP>. You can also change your current desktop using wmctrl -s <DESKTOP>. Desktop numbers start at 0. On one line, this would be:

wmctrl -r :ACTIVE: -t 1; wmctrl -s 1

If you want to switch a window other than the active one to another desktop, use text from the title as the argument to -r. For example:

wmctrl -r "Chromium" -t 1

Alternatively you can use wmctrl -l to list the available windows and pass the id number to -r instead of the special string :ACTIVE:. When passing an id, you also need to add -i. For example:

$ wmctrl -l
0x03e00189  0 hostname Ask Ubuntu - Chromium
$ wmctrl -i -r 0x03e00189 -t 2

(wmctrl can be installed on Ubuntu with sudo apt-get install wmctrl.) At present, this doesn't seem to work with standard Unity, unfortunately.

Related Question