Position at central workspace on login
I have set up 3x3 workspace switcher, and I want my position to be on the central one by default. Is it possible?
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:
center_row=$((rows / 2))
center_col=$((cols / 2))
center_x=$((center_col * viewport_w))
center_y=$((center_row * viewport_h))
center_viewport=$center_x,$center_y
And move the viewport there:
wmctrl -o $center_viewport
Yes: install wmctrl
sudo apt-get install wmctrl
and create a file in ~/.config/autostart/wmctrl.desktop
with the following:
[Desktop Entry]
Name=Desktop Switcher
Exec=/usr/bin/wmctrl -s 4
Type=Application