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.
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 usingwmctrl -s <DESKTOP>
. Desktop numbers start at 0. On one line, this would be: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:
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 can be installed on Ubuntu with
sudo apt-get install wmctrl
.) At present, this doesn't seem to work with standard Unity, unfortunately.It is possible to do this with
xdotool
, but if you are usingcompiz
this solution might not be applicable, so please keep this in mind.To switch a particular window (the active window) to a different workspace, you could use
Or for a script you might want to switch a particular program's windows to a given workspace with:
This command searches and finds the
firefox
window(s) and transfers them to workspace 1, where they will appear minimised. To returnfirefox
to the default desktop, just replace the 1 with a 0 at the end of the command. To send a different window to another workspace, just replacefirefox
with another program name.It is crucial you use
%@
to represent the windows passed from the--search
parameter, as if you don't no windows will be transferred.For more information, see
man xdotool
and the Ubuntu manpages online.Here is a script of mine that implements what you ask: https://github.com/norswap/wmov/blob/master/wmov.sh
In it's current form, it can send windows (selected by matching a case-insensitive string against substrings title, like for the
wmctrl
-r
option) to other desktops, either by choosing an explicit desktop number, or by indicating the direction of the desktop from the current desktop.For instance:
It works indeed as described in desgua's post. It also the capabilities to send windows to other workspaces.
If you are using compiz, then look here at the compiz wiki. There you find several examples. Look at the "put" plugin.
Example
Firstly, the colon is part of the
:ACTIVE:
magic token to indicate the active window. You don't want it normally. Second, you need to quote strings with spaces in them.You can also get the window ID (the
0x...
at the start of each line) and use that instead of trying to make the title work.By modifying a bit the script that it's given as solution to this question, the following "brings" a given window to the current workspace (in compiz):
If an arbitrary workspace is desired, then it's a matter of adding/substracting the corresponding
$SCREEN_W
/$SCREEN_H
, as many times as workspaces a window is away from the target one.Try:
let me explain: in the help of wmctrl shows
wmctrl -d
can list all the workspaces, in my computer now shows as following:* means the current workspace
BTW,
wmctrl -l
is to list all the windows(which you already known), in my computer now they are:since the "DESK" must be the number, I use
grep “workspace name” | cut -d" " -f1
to get it.For example, if I wanna move Firefox to workspace"code" , I can use:
or
but
Just work me once, and I don't know why!