Sticky Window Snapping Original

Kwin Scripts

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

16
Score 86.6%
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 1 year 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

jospoortvliet

1 year 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

C

Flupp

10 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

fezu54

1 year ago

Awesome! That one works. Many thanks :-)

Report

Warmuser

1 year ago

Keep alive these project, please. It rocks!

Report

aSystemOverload

1 year ago

Just what the Doctor ordered!

Report

KIMW

2 years ago

Excellent. Thank you!

Report

Zren

2 years 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

1 year ago

Please, add some examples on the git page.

Report

Zren

1 year ago

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

Report

Warmuser

1 year 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_double

4 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_double

4 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

C

Flupp

3 years ago

This problem was caused by a bug in KWin, which is now fixed. (cf. https://github.com/Flupp/sticky-window-snapping/issues/1)

Report

mcaceres

4 years ago

Just discovered this. Extremely useful. I've been looking for a way of doing this ever since quick pack/tile became part of my workflow. The behavior is as expected and my window resizing is measurably better (:

I have a suggestion: I'd like a way of deciding whether to "unstick" a particular window on the fly. For instance, alt + right-click resizes with all snapped windows sticking (even if only part of the edge is snapped, which I really like). But it'd be useful if, say, alt + meta + right-click resized the window without sticking.

Thanks!

Report

jhnnslschnr

5 years ago

I find this script pretty useful, but i would like an option for deciding whether windows should be sticky on borders that are not between the windows.
However this behaviour causes a small bug regarding the maximization state: in case i have two quick tiled windows and shrink one from the bottom, the other one follows, but is still marked as vertically maximized, so i have to middle click the maximize button twice to remaximize it vertically.

Report

csslayer

5 years ago

I found this script seems also resize window that are overlapped, for example

--------
| | |
| |----
| |
-------

Resize the upper edge will resize both window, I can't think of a useful case for this.

Report

jospoortvliet_double

6 years ago

This is really awesome. I have a small behavioral suggestion which could make it a bit more intuitive, esp when you do NOT want a window to follow resizing: only resize both windows in the area where they touch each other. Say that one window is full-height of the screen and the other half-height, then resizing the full-height one in the area where the other is not, should leave the other alone, un-snapping them.

This is what I intuitively expected when I tried to 'unsnap' the windows. It is easier than having to move one of the windows to unsnap.

Not sure how hard this is, though, and in any case - great script :D

Report

C

Flupp

6 years ago

Unfortunately, as far as I know, it is not possible to get the mouse position with a KWin script. But I also think the behavior would be rather unintuitive if there are two small windows snapped to the same edge of a large window.

Report

Crespyl

6 years ago

Ever since I found out about the removal of tiling features in 4.10 I've been looking for a good work-around, and I'm really liking this so far.
Really elegant idea.

The one suggestions/request I have is that I would like to see support for the kwin "Resize Window" effect during resize, which displays the resizing window using a faster/more responsive scale effect until the resize ends. I've no idea how hard that might be though...

Report

Crespyl

6 years ago

Actually, I should clarify about the resize effect; The focused window is scaled appropriately, but the snapped window being resized by the script has to keep recalculating its layout.

Report

Henri

6 years ago

I've installed and enabled the script. When I snap two windows side by side and resize one window it doesn't resize the another one. Using Kde 4.10.2.

Report

C

Flupp

6 years ago

Have you forgotten to press the “Apply” button in systemsettings? (Maybe this seems like a stupid question, but I occasionally forget it myself.)

Have you tried restarting kwin after applying the changes (Alt+F2: kwin --replace)? I have to do this sometimes – this may be a bug in kwin, but I am not sure.

Alternatively you can try to log out and log in again.

Report

Henri

6 years ago

I've rebooted my system and it's working now as it should. Thanks. I love the script! Something that should be default in KDE imho.

Report

v1.0 1 year 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 1 year ago

  • fixed resizing for windows spanning multiple screens

v0.2 1 year 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 1 year ago

  • initial release

12345678910
274
product-maker alex1701c Jul 06 2019 10 the best
10 the best
product-maker kaetir Jun 09 2019 10 the best
must have
product-maker pyro226 May 26 2019 10 the best
KDE should ship with this
product-maker eptin May 19 2019 10 the best
10 the best
product-maker roachsinai Apr 02 2019 9 excellent
+
product-maker duncanyoyo1 Feb 27 2019 9 excellent
+
product-maker jontheburger Feb 17 2019 9 excellent
+
product-maker molecule-eye Feb 08 2019 9 excellent
+ This is awesome and should be incorporated into kwin and maintained upstream!
product-maker m0ji Feb 06 2019 9 excellent
+
product-maker chickenff Dec 11 2018 9 excellent
fantastic
product-maker moonchild19 Nov 21 2018 9 excellent
+Very useful!!
product-maker brazzmonkey Nov 08 2018 9 excellent
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 9 excellent
+
product-maker L0sted Jun 29 2018 9 excellent
+
product-maker sh4nks Jan 04 2018 9 excellent
product-maker KIMW Jun 16 2017 9 excellent
product-maker Zren May 01 2017 9 excellent
product-maker chips Sep 04 2016 9 excellent
product-maker qtnerd Aug 14 2016 9 excellent
product-maker lboklin Jan 03 2016 9 excellent
product-maker mirkogennari Oct 07 2015 9 excellent
product-maker mcaceres Oct 03 2014 9 excellent
product-maker jospoortvliet_double Sep 23 2014 9 excellent
product-maker SeaJey Oct 31 2013 9 excellent
product-maker jaitrum Oct 31 2013 9 excellent
product-maker deabru Oct 30 2013 9 excellent
product-maker saabzero Jun 27 2013 9 excellent
product-maker Henri Apr 15 2013 9 excellent
product-maker Contrast Mar 09 2013 9 excellent
product-maker Hmpf Mar 09 2013 9 excellent
product-maker herrbatka Mar 09 2013 9 excellent
product-maker Count: 4 Rating: 5.0
File (click to download) Version Description Downloads Date Filesize DL OCS-Install
Pling
*Needs ocs-url or ocs-store to install things
Details
license
GPLv2 only
version
1.0
updated May 27 2018
added Mar 09 2013
downloads today
37
page views today 42
System Tags linux unix gplv2