http://www.perlmonks.org?node_id=803821

LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

It should be trivial but my googling strategy failed for half an hour now...

I want to retrieve which applications have an open window and manipulate location and geometry of these windows.

Maybe it's XY ... I just want to automatize changing between different screen settings with browsers and editor and other applications on different screens I use for development...

Apparently gnome doesn't have a standard tool to tile windows ...

Cheers Rolf

...ahh meanwhile got some hits while searching! 8)

Do you folks recommend wmctrl and X11::WMCtrl or are there better ways to do it? UPDATE: thanx guys, sometimes asking is already the answer, I'm already using wmctrl! 8)

Replies are listed 'Best First'.
Re: Moving and resizing application in X Window Manager
by jettero (Monsignor) on Oct 28, 2009 at 22:58 UTC
    I use X11::GUITest for this stuff. I used to like the KGS Go server, but I hated the way the client interacted with my linux desktop. WMS made several terrible design decisions that made it somewhat less portable than Java programmers pretend their programs should be... ... so I wrote a program to find KGS windows and move them back onto my desktop (from off the screen) and/or put them where I want them to go (instead of whatever random position WMS calculated). I won't cut and paste the whole thing, but here's basically how it worked:

    Also, I may not understand Gnome/kde vs Metacity/sawfish/openbox -- but I don't think Gnome moves windows around, that's metacity. Metacity doesn't handle the panels, that's gnome... maybe I'm way off.

    -Paul

      Thanx Paul, I really appreciate your help + code samples!

      I already got wmctrl installed and running it does everything I need so far! 8)

      ... and yes the WM is indeed metacity, the default installed with gnome. (Actually I really do not care much, as long as I have the least possible administration tasks setting up my ubuntu box, which may distract me from hacking ... )

      Anyway X11::GUITest does muuuuch more than wmctrl, e.g sending keystrokes to the app, simulating a typing user - excellent!

      That's something I have on my todo list for a long time now, so muchas gracias again!!! 8)

      Cheers Rolf

Re: Moving and resizing application in X Window Manager
by skx (Parson) on Oct 28, 2009 at 22:53 UTC

    I appreciate this isn't a perl solution, but you might enjoy devil's pie.

    Steve
    --
      thanx steve! :)

      from what I understand in the docs it's more kind of a customizer for windows default behavior by defining "rules", like always open the mailer in the upper-right corner. Isn't it?

      I need more little individualized solutions for different projects like adjusting emacs, firefox + error-console and/or different other browsers. So calling several little scripts is more what I need.

      But I think devilspie is in general a good and necessary extension to metacity! 8)

      Cheers Rolf

Re: Moving and resizing application in X Window Manager
by zentara (Archbishop) on Oct 29, 2009 at 15:31 UTC
    see automate your linux window manager for some ideas.... i found the c app works better, but it probably depends alot on which window manager you are using, what version, and platform

    ...in my limited experience... it works like this...... if you want full control over apps, you need to write the controls into the apps themselves for best results.... but if you want to control any app from the window manager level... wmctrl is probably the best bet so far.... system security makes it tricky to give too much control to the window manager.... so control is limited and may seem buggy.... what do you expect for free? :-)


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku