Hola,
I would be interested to add something in my .fvwm2rc like remembering the desk + page when I close the window. Then when launching again the application, the window would be at same page and desktop, like where I left it when closing. I read that I could do that with the event with add_window, but no idea how. Is there some code for that ?
Whao, that was a very fast reply, but actually you did not reply the question. In the provided link, there is only “Remembering the state of maximised windows.”. In my case, it is rather general, just remembering desk + page, what they were. (no maximized windows)
The pre-condition here is that when all of this runs first, you’re going to have to set the style for the window yourself, and let the file controlled by FvwmEvent override it.
DestroyFunc FuncCheckWindowDW
AddToFunc FuncCheckWindowDW
+ I Test (!F $[FVWM_USERDIR]/stylestates) Exec exec touch $[FVWM_USERDIR]/stylestates
+ I PipeRead 'if grep -q \"$[w.name]\" \
$[FVWM_USERDIR]/stylestates; then \
sed -ie "/\"$[w.name]\"/d;" $[FVWM_USERDIR]/stylestates; fi'
+ I PipeRead 'if ! grep -q \"$[w.name]\" \
$[FVWM_USERDIR]/stylestates; then \
echo "Style \"$[w.name]\" StartsOnPage $[w.desk] $[page.nx] $[page.ny], SkipMapping" >> $[FVWM_USERDIR]/stylestates; fi'
+ I Read $./stylestates
So what the above does is everything on when a window closes. You don’t need to check what happens when a window is mapped because it’s already been taken care of. When you close a window, what happens is that the entry for it (based on the window’s name) is deleted and then re-entered into the ‘stylestates’ file.
Once that has happened, the file is then read by FVWM. So to explain this. Assume you closed a window called “buttons”. Here’s what you’d see in this stylestates:
Style "buttons" StartsOnPage 0 1 2
Where the numbers “0 1 2” are for wherever the window is at the time it’s closed. Then the entire file is re-read by FVWM. Such that when a window is next launched matching those lines, FVWM should be moving said window to wherever it was.
Oh, one more thing. This file will need to be read at Init:
AddToFunc StartFunction I Test (Init) Read $./stylestates
Not tested. Change at your leisure. Note that using $[w.name] here is potentially disasterous, and if you can use $[w.class] try to do so – but at some point you’re going to run into problems due to the way FVWM interprets its style lines. In the case we’re using, the function just appends its information. Hence for each style read the last match is always going to win. In the cases of specific matching this might not be what you want at all.