1

I found the "Pack Window" shortcuts available in KDE and they work very well:

Current shortcuts

I would like to add shortcuts to move the window directly into the screen corners. Currently if I wanted to get my window into the bottom left corner I would have to do something like Pack Window Left (Ctrl+Num4) + Pack Window Down (Ctrl+Num2)

I would like to use a single shortcut, eg Pack Window Bottom-Left (Ctrl+Num1) to move my windows in this manner - and critically without changing the window size.

As well I would like to be able to center my window with a shortcut, eg Pack Window Center (Ctrl+Num5), again without changing the window size - though a second shortcut that centered the window and set it to a predefined size would be very nice as well, so that I could have something like Pack Window Center - Large (Ctrl+Shift+Num5) for a 90% maximized window, centered.

I have found a couple of kwin scripts that approach what I want here and here, however I am a beginner regarding programming and this appears to be in JavaScript. I was hoping there was an easy GUI / template based approach to creating custom shortcuts that I had missed before I tried to dig into customizing or creating a script like these ones.

I am currently using Manjaro KDE edition.

  • Re. moving windows to the corners without resizing them, see askubuntu.com/a/1188195/248158. No idea about the other aspects. – DK Bose Nov 14 '19 at 8:49
  • I guess you could look at something wmctrl for placing windows in the center. – DK Bose Nov 14 '19 at 8:51
  • See askubuntu.com/q/104155/248158 – DK Bose Nov 14 '19 at 10:46
  • @JusticeforMonica Your link shows using the KDE "Quick Tile" shortcuts, but unless I am missing something this shortcut does resize the window. – Merritt Nov 14 '19 at 18:18
  • I'm sorry, you're right! But I don't know if what you want is possible. I'll have to amend my answer there. – DK Bose Nov 15 '19 at 4:15
0

Notes:

  • I don't have a numpad and so I'm using different shortcuts than what you use.
  • You need to install xdotool from the repository. It can simulate key presses.
  • This will probably not work in a Wayland session.

In System Settings > Shortcuts > Global Shortcuts > Kwin,

  • I set Super+Ctrl+Down to "Pack Window Down" and
  • Super+Ctrl+Right to "Pack Window Right"

As you observed, these commands cannot be merged into one directly. You need to run them consecutively.

However, there's a workaround using xdotool.

  • Open some window, not konsole just for simplicity, and size and place it somewhere but not in the bottom right corner.
  • Open konsole and paste in the following code: sleep 10s && xdotool key Super+Ctrl+Down && sleep 0.1 && xdotool key Super+Ctrl+Right

  • Press Enter in konsole and then switch to the window you want to move into the right corner without it being resized.

  • After 10s, the window in focus will be moved into the right corner without it being resized.

Assuming that works for you,

  • open System Settings > Shortcuts > Custom Shortcuts
  • Click on Edit > New > Global Shortcut > Command/URL
  • In the left panel, provide a suitable name such as Pack right bottom
  • In the right panel, enter a comment (optional)
  • Next, for Trigger, click on the Input box and press the keys corresponding to the keyboard shortcut you'll use such as Ctrl+Meta+Z or whatever is convenient and available.
  • In the Action tab, paste in xdotool key Super+Ctrl+Down && sleep 0.1 && xdotool key Super+Ctrl+Right.
  • Click Apply in the lower right-corner.

Now, whenever you press Ctrl+Meta+Z, the window in focus will be moved, without being resized, into the lower right corner of your screen.

Having a small sleep between the two xdotool commands is useful because sometimes xdotool can act up.

You'll need to repeat the whole process to pack windows in other corners.


I'm not addressing the other issue of centering windows with 90% of the screen size because that's more challenging.

But again, a sort of workaround is to have all windows appear initially centered. You can then move them wherever you like. To do so, open System Settings > Window Management > Window Behavior > Advanced and choose Centered under Placement.

Another route is to press Alt+F3, choose More Actions and then Special Window Settings or Special Application Settings as required and then set up what you want in the Size & Position tab.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.