PaperWM icon indicating copy to clipboard operation
PaperWM copied to clipboard

Enhanced shortcuts for PaperWM

Open EGmux opened this issue 4 years ago • 10 comments

Problem

While using PaperWM some actions require a lot of key presses.

Proposed solution

The following keybinds could be used to save time

  • Horizontal splitting
    right to the active border: Super+u left to the active border: Super+Shift+u

  • Vertical splitting left of the active border: Super+Shift+i

  • Maximized window by default this could be inside the PaperWM Gnome extensions section.

Use cases

For splitting

  • App opening spawns random sizes.
  • Quick tile an application to the left or right in a horizontal/verticall manner

For Maximized by default

  • Time is saved by not pressing Super+f for every app instance launched

EGmux avatar May 12 '20 19:05 EGmux

Horizontal splitting: Ie. move a window out of a column into a new column (or simply move it if it's already a single column)? I can try to find some time to implement a example action.

Vertical splitting: Extension.imports.examples.keybindings.tileInto(); binds keys (super-</> (configurable by passing in two keystrings) to tile the selected window into the left/right column. (ref.: user config)

Maximized by default: I think this could be part of more comprehensive "winprop" support. (ref.: #304)

olejorgenb avatar May 15 '20 14:05 olejorgenb

Thank you for the pointers,

Horizontal splitting is basically default i3 behavior,however would be triggered by a shortcut .

The main ideia is the actual window get squashed or expanded to fit the 0.5 screen ratio and the shortcut will determine which window,the one to the left or right of it,is going to get the same treatment.

  • right to the active border: Super+u

  • left to the active border: Super+Shift+u

If possible would also be interesting to add an undo horizontal splitting shortcut as well,both windows would return to the previous ratio,similar to the o key behavior.If not in the Gnome settings,maybe as user config?

EGmux avatar May 15 '20 15:05 EGmux

This is my branch where I test out layout actions: https://github.com/paperwm/PaperWM/tree/virtual-tiling-playground

I think the cycle-layout-direction roughly correspond to the suggested super+u bindings. The tile-into is close to Super+Shift+i have but have slots for left and right and will untile (ie. move to a separate column) a window in the given direction if it's already vertically tiled.

I recommend adding <Super><Alt>Up/Down to move the window up down in a column for better erogonomics.

fit-available will expand/shrink the given window to occupy "available" space. (ie. space not occupied by fully visible windows)

user.js@init:

    Extension.imports.examples.layouts.bindCycleLayoutDirection("<Super><Shift>u", "<Super>u")
    Extension.imports.examples.layouts.bindFitAvailable("<Super>j", "<Super>k", "<Super>l")  // left, focus, right
    Extension.imports.examples.layouts.bindTileInto("<Super><Alt>Left", "<Super><Alt>Right")

olejorgenb avatar May 30 '20 10:05 olejorgenb

Hi!

Do you have any plan to merge that branch into master? For my workflow, these features would be a usability improvement.

I'm playing with it right now. I tried to simply copy the scripts to my user.js using the current master branch, but the only feature currently working seems to be tileInto. I'm actually very interested in cycleLayoutDirection and fitAvailable. Unfortunately, I have no knowledge about the API and don't know why the aforementioned actions don't work, since they fail silently.

Thanks!

gustavo-hms avatar Aug 23 '20 14:08 gustavo-hms

@gustavo-hms, you'll have to check out the virtual-tiling-playground branch for it to work (git checkout virtual-tiling-playground). You'll then have to restart gnome-shell (Alt-F2 restart on X11 and logout/login on Wayland).

We'll hopefully get the time soon to merge in some of the stuff we've been using locally for a while.

hedning avatar Aug 23 '20 15:08 hedning

Thanks for the fast response!

The problem with running the code from that branch is that I get an error:

-En PaperWM
Error occured in user @init:

keymap is null

devirtualizeMask@/home/gustavo/.local/share/gnome-shell/extensions/paperwm@hedning:matrix.org/keybindings.js:396:30
rawMaskOfKeystr@/home/gustavo/.local/share/gnome-shell/extensions/paperwm@hedning:matrix.org/keybindings.js:405:12
openNavigatorHandler@/home/gustavo/.local/share/gnome-shell/extensions/paperwm@hedning:matrix.org/keybindings.js:409:18
enableAction@/home/gustavo/.local/share/gnome-shell/extensions/paperwm@hedning:matrix.org/keybindings.js:515:33
bindkey@/home/gustavo/.local/share/gnome-shell/extensions/paperwm@hedning:matrix.org/keybindings.js:351:9
bindCycleLayoutDirection@/home/gustavo/.local/share/gnome-shell/extensions/paperwm@hedning:matrix.org/examples/layouts.js:259:17
init@/home/gustavo/.config/paperwm/user.js:25:22
safeCall@/home/gustavo/.local/share/gnome-shell/extensions/paperwm@hedning:matrix.org/extension.js:59:52
run@/home/gustavo/.local/share/gnome-shell/extensions/paperwm@hedning:matrix.org/extension.js:49:9
init@/home/gustavo/.local/share/gnome-shell/extensions/paperwm@hedning:matrix.org/extension.js:98:9
_callExtensionInit@resource:///org/gnome/shell/ui/extensionSystem.js:433:50
loadExtension@resource:///org/gnome/shell/ui/extensionSystem.js:346:27
_loadExtensions/<@resource:///org/gnome/shell/ui/extensionSystem.js:599:18
collectFromDatadirs@resource:///org/gnome/shell/misc/fileUtils.js:27:17
_loadExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:574:19
_enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:608:18
_sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:639:18
init@resource:///org/gnome/shell/ui/extensionSystem.js:56:14
_initializeUI@resource:///org/gnome/shell/ui/main.js:257:22
start@resource:///org/gnome/shell/ui/main.js:146:5
@<main>:1:47

It seems the call const keymap = Gdk.Keymap.get_default(); from keybindings.js returns null. At least that doesn't happen on master.

gustavo-hms avatar Aug 24 '20 11:08 gustavo-hms

It seems the call const keymap = Gdk.Keymap.get_default(); from keybindings.js returns null. At least that doesn't happen on master.

OK. I must have done something wrong. I tried again and this time it worked.

Thanks!

gustavo-hms avatar Aug 26 '20 00:08 gustavo-hms

Please forgive me for necro-bumping this thread...

I have an idea of some additional functionality that would improve my workflow with paperwm, and I'm wondering if "tile-into" is the same thing. What I would like to see is a binding that would move the focused window either right or left. If the window is in a stack, it would move it into a full-height new column, and if the window is full-height, then move it into a stack with the adjacent window(s).

Is that what "tile-into" is?

If so, has it progressed at all since August?

I've tried adding

Extension.imports.examples.layouts.bindTileInto("<Super><Alt>Left", "<Super><Alt>Right")

into my user.js and restarting gnome-shell, but I didn't see any effect. Perhaps I'm adding it in the wrong place?

mrspikeroot avatar Dec 19 '20 19:12 mrspikeroot

No problem (personally have nothing against necro-bumping and find it annoying when threads are locked just because they're old..) :)

It should work if you add it to the init function in user.js (but remember: those actions are only available in the virtual-tiling-playground branch). Perhaps the keys are already bound? (we do try to give a notification when that's the case though)

A mentioned earlier in the thread - master has a similar tile action example (Extension.imports.examples.keybindings.tileInto()) (but that action never untiles the window)

We've been quite busy with work this fall, so no progress, but hope to carve out some time to work on paperwm during the holiday.

olejorgenb avatar Dec 20 '20 01:12 olejorgenb

Just want to add a vote for merging the actions from https://github.com/paperwm/PaperWM/issues/303#issuecomment-636313932 -- I have been using this branch for the past few weeks and I find these very useful, especially cycle-layout-direction. Thanks for your work on Paperwm.

Btw @olejorgenb do you have a Sponsors or Patreon or other way that I can contribute in a small way to support your work?

indigoviolet avatar Mar 24 '21 19:03 indigoviolet