FvwmRearrange -auto_tile

When you build the development version from the main branch, you should build the manual pages (either as a man page or as a .html file) and read those. Otherwise you’ll have to wait for the next release and for someone to update the manual pages. Not every option that gets added is going to have a wiki page, at some level due to the large number of options in fvwm and its modules, the manual page that you build along side the binaries are going to always be the best source of info.

-win_cmd COMMAND
Runs the fvwm COMMAND in the context of every window that is rearranged. This can be used to set the state of all affected windows with the COMMAND “State n” so they can be matched using the “State n” conditional.

This describes the -win_cmd option but doesn’t tell how to do. What command to add to detile all tiled windows.

This command string detiles all and maximizes all windows (full screen).
FvwmRearrange -win_cmd Maximize Off
I want the original state.

You are going to have to write your own functions for that. This command does exactly what it says, it runs a command on all windows that FvwmRearrange moves. The intent was to allow you to add a state to those windows so you can easily identify them, -win_cmd "State n", as stated in the manual page.

You will probably have to clear the state you use from all other windows, and write conditionals to deal with the windows that match that state to detile.

Indeed – as @somiaj states – using the new -win_cmd is a one-way street – it cannot be anything else. As I previously mentioned though, using -maximize is a hack to infer the previous state of windows.

Either way, as FvwmRearrange has no knowledge of previous runs, using -maximize is only there to help with this; but if you’re going to use -win_cmd it is up to you to manage the state, which can only happen through the use of functions, etc.

At this point, I fee as though we’ve taken FvwmRearrange to its logical conclusion without needn’t to do anything else directly, which the user couldn’t otherwise already do.

Enjoy!

Note, we haven’t been giving the exact commands as at some level you need to set this up to fit your configuration. -win_cmd was added to give users some freedom to run anything they want on the windows FvwmRearrange moves. But this is run after the move, so can be use to tag (or maybe change the color of) the windows that were arranged.

The inspiration for this was @thomasadam suggestion of using State n to identify the windows that were tiled, along with using the -maximize hack, so fvwm can return windows back to their non maximized size.

You basically need two functions, one to clear the state from all other windows so only the last ones arranged by FvwmRearrange are tagged, and another to restore windows to their unmaximized size.

AddToFunc Tile
+ I All State 1 False
+ I FvwmRearrange -maximize -win_cmd "State 1"

AddToFunc DeTile
+ I All (State 1) Maximize

Thanks, @thomasadam and @somiaj. The Tile and DeTile functions work nicely, simplifying the overall process with -auto_tile

FvwmRearrange -auto_tile -gap 6 -maximize -win_cmd "State 1"

Note -auto_tile is the default (so not needed), which is why I didn’t include it in my example.