[ltp] [OT]: KDE hack: script to list and control windows?

Richard Neill linux-thinkpad@linux-thinkpad.org
Fri, 24 Feb 2006 02:03:52 +0000


Matt Graham wrote:
>>I'm trying to find some shell functions which will allow me to list 
>>windows and to maximise/minimise them.
> 
> 
> Install wmctrl and use it.  "wmctrl -l" , "wmctrl -r WINDOW -b maximize"
> 

Thank you!  That works excellently.
http://sweb.cz/tripie/utils/wmctrl/

Interestingly, I *still* can't come up with a google query that would 
have found this without advance knowledge of its name. Google will never 
be a substitute for expert human advice!


>>This would either be done by X or perhaps DCOP.
> 
> DCOP is a neat idea, but the functions you need may not be there for all
> programs.

Yes - that's usually what I have found. Most of the really useful 
functions are missing from DCOP. There are some obscure ones, but not 
nearly enough!  These, however are extremely useful:

   (1)  dcop klipper klipper getClipboardContents
   (2)  dcop klipper klipper setClipboardContents "`cat`"

These are one line shell scripts allowing you to send text to/from the 
clipboard via a pipe.


>>Also, is there any obvious way to convert between X's WINDOW_ID and the 
>>PID of the process?
> 
> Hell no.  wmctrl may or may not list PIDs for running X clients, depending on
> various factors.  It looks like KDE and GNOME apps and Firefox usually have
> PIDs listed, but xeyes and xterm don't.  Running an X client on a remote
> machine means that no PID will be available for that client on your local
> machine, naturally. 

I thought so. xlsclients and xprop etc go part of the way, but not 
sufficiently. However, wmctrl makes this requirement redundant.


Thanks a lot. I'll post the script when it's done.

Richard