Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a laptop with a docking station that has a large monitor connected to it. When the laptop is docked, I use the monitor as my primary display, and the laptop screen as a secondary display.

When I undock, the laptop screen becomes my primary display, and all the windows move over to it. When I dock the laptop, the monitor automatically becomes the primary display again, but the windows all stay on the laptop screen. I have to drag each one over to the monitor and resize it.

How can I get my windows to automatically resume the positions and sizes they had just before I undocked (assuming they're still open)? All I've been able to find are answers talking about restoring programs when you log in. That's not what I'm looking for.

I'm using Gnome 3 on Arch Linux.

share|improve this question
I have a similar problem: When I run a game that demands full screen mode but doesn't support my native resolution, all windows move around and get resized. It would be great to have a way to save / restore them. – Aaron Digulla Jan 8 '13 at 9:02

I tried to come up with a script but ran out of time. You can find the related discussion here:


share|improve this answer

I have asked a similar question on ask ubuntu and the accepted answer contains (not-ubuntu specific) shell scripts to save / restore window positions.

The key point is to use wmctrl to list active windows and xwininfo to query their geometry and later wmctrl again to restore each window's geometry back.

wmctrl has to be installed separately.

share|improve this answer

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.