Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I would like to resize the window to the left half of the screen.

A solution to achieve that would be to use wmctrl and keybind the right command to a keyboard shortcut.

But the manpage only shows how to resize to a certain height and width, for example:

wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,0,800,1040

that moves the window to the upper left corner and resizes to 800x1040 px.

But strangely only the first time. If you execute the same command again, in moves to the very top right of the screen, ignoring the top-toolbar.

Also it would be nice, to have that comand with height 100% and width 50% instead the absolute values.

share|improve this question

2 Answers 2

you can use xrandr to get(or set) the screen resolution and then use wmctrl to resize your window.

share|improve this answer
up vote 1 down vote accepted

I got the answer here.

this would be the script to maximize it to the right half of the screen:

# resizes the window to full height and 50% width and moves into upper right corner

#define the height in px of the top system-bar:

#sum in px of all horizontal borders:

# get width of screen and height of screen
SCREEN_WIDTH=$(xwininfo -root | awk '$1=="Width:" {print $2}')
SCREEN_HEIGHT=$(xwininfo -root | awk '$1=="Height:" {print $2}')

# new width and height

# X, change to move left or right:

# moving to the right half of the screen:
X=$(( $SCREEN_WIDTH / 2 ))
# moving to the left:


wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$X,$Y,$W,$H

To move to the left, just change the X-Line to X=0. (If you use Ubuntu Unity, you need to adapt RIGHTMARGIN too I use RIGHTMARGIN=102)

defining the right margins this solves the bug, that the second time you call it, it moved to the very top of the screen, ignoring the top-toolbar.

share|improve this answer
Here I describe How to put this script on a keyboard shortcut: Is it possible to place windows with keyboard shortcuts in Xfce? – rubo77 Jul 27 '14 at 5:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.