I found a Python script (I think on Github, but I can't seem to locate
the URL or the original author) that saves or restores the desktop
location of each open Firefox window*. It does this by calling
wmctrl(1) and storing/loading the location as a JSON data structure.
The data structure is indexed by the window title, but Firefox changes
the title based on the currently active tab in each window. Thus the
saved data will depend on which tab happens to be active in each
window.
The script already works when called manually but I just want to
automate the process when I log in or out of KDE.
The Save script has to run *after* Plasma starts and all my windows are
already created. According to the KDE manual, this seems to rule out
Autostart.
The Restore script should run just before killing any running windows.
It should also work even if I reboot directly from the KDE Leave tab
without logging out.
Is this possible?
poc
* It would be trivial to modify the script for other apps.