Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When undocking my laptop from twinview external monitors back to a single screen I would like to have a single command to move all windows onto my primary screen.

Although nvidia does some of the work so that I can see the edge of the windows, moving each one with the mouse, keyboard or compiz plugins takes time.

share|improve this question
add comment

2 Answers 2

You can use wmctrl and a little bash script to loop through the windows and then position them onto your primary display. I threw this together. It might be sufficient for you.

#! /bin/bash

#dump the list of windows to a file
wmctrl -l > /tmp/window_list.txt
x=40; y=40

#read the window information from the file
while read id sticky host win_title; do

    #move any non-sticky windows except the desktop
    if [ "$sticky" == "0" -a "$win_title" != "x-nautilus-desktop" ]
      then
        wmctrl -i -r $id -e 0,$x,$y,-1,-1
        x=$(($x + 40))
        y=$(($y + 40))
    fi

done < /tmp/window_list.txt

#delete the temporary file
rm /tmp/window_list.txt
exit 0

Save it to a file called "move_windows.sh" or something and give it execute permissions with chmod +x move_windows.sh and then create a launcher for it.

share|improve this answer
    
Oh, almost forgot. I don't use Unity so I'm not sure what it will do in that environment. –  Ramón May 26 '11 at 0:26
    
Yep it need some tweaks for unity, ill test again tomorrow. –  Cas May 26 '11 at 1:38
    
Thank you! Your script was very useful in finding a workaround for a bug I had with openbox (it would crash every time I switched monitor configuration if a window was on an external monitor). –  Glutanimate Mar 7 '13 at 4:14
add comment

I would love to find a better solution, but Compiz has Grouping of windows.

share|improve this answer
add comment

Your Answer

 
discard

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.