How do I assign a keyboard shortcut to a command which will set the active window’s geometry to an absolute value? e.g. 1024x1408
I’m trying to work around Plasma’s desire to fill all the negative space in the tiling system by just… not using the tiling system.
I just want a 60/40 split where the 40% on the right-hand side has a 32px empty margin at the top so my Dodge Windows dock can stay visible unless I move a floating window near it or resize the right-hand window manually.
Changing the Visibility property of the dock is no bueno, as I also have a top-center and top-left aligned dock that are also set to Dodge Windows - but set one to Always Visible and they all appear because of… design decisions, apparently (https://bugs.kde.org/show_bug.cgi?id=477939)
I can get a Konsole window to reposition itself by using Kwin scripting and something like w=workspace.activeWindow; if(w){w.maximized=0; var g=w.frameGeometry; g.x=1536; g.y=32; g.width=1024; g.height=1408; w.frameGeometry=g
… but assigning that to a keyboard shortcut seems to be impossible on a Wayland session.
I’m sure I’m missing something, and it’s time for another coffee.
Plasma 6.7.5 on CachyOS running a Wayland session, no conflicting default shortcuts enabled.
I’d rather avoid installing 3rd party tiling addons when all I need is one simple feature that seems very achievable.
Window rules are per application/window, and would need to be defined individually ahead of time for every window.
What the OP wants is for it to affect any application currently open and done with a keyboard shortcut as opposed to manually editing an indefinite amount of window rules.
What the OP needs is some kind of script that can apply window rules on the fly based on the currently active window. And it would probably need to use the temporary settings in the kwin rules so that the apps can open at their usual/remembered sizes. Not sure if this already exists.
/.config/kwinrulesrc is the file that such a script would need to edit. It would need to apply the rules for the active window, then delete the rule after a short wait period to ensure the rule is applied using “Force Temporarily”, I think.
Well, you already got told on reddit how to do it using kdotool and that’s really just the easiest and most future proof way.
Just for anyone else wondering:
Either create a global shortcut (System Settings → Keyboard → Shortcuts → + Add New → Command or Script) with this: kdotool getactivewindow windowsize <height> <width>
Or use its dry-run mode to create custom kwin scripts which you can install yourself, after which you could even uninstall kdotool if for some reason you don’t want to keep it around:
Yeah, I created this thread minutes after the Reddit post hoping to get more focused replies than Reddit is known for, I suppose it took a long time to approve.
I tried out kdotool’s --dry-run option, and even just setting the absolute position and size of a window without registering a shortcut produced a surprisingly verbose output, although it looks like I could trim it down. Ideally I’d not rely on third party tools so I guess I’ll be creating and maintaining my own KWin script - I’ll find a way to convince myself I really wanted to learn JavaScript
The only advantage of this I can see is that I can experiment with setting the Quick Tile hints KWin uses to suppress window borders along the snapped edge/two edges of corner-snapped windows.
I know some people have recommended tiling extensions of some kind or another - I’ve used full tiling WMs for years and KDE Plasma meets my needs as it is, I just need a single Quick Tiling-esque feature that’s able to work around the design limitations that currently exist which seem to be a very low priority to address because they affect a small niche of users, but…
I imagine most of the users who would be affected simply move to third party extensions and addons for the system panel and tiling features. With Plasma’s push for native tiling support to be extended it would be nice to see such issues looked at again, if not simply because multi-panel-on-one-edge solutions are easy to create for new users but don’t intuitively work as they might expect.
How I got here:
Limitation in the panel system (multiple panels on one edge, one affects the whole edge)
Try to work around it, meet limitation in the tiling system (no concept of exclusion zone or blank space)
Try to work around it, time to write an extension or use third party code
I’m really trying not to get distracted and write a tiling extension, I just need one basic feature so I don’t have to reduce the height of a window by 32px after I tile it to the right. I’ll be reading kdotool --dry-run output and the KWin API before bedtime, hope I don’t bump in to any dragons. Thanks for recommending kdotool.
It’s meant to be a debug option, not an educational one. So the script it generates is a generic one, and won’t resemble human-written scripts. But still, you can learn what KWin API to use from it.
And you can safely trim all callDbus and output_* from the script. They are for communicating with the kdotool process. No need in a standalone script.