Re: [kde] Hotkey to move windows to predetermined location and geometry?

2012-03-13 Thread Dotan Cohen
On Mon, Mar 12, 2012 at 21:41, Anne Wilson cannewil...@googlemail.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On 12/03/12 18:30, Dotan Cohen wrote:
 I have two applications that I often use in tandem, each with a
 specific geometry and position on the screen. Is there a hotkey
 that one could set up to move these windows to my preferred
 location and sizes? One of them is a KDE app (Konsole), the other
 is a Qt app (Anki).

 Thanks.


 KWin rules will ensure that they go there whenever you open them.  You
 might like to read the tutorial starting at
 http://userbase.kde.org/KWin_Rules

 Anne

Thanks Anne. I actually do need to move already-open windows, not new
windows. The reason is that I _usually_ need the two windows
horizontally-aligned, but sometimes I need vertically-aligned. So a
quick way to swap between these two states is what I am after.


-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
___
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.

Re: [kde] Hotkey to move windows to predetermined location and geometry?

2012-03-13 Thread Duncan
Dotan Cohen posted on Tue, 13 Mar 2012 13:22:41 +0200 as excerpted:

 On Tue, Mar 13, 2012 at 03:22, Duncan 1i5t5.dun...@cox.net wrote:

 2) The scriptable solution makes use of a very handy little app called
 wmctrl.  You can call wmctrl with appropriate options to move and/or
 resize to specific coordinates, close or move to other desktops various
 already open windows, in a real-time manner.

 Thanks, Duncan! The wmctrl does seem to be what I am looking for. I
 installed it and tried playing with it a bit, but I could not get it do
 affect any windows. I'll start googling around as I am certain that I am
 missing some thing obvious.

First thing, be sure you're either running it as the user you're logged 
into kde as, in an environment inherited from kde (such as from a konsole 
window, not from a virtual terminal text login that doesn't know about 
your X session), or that you set the DISPLAY variable, etc.  In konsole 
it should be set automatically, tho.  You can check the variable in 
konsole by issuing the echo $DISPLAY command (no quotes of course).  
Here, it returns :0 (no quotes).

Second thing, checkout the manpage, and first try the -l option (with 
some windows open, of course, for it to report on).  That should list the 
managed windows, including a plasma-desktop window for the desktop 
itself, and for each of the panels (so here I have three plasma-desktop 
windows listed, two panels plus the desktop).  Similarly, -d should list 
your desktops, and -m should list the window manager (KWin) and some info 
about it.  If those options aren't reporting anything, wmctrl isn't 
seeing your X/kde session for some reason.

You can then try wmctrl -d to list the desktops, wmctrl -n number to 
set it to one more than there were, and wmctrl -d again, to check that it 
took.  Of course you can then set it back to the normal number of 
desktops if you wish.

All these basics work, here.

Third, the following should be obvious, and probably will be in 
hindsight, but it still feels a bit weird to me, and if I hadn't been 
paying attention reading the manpage, I'd have gotten in wrong:

Near the bottom of the manpage it explains the WIN parameter notation.  
It's worth noting that we're working with WINDOWS here, NOT WHOLE 
PROCESSES, so feeding wmctrl a PID (process-ID) as you'd feed to kill, or 
feeding it a procname/exename, as you'd feed to killall, will probably 
*NOT* work as intended.

If you think about it, it couldn't work that way, since as I mentioned 
above, plasma-desktop for instance has three open windows here, and just 
using the PID or process name isn't enough to identify which window you 
intended to manipulate.

Instead, the WIN paramater by default substring-matches (case 
insensitive) against the window TITLE.  Thus, the TITLE is what you need 
to match against.

For instance, here, I have a konsole window sitting at the bash prompt, 
with bash in the titlebar.  I've ensured that it's the only one running 
ATM so the wrong one won't get matched, accidentally.  Typing this at 
that konsole prompt causes that window to close, as you'd expect from the 
manpage:

wmctrl -c bash

Meanwhile, wmctrl -c konsole doesn't close the window (tho it might close 
another one with konsole in the name if there is one), because that's the 
name of the app, not the title of the window.


Fourth, try the mentioned :SELECT: special string, as mentioned in the 
manpage under the WIN description, like this:

wmctrl -c :SELECT:

That should give you a cross-hairs pointer, that lets you click on a 
window to close it.  Don't click the wrong one! =:^)

Fifth, if the title matching isn't working but :SELECT: does, I'd guess 
it may have something to do with either unicode or possibly right-to-left 
window titles (I'm presuming...).  Try the workaround noted near the 
bottom of the manpage to see if that works.  If not, it's probably time 
to file a bug with either the wmctrl author or your distro, specifically 
mentioning R2L titles, UTF8, etc, as appropriate.  While I'm at least 
partially UTF8 here, I'm en_US, as close to basic POSIX as it gets other 
than the unicode, so wouldn't expect the trip-ups in that regard that 
someone with I'd guess native RtL Hebrew window titles might have.

 [1] When kde4 broke multi-key hotkeys that worked just fine in kde3, I
 rolled my own solution.  I'm not a C/C++ or even python/perl coder,
 only a bash scriptor, so I coded the script in bash and run it in a
 special konsole window with its own kwin window rules.  It's not fancy,
 but it does a rather impressive job, considering it's all bash and kwin
 rules, picking up where all kde4 left me was broken pieces of a
 solution that USED to work!  A kde single-key hotkey still launches my
 script tho there's independent hotkey solutions out there too, if kde
 decides to break that as well.  My script in turn takes a category and
 then an action selection key, to launch anything I use often enough to
 have programmed a