KDE KWin Script for remembering application window properties. Especially useful for multi-window applications such as browsers. Remembers and restores the windows position, size, screen and virtual desktop.
-
Compatible with KDE Plasma 6+ (compatibility with previous versions is unknown).
-
Tested on Fedora 42 KDE running Wayland and X11 with Plasma version 6.4.5.
- Features
- How it works
- Installation
- Recommended setup
- Per Application / Window override
- Changing system settings
- Manually erasing settings
- Use case examples
- Troubleshooting
- Compatibility
- Get in touch
The process of saving and restoring a window is extremely simple:
- Arrange the application windows to your liking
- Close the application fully
- Next time the application starts, the windows are restored to best ability
Can operate in one of four modes where it remembers:
- All applications
- All multi-window applications
- All except blacklisted applications (Default)
- Only whitelisted applications (Recommended)
There are lots of other settings that let you control exactly how and when to restore windows to their previous state.
- Add caption change listener restore trigger
- Add keyboard shortcut to block restoring of next application started
- Add override ignores numbers in caption match
- Figure out resizing adjacent tile (set tile?)
-
When the last window of an application is closed, the properties of all windows that were closed within the past second are saved. To save all windows for a browser, simply "Quit" it from the application menu so that all windows are closed at once.
-
Next time the application starts the restoration process begins:
- Window caption and size are compared to the saved windows.
- When the captions of all windows match to at least 85% (since a caption can change slightly such as when it contains a number of messages) - the windows are restored to the previous state.
-
The process above is repeated once a second, for a customizable amount of attempts. If it fails to restore the windows with high caption match level, they are instead restored to the best ability.
- Open
System Settings>Window Management>KWin Scripts. - Click the
Get New...in upper right corner.
- Search for
Remember Window Positionsand click on it (step1applies only with small window size)
- Click
Install
- Enable
Remember Window Positions
- Click
Apply
- Click the configure icon to change the settings to your liking
Please note that changing settings requires some additional steps to apply due to a KDE limitation - see Changing settings below for more information.
You can download the rememberwindowpositions.kwinscript file and install it through System Settings.
- Download the .kwinscript file.
- Open
System Settings>Window Management>KWin Scripts. - Click the
Install from File...in upper right corner.
- Select the downloaded file and click
Open - Enable
Remember Window Positions
- Click
Apply
- Click the configure icon to change the settings to your liking
Please note that changing settings requires some additional steps to apply due to a KDE limitation - see Changing settings below for more information.
Since there are probably tens of thousands of different applications, it is simply impossible to test how all of them behave.
By default, all applications except those that are blacklisted will be remembered. The blacklisted applications are known to use many windows with the same name that are expected to have different sizes. This will obviously cause issues since they would be resized to last known size.
Recommended usage would be to either use a whitelist or a blacklist. It's also possible to simply adjust other settings and get perfect results. The default configuration should not cause many issues, but it all depends on which applications you use - so some tweaking might be required. Enable logs to find application names to add to the blacklist or the whitelist if you go that route.
- Identify problematic applications.
- Check the application names to add in the log (see "Find application names" below).
- Add them to the Blacklist, one per line.
- Check the application names to add in the log (see "Find application names" below).
- Add applications you would like to remember to the list, one per line.
To find application names to add to the Blacklist, Whitelist or Perfect Multi-Window Restore List, enable the "Print Application Name To Log" in the "General" tab of the settings.
Then in a terminal (Konsole) run:
journalctl -f | grep RememberWindowPositions
It is possible to configure individual application and windows by pressing the Ctrl+Meta+W key. (On most keyboards Windows key is the Meta key).
If this keyboard shortcut does not work for you, make sure it is correctly setup in System Settings > Keyboard > Shortcuts > Window Management > Remember Window Positions: Show Config
Due to a bug in KDE, changing user configuration requires reloading the script. (A reboot works too.)
To make setting changes effective, reload the script as follows:
- In
System Settings>Window Management>KWin Scripts, untickRemember Window Positions
- Click
Apply
- Tick
Remember Window Positions
- Click
Apply
If there is ever need to manually erase user data (do not do this unless you are a developer or really need it).
The application/window data is stored in ~/.config/kde.org/kwin.conf under the key rememberwindowpositions_windows.
The system user settings data is stored in ~/.config/kwinrc under [Script-krestorewindowpositions].
- Open your Firefox-based browser and go to Youtube
- Start a video and click the Picture-in-Picture button
- Open Per Application/Window Configuration (Ctrl+Meta+W)
- Click the
Select Application/Windowbutton
- Click on the Picture-in-Picture window
- Make sure the "
Window" is checked, "Close This Window" is selected and click the "Save Override Settings"
- Open
System Settings>Window Management>KWin Scripts>Remember Window Positions Settings
- Change to
Remember"Only whitelisted applications"
- Find your browser name (see
Find application names") and add it to the whitelist (might be pre-added)
- Click "
OK" to save the changes - Untick
Remember Window Positions
- Click
Apply
- Tick
Remember Window Positions
- Click
Apply
- Open a Konsole window
- Open Per Application/Window Configuration (Ctrl+Meta+W)
- Click the
Select Application/Windowbutton
- Click on the Konsole window
- Make sure the "
Application" is checked, "Close Last Window" is selected, "Desktop" is unchecked and click the "Save Override Settings"
- Open
System Settings>Window Management>KWin Scripts>Remember Window Positions Settings
- Change the
Minimum Caption Match Percentageto around 85%. Anything much higher and you will get issues with windows that show number of messages or similar information
- Click "
OK" to save the changes - Untick
Remember Window Positions
- Click
Apply
- Tick
Remember Window Positions
- Click
Apply
In case there are any issues (such as a crash - which should never happen but just in case), this is how to disable the script from command line (open a console with Ctrl+Alt+F5):
kwriteconfig6 --file kwinrc --group Plugins --key rememberwindowpositionsEnabled false
qdbus org.kde.KWin /KWin reconfigure
If the window configuration contains corrupted data, it can be manually deleted in the file: ~/.config/kde.org/kwin.conf under key rememberwindowpositions_windows.
Compatible with:
- Session Restore - some users report success, however this is not officially supported and one user reported crash loop when restoring a saved session (reported by Equivalent-Cut-9253)
Join the official discord channel https://discord.gg/Js6AYsnQQj to discuss, report bugs or find guides.