Sticky Window Snapping

Kwin Scripts

Source (link to git-repo or to original if based on someone elses unmodified work): https://github.com/Flupp/sticky-window-snapping

13
Score 74%
Description:

KWin script to let snapped window edges stick together when one window is resized.

The script provides an easy to use configuration dialog, which can be reached via “systemsettings”. (However, note section “Bugs and Workarounds”.)

Additionally, the script registers two global shortcuts: one for enabling/disabling the script permanently, and one for enabling/disabling the script only for the next resize. The default shortcut keys are Meta+Shift+S and Ctrl+Shift+S, respectively. You can change them using “systemsettings” (or “kcmshell4 keys”); they are associated with the component “KWin”. Their names are prefixed by “KWin Script: Sticky Window Snapping”.


## Bugs and Workarounds

• If the configuration dialog is not reachable via “systemsettings”, then try the following command and restart “systemsettings”:

ln --relative --symbolic ~/.local/share/kwin/scripts/sticky-window-snapping/metadata.desktop ~/.local/share/kservices5/kwin-script-sticky-window-snapping.desktop

• If the script does not work, increasing the threshold in the configuration dialog might help.


## Known issues

• There is no optical feedback when a shortcut is pressed. I do not know how to initiate a KNotify notification from a KWin script. There is the function “callDBus”, but I do not know if or how it can be used for that purpose. KNotify provides the method “event” via D-Bus, but it expects arguments of types for which I do not know how to produce values with JavaScript.

• Currently, not only snapped window edges are considered as connected, but even edges which are only on the same row/column are considered as connected. I have not decided, if this is a bug or a feature, yet.
Last changelog:

v1.0 6 months ago

• new:
  • configuration dialog
  • configurable transparency of unaffected windows
  • configurable threshold defining a maximal distance to consider edges as snapped
  • option to ignore maximized windows
  • option to ignore window edges that touch an edge of the screen
  • restore affected minimized windows temporarily
• changed:
  • highlight a snapped window only when its size is changed
  • also consider windows that are on all desktops
  • delay transparency changes until first resize step to prevent flickering
  • do not restrict a window to the client area (typically the screen size) if it already exceeds it
• fixed:
  • crash on resize when a snapped window disappears

chickenff

3 days ago

fantastic

Report

leggettc18

20 days ago

Maybe I'm just missing something, but it seems like there's no area between the windows where I can click and drag to resize. It works if I alt + right-click and move the mouse to resize, the snapped windows also resize appropriately, but I can't manage to click in between them...

Report

C

Flupp

18 days ago

I am not sure if I understand you correctly. The script does not add any click regions for resizing. The script just monitors the default resizing mechanism(s). Also, if two windows are snapped, then there should not be any room between the windows (at least when using the Breeze window decoration).
Maybe you disabled windows snapping (System Settings/Workspace/Window Management/Window Behavior/Moving)? Without window snapping it is rather hard to position windows in a way that resizing triggers the script. If you do not want to enable window snapping, maybe playing around with the threshold setting of the script does help.

Report

moonchild19

22 days ago

+Very useful!!

Report

brazzmonkey

1 month ago

Rendering seems to lag a little, but the extra functionality is awesome. This should be offered in KWin by default.

Report

Nano-Ocelot

1 month ago

I'm not seeing the configuration dialogue. On Plasma 5.14.2

Report

C

Flupp

1 month ago

Have you tried the workaround given in the description?

• If the configuration dialog is not reachable via “systemsettings”, then try the following command and restart “systemsettings”:

ln --relative --symbolic ~/.local/share/kwin/scripts/sticky-window-snapping/metadata.desktop ~/.local/share/kservices5/kwin-script-sticky-window-snapping.desktop

Report

kuriot

2 months ago

+

Report

L0sted

5 months ago

+

Report

fezu54

7 months ago

Does others also recognized that this awesome script is not working anymore since a few months? Or is it just a local problem on my side?

Report

jospoortvliet

6 months ago

Same here- not working anymore :( :(

Report

jospoortvliet

6 months ago

This one worked for me: https://github.com/Zren/kwin-script-sticky-window-snapping/

download the zip, rename to .kwinscript install and boom. Magic :D

Report

fezu54

6 months ago

Awesome! That one works. Many thanks :-)

Report

C

Flupp

3 months ago

It would be great if you could try the current version (v1.0) of the script and give me some feedback if your problems are fixed.
Probably, the threshold, which Zren introduced, fixed the problem. In v1.0 the threshold is configurable and initially zero, so you might have to adapt it. Note the workarounds mentioned in the description if the configuration dialog is not available.

Report

Warmuser

7 months ago

Keep alive these project, please. It rocks!

Report

aSystemOverload

11 months ago

Just what the Doctor ordered!

Report

KIMW

1 year ago

Excellent. Thank you!

Report

Zren

1 year ago

I modified your script slightly for personal use. I made it not sticky windows unless they split the entire screen, and not stick when the windows originally touch the edge of the screen.

https://github.com/Zren/kwin-script-sticky-window-snapping/commit/fb71809b065969b8c67077bcfa2af790a954a571

Report

Warmuser

7 months ago

Please, add some examples on the git page.

Report

Zren

7 months ago

Here's a video that demonstrates the differences.
https://streamable.com/bpavy

Report

Warmuser

7 months ago

Thanks! :)

Report

jakubleska

2 years ago

Hi, I don't know how to make knotify from KWin script but this is working in nodejs(maybe there is some better way how to do it, I just rewrite it from python)

var dbus = require('dbus-native');
var sessionBus = dbus.sessionBus();
sessionBus.getService('org.kde.knotify').getObject('/Notify', (err, obj)=>{

var knotify = obj.proxy['org.kde.KNotify'];
knotify.event("warning", "kde", [], "title", "text", [], ["action"], 0, 0);
});

I hope this can help you.

Report

andyandybobandy

2 years ago

Thank you, this is excellent!

Report

jospoortvliet_deactivated

3 years ago

I would absolutely love an update that makes this work on kwin in Plasma 5 as it doesn't seem to work here. And this is just such an amazing script I think it should be there by default....

Report

jospoortvliet_deactivated

3 years ago

hmmm, so it isn't that it doesn't work, but the situation where I used it most (moving the 'divide' between quick tiled windows) is broken. So - quick tile a window do the left, quick tile another to the right, move the divide between them to give one more space than the other. I do this a lot (web development stuff...) and in kwin4 it works. With kwin5 it doesn't, the windows lose their 'quick tile' size, so they pop back to a smaller size or whatever they were before.

Report

v1.0 6 months ago

• new:
  • configuration dialog
  • configurable transparency of unaffected windows
  • configurable threshold defining a maximal distance to consider edges as snapped
  • option to ignore maximized windows
  • option to ignore window edges that touch an edge of the screen
  • restore affected minimized windows temporarily
• changed:
  • highlight a snapped window only when its size is changed
  • also consider windows that are on all desktops
  • delay transparency changes until first resize step to prevent flickering
  • do not restrict a window to the client area (typically the screen size) if it already exceeds it
• fixed:
  • crash on resize when a snapped window disappears

v0.2.1 6 months ago

• fixed resizing for windows spanning multiple screens

v0.2 6 months ago

• maximized windows are ignored now
• shaded windows are ignored now
• windows on other screens are ignored now
• changed behavior when windows get very small while resizing

v0.1 6 months ago

• initial release

product-maker chickenff Dec 11 2018

fantastic

product-maker moonchild19 Nov 21 2018

+Very useful!!

product-maker brazzmonkey Nov 08 2018

Rendering seems to lag a little, but the extra functionality is awesome. This should be offered in KWin by default.

product-maker kuriot Oct 07 2018

+

product-maker L0sted Jun 29 2018

+

product-maker nchyfw May 27 2018

+thank you

product-maker sh4nks Jan 04 2018

product-maker KIMW Jun 16 2017

product-maker Zren May 01 2017

product-maker chips Sep 04 2016

product-maker qtnerd Aug 14 2016

product-maker lboklin Jan 03 2016

product-maker mirkogennari Oct 07 2015

product-maker mcaceres Oct 03 2014

product-maker SeaJey Oct 31 2013

product-maker jaitrum Oct 31 2013

product-maker deabru Oct 30 2013

product-maker saabzero Jun 27 2013

product-maker Henri Apr 15 2013

product-maker Contrast Mar 09 2013

product-maker Hmpf Mar 09 2013

product-maker herrbatka Mar 09 2013

product-maker 6 6

File (click to download) Version Description Packagetype Architecture Downloads Date Filesize DL OCS-Install
Pling
Details
license
GPLv2 only
version
1.0
updated May 27 2018
added Mar 09 2013
downloads today
0
page views today 27
System Tags linux unix gplv2