Re: Hotkey to move windows to predetermined location and geometry?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On Tue, Mar 13, 2012 at 03:22, Duncan <1i5t5.duncan@xxxxxxx> wrote:
> As Anne says, kwin rules can be used to force a specific position, and I
> use exactly that functionality quite a lot (REALLY quite a lot!) myself,
> but they apply any time a window matches the rule.
> There's at least two further solutions that allow sometimes-matching, one
> via hotkey, but it'll involve a bit of bash scripting or similar, and one
> that effectively lets you decide at launch time.
> 1) The launch-time one works with kde apps and should work with non-kde
> qt apps, but won't necessarily work with all X-based apps and windows.
> It depends on kde's --caption option or qt's --title option (also see qt's
> --name option and kde's --geometry option), as seen in for example
> konsole's  --help-all output when run /in/ konsole.
> The idea is to set a unique window title that can be matched by a kwin
> window rule that ignores the application when run normally, that is,
> without the title setting option.
> I use this here to set special rules for a konsole window when it's
> invoked to run my multi-key hotkey bash scripts.[1]  Just under that rule
> in kwin's window rules list, is another one for konsole in general, so
> the first rule catches the specific case, while the general case falls
> thru to the second rule.
> As I mentioned above, for kde apps specifically, there's also the
> --geometry option, that sets the X geometry.  However, depending on your
> kwin config (smart window placement, etc), you may still need a kwin
> window rule to ignore smart-placement or whatever the general policy is
> and obey the specified geometry, and the non-kde app likely doesn't have
> such an option anyway, so the above idea, setting the title specifically
> and using that as a kwin window rules match, then simply setting window
> size and placement in that window rule, probably makes more sense.
> 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.  After installation, read
> its manpage for instructions on how to invoke it to do what you want
> done.  From there, a hotkey invoked relocate/resize is a simple few lines
> of bash script and a hotkey set in kde settings, common..., shortcuts...,
> custom shortcuts, away. =:^)
> Of course you could also use wmctrl as a launch-time solution, by simply
> using a wrapper script that launches the app, sleeps a few seconds if
> necessary to let the window show up, then runs wmctrl on it to locate and
> size it as desired.
> Meanwhile, this is of course exactly the sort of thing that kde
> activities are eventually supposed to manage, but as the two solutions
> above demonstrate, power users have been doing this sort of thing for
> quite some time already, so all activities will do is put a bit nicer GUI
> on what they've already been doing and expose the same functionality to
> ordinary users, or at least those not quite so high up the power user
> scale as those using existing solutions.  But while I've not actually
> tested activities in 4.8, I doubt they're there yet, and even when they
> get there, it'll likely be a tradeoff between limited functionality
> exposed to a wider userbase, and the more powerful functionality that has
> been available to the power user, for some time to come.
> ---
> [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 sequence for in a total of three individual key presses.
> For example, to open my browser of choice to bank's secure login site is
> launcher, n, b.  Launcher is an "extra" key available on my inet/media
> keyboard, n=net (category), b=bank (individual task in the selected
> category).

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.

I would love to see your scripted hotkeys bash file. I use Krunner
very heavily, and your solution might be even more efficient.

Have a great week!

Dotan Cohen
This message is from the kde mailing list.
Account management:
More info:

[Fedora Desktop]    [Linux Kernel]     [Red Hat Install]    [GIMP for Windows]    [Gnome]    [Red Hat Development]    [Gaim]     [Gnome Discussion]    [Gimp]    [Yosemite Hiking]

Add to Google Powered by Linux