PaperWM
PaperWM copied to clipboard
Always Center
The more I use PaperWM, the more I play around with certain applications behind slightly different widths.
It would be really beneficial if there was an option to always center on the active window
#150 might be close enough to this
CC @olejorgenb
You can get something like this by turning up the horizontal margin (eg. to 1/2 the screen). It won't center the first and last window though, and the preference gui still has a bug which limits you to max 100px so you'll have to use eg. dconf-editor to set it higher.
Auto centering would absolutely be nice, especially on wide screens.
I guess there's a few options here:
- add a «mode» that can be toggled
- let windows inherit centering, ie. if the previous window was centered, center the new one. That might be workable as a default.
For a quick local fix this should work in user.js (and similarly for Space.switchLeft/Right
):
let orgSwitch = Tiling.Space.prototype.switchLinear;
Tiling.Space.prototype.switchLinear = function (dir) {
orgSwitch.call(this, dir);
Tiling.centerWindowHorizontally(this.selectedWindow);
}
@hedning
how to properly paste the code in user.js ? inside enable function or outside ?
The fix hedning suggested should go in the init
function. (otherwise a new override layer would be added each time the screen was unlocked)
can you descript it on details? it dooesn't work for me @olejorgenb
The init function in ".config/paperwm/user.js" should look like this: (you need to restart gnome shell after making the change)
function init() {
// Runs _only_ once on startup
// Initialize extension imports here to make gnome-shell-reload work
Extension = imports.misc.extensionUtils.getCurrentExtension();
Me = Extension.imports.user;
Tiling = Extension.imports.tiling;
Utils = Extension.imports.utils;
Keybindings = Extension.imports.keybindings;
Examples = Extension.imports.examples;
App = Extension.imports.app;
let orgSwitch = Tiling.Space.prototype.switchLinear;
Tiling.Space.prototype.switchLinear = function (dir) {
orgSwitch.call(this, dir);
Tiling.centerWindowHorizontally(this.selectedWindow);
}
}
Note: didn't actually test it myself though :)
Note: it will only work for the linear keybindings (<Super>,
/<Super>.
) You need to add similar wrappers for the left/right actions.
#482 does this. Well, it adds a persistent sticky centering mode (can set it at a workspace level). Just collecting feedback for this atm - after that (if no showstoppers) I'll merge it in.