Skip to content

jinliu/waycosh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Waycosh: A stupid hack to remember window positions in KDE Plasma Wayland

This is a stupid hack to remember window positions in KDE Plasma Wayland. It's not intended to be a proper solution, but rather a simple and stupid implementation that might or might not work for you. It's no substitute for a proper implementation in KWin.

Installation

  1. Install uv with your package manager, or from GitHub.
  2. Clone this repository with git clone https://github.com/jinliu/waycosh.git.

Usage

  1. cd waycosh; ./run.sh
  2. The first time might take a while, because it needs to download dependencies first.
  3. Now your window positions should be (kind of) remembered when the program is running.
  4. Press Ctrl-C to exit the program.
  5. Your window positions will be saved automatically, and also before the program exits.

How it works

This program groups windows by paths of their executables. E.g., all Dolphin windows are grouped together by "/usr/bin/dolphin". When the last window of a group (e.g. the last Dolphin window) is closed, its position is saved in "~/.local/share/waycosh/state.json". Then, when a new window opens, and there is no other window in the same group (e.g. there are no open Dolphin windows), the remembered position is restored.

I.e., it only remembers the last closed window from an executable and only restores the position for the next new window from the same executable. All other new windows are placed by KWin.

Limitations

This obviously won't work for Google Chrome web apps, because they are all grouped with the main Chrome executable.

It won't work for multi-window apps either, because it only remembers one window.

It probably will put your windows outside the screen if you change the scaling factor or the screen configuration. You can delete "~/.local/share/waycosh/state.json" to reset the positions if that happens.

Probably a lot more. It's a stupid hack, remember?

Notes

  1. Please report bugs to my repo, not to KDE. This is not a proper solution, and it's not KDE's fault if it doesn't work for you. Remember to close this program and re-test without it before reporting a bug to KDE.
  2. Don't expect this to work perfectly. But I do plan to improve it while keeping it simple and stupid. So I'd appreciate your feedback and suggestions.
  3. Also you are encouraged to tinker with the code. You might want to start with event_handler.py and window_registry.py.

How it works, really?

This program uploads a script (see kwin_script.py) to KWin, which reports back to the main program via DBus, on KWin's windowAdded and windowRemoved signal. The main program then determines if the window position should be remembered (on windowRemoved), or the window should be moved to the remembered position (on windowAdded). For the latter case, the main program sends back a DBus message to the KWin script to move the window.

This essentially makes it possible to do KWin scripting outside KWin. Benefits:

  1. You can't do disk IO in KWin scripts, making it impossible to save window positions. You can do that and all other things in an external program.
  2. You don't have to use js.
  3. KWin scripts run in KWin's main thread, so they can't do heavy work, otherwise it will slow down KWin. But since KWin scripts call DBus asynchronously, you can take as much time as you like in the external program before sending a reply back to KWin.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published