Back in the day I had an Autohotkey script to do exactly this on Windows. Was very simple with the WinGet, list, WinGetPos and WinSetPos in loops with window title, x,y,w,h, persisted to a .ini file
I wonder how you might do this on Gnome or KDE these days.