Thanks to Marco, I have figured out a way using wmctrl.
Because compiz workspaces are actually viewport of a single desktop, so the solution is to move the current viewport to cover the center region of the desktop.
First, call wmctrl -d to get the information of current desktop:
read desktop_id _ast \
DG_ geometry \
VP_ viewport \
WA_ wa_off wa_size \
title \
< <(LANG=C wmctrl -d | grep '*')
geom_w=${geometry%x*}
geom_h=${geometry#*x}
# The workarea size isn't accurate, because the top/bottom panel is excluded.
viewport_w=${wa_size%x*}
viewport_h=${wa_size#*x}
rows=$((geom_w / viewport_w))
cols=$((geom_h / viewport_h))
# Fix the viewport size
viewport_w=$((geom_w / rows))
viewport_h=$((geom_h / cols))
Then, calculate the origin of the center viewport:
I was going to ask the similar question, but for 3 horizontal workspaces and I'm also running compiz, and the wmctrl -d output (per workspace) looks like this:
Than I simply used wmctrl -o 1366,0 (VP values) to make the center as my default workspace at startup. Might not work for everyone, but just in case ;)
Just a brief note - I'm using Natty, and thanks to @谢继雷's answer, I noticed that the following is reported by moving the terminal in each of the four 'workspaces' in Unity:
$ wmctrl -d
# top left
0 * DG: 2048x1200 VP: 0,0 WA: 0,24 1024x576 Workspace 1
# bottom left
0 * DG: 2048x1200 VP: 0,600 WA: 0,24 1024x576 Workspace 1
# top right
0 * DG: 2048x1200 VP: 1024,0 WA: 0,24 1024x576 Workspace 1
# bottom right
0 * DG: 2048x1200 VP: 1024,600 WA: 0,24 1024x576 Workspace 1
... i.e. they are not neither separate desktops, nor workspaces - simply the viewport changes!
So, to change between those four viewports, simply call the wmctrl -o command directly with the VP values listed above, i.e.:
Thanks to Marco, I have figured out a way using
wmctrl
.Because compiz workspaces are actually viewport of a single desktop, so the solution is to move the current viewport to cover the center region of the desktop.
First, call
wmctrl -d
to get the information of current desktop:Then, calculate the origin of the center viewport:
And move the viewport there:
Yes: install wmctrl
and create a file in
~/.config/autostart/wmctrl.desktop
with the following:compiz-send.py
in your home folder.python compiz-send.py vpswitch switch_to_5_key
to make sure it works correctly. It should switch you to the center workspace.If it works, create a file called
.switch_to_center_workspace.sh
in your home folder and paste the following inside of it:replacing
user
with your username.Open up Startup Applications, System -> Preferences -> Startup Applications.
Click Add and in the Command: entry put
/home/user/.switch_to_center_workspace.sh
. Put whatever you want in the Name: and Comment: entries.Log out and log back in and verify that it works.
I was going to ask the similar question, but for 3 horizontal workspaces and I'm also running compiz, and the
wmctrl -d
output (per workspace) looks like this:0 * DG: 4098x768 VP: 0,0 WA: 0,24 1366x744 Workspace 1
0 * DG: 4098x768 VP: 1366,0 WA: 0,24 1366x744 Workspace 1
0 * DG: 4098x768 VP: 2732,0 WA: 0,24 1366x744 Workspace 1
Than I simply used
wmctrl -o 1366,0
(VP values) to make the center as my default workspace at startup. Might not work for everyone, but just in case ;)Just a brief note - I'm using Natty, and thanks to @谢继雷's answer, I noticed that the following is reported by moving the terminal in each of the four 'workspaces' in Unity:
... i.e. they are not neither separate desktops, nor workspaces - simply the viewport changes!
So, to change between those four viewports, simply call the
wmctrl -o
command directly with theVP
values listed above, i.e.:EDIT: Ups, sorry, just saw this is the same as @wik's answer - merge/delete as appropriate..