On an older laptop that I still have Plasma 5.27 with Xorg installed on I use regular floating windows. Sometimes I use it with an external monitor.
I have configured a few custom shortcuts with wmctrl to position the window accordingly. Sadly those keybindings do not work when both screens are activated. Nonetheless I do want to move on to wayland eventually on this older piece of tech, but for now I would like to know if there is a way to just center the window on any given screen, no matter the protocol.
A simple shortcut to just center the active window with all its properties. That cant be too hard? I looked around for kwin scripts but did not found anything.
You need to fiddle with the percentages of course.
You could take it up a notch and minimize all windows, except for the active one which is then placed at the given coordinates. Something like:
#!/bin/bash
active_window_id=$(xdotool getactivewindow)
for window_id in $(xdotool search --onlyvisible “.*”)
do
if [ $window_id != $active_window_id ]
then
xdotool windowminimize $window_id
xdotool getactivewindow windowmove 25% 25%
fi
done
You could assign a shortcut or make a desktop app ( panel for example) that links to that script.
It means when I do configure wmctrl on my monitor, then I cant use those parameters on my laptop screen. They window goes beyond my screen real estate. Essentially I can configure the size of the window just for one screen at a time. Thus they remain static and not dynamic.
Here is an example:
wmctrl -r :ACTIVE: -e 0,24,409,570,763
What I would like is a dynamic centering command for every window that I am currently focussed on. And it should respect my active screen and not place the window in between my monitor and my laptop display. imo this cannot be done with xorg, xdotool is nice and it could work when you consider all eventualities. But this kind of defeats the purpose of working dynamically.
Well, I only have one screen ( can’t test it) but I believe that particular xdotool command only works on the active monitor, the one you’re using. To make sure it does, you could add getmouselocation though.