Source i (link to git-repo or to original if based on someone elses unmodified work):

https://github.com/Hegemonia123/restoreToScreen

Original
1
Become a Fan
5.0

Description:
A simple Kwin script, which tries to remember the screen a window was in, and to restore it when the screen is reconnected. Useful when you have to disconnect you external monitors frequently.
Last changelog:

1.6

Fix bug when running in older kwin.


Ratings & Comments

8 Comments

mikebutash

Hasn't been working for me on multiple (4x) displays for some time now, and has gotten worse with 5.27.

hegemonia

Hi! Are you using the latest version 1.4? Since 5.26, KDE has included somewhat similar feature out-of-the-box (https://github.com/Hegemonia123/restoreToScreen/issues/2), which probably conflicts with my script. I made some changes to the latest version to mitigate those issues and the script mostly works on my machine now. I have only one external monitor connected to my laptop, though, and I'm not able to test with multiple.

mikebutash

Hi, I am/was using 1.4, which was working (mostly), but far more broken with 5.27 now. I did see the issues from zamundaaa on your github, so I'd started by filing a bug with the kwin team as whatever functionality they included is far more broken than yours was, but as you said, suspect they were now in direct conflict so I will go back and try 1.5 with this now. Mostly I'm getting odd resizing of windows, random selection of windows to move, and random placements of those windows, at times partially off the screens, so just rather frustrating as my dock tends to glitch and (undock) itself periodically during the day. Hopefully they are willing to work with me to fix it, but so far I can't find where kwin or restoreToScreen is saving these to see why or how these placements/sizings are getting hozed up.

hegemonia

restoreToScreen doesn't touch window sizes. At least not directly. It just sends them to the user-defined screen when a monitor is reconnected. The window position is saved on per screen configuration basis. I.e. a window may be on DP-1 when eDP-1 and DP-1 are connected, but on eDP-1 when eDP-1, DP-1 and DP-2 are connected. That might cause some confusion. Also, the script saves the state into runtime memory, and therefore screen selections are remembered only as long as kwin -session lasts. The workaround is trying to undo the movements kwin does automatically. I guess windows may get resized when they are moved to some smaller screen and then back to the bigger one. The implementation is quite hacky and fragile, though, but I haven't been able to come up with better solution.

mikebutash

Thank you for that insight and explanation! I suspect that part of the issue is when kwin itself moves windows about as part of a display geometry change to reset them to the last-standing display(s), it or yours is re-learning the placements in some preferred capacity, and leaves them there when the full display set adds back. What is odd is certain windows will never move back (virtualbox ui is a weird example of this), other things sometimes move back, most things never move back. Oddly when this happens, some of the screens too will resize horizontally, which as you said *shouldn't* unless moving between smaller displays, but mine are all 4k, even the built-in laptop, so that should not need to be considered even. I would just be happy if it were more consistent placement restoration, maybe adding a cli/ui/dbus trigger to "snapshot" a preferred state for windows? KDE used to have something like this to remember window placements as a button in display behavior settings, but no longer. Thanks again for your help and contributing this script, it's been a sanity saver for years before things changed around it.

mikebutash

Just some feedback on this, since uninstalling the 1.4 version and upgrading to 1.5, my windows placements and geometry have been working almost perfectly. There are a few outliers still, notably virtualbox and gkrellm windows always misbehave when displays change (would love to know why only these), but otherwise quite literally it's been working perfectly. Cheers, and thank you so much for the updates on this remarkable feature - it truly is a sanity saver!

hegemonia

Thanks for the update. Glad to hear it's working mostly ok now.

hegemonia

It seems that the workaround I mentioned only fixed the issue in X11, but not in Wayland. I just pushed 1.5 which should fix Wayland as well.

Pling
0 Affiliates
Details
license GPLv3
version 1.6
updated
added
downloads 24h 1
mediaviews 24h 0
pageviews 24h 2

More Kwin Scripts from hegemonia:

FlexGrid
hegemonia
last update date: 5 months ago

Score 5.7

Other Kwin Scripts:

Snap To Deco
thomas12777
last update date: 11 years ago

Score 5.0

Unminimize windows w/o taskbar entry
thomas12777
last update date: 11 years ago

Score 5.0

MiniStack
faho
last update date: 11 years ago

Score 5.0

Debug Clients
thomas12777
last update date: 11 years ago

Score 5.0

TIL3R
causa-prima
last update date: 11 years ago

Score 5.7

Spam Transients
thomas12777
last update date: 10 years ago

Score 5.0



System Tags