Change command in same function name

Related to @rasat Window Tiling function. To use same action button first to Tile, on second push to DeTile, and third back to Tile. Got it to work with Schedule. Is there a better way?

Experimenting with a FvwmButton that creates one new button. On second push it kills the new button, on third push creates a new one again.

  1. Read $[HOME]/.fvwm/testB.sy
## testB.sy

DestroyFunc NewBtm
AddToFunc NewBtm
+ I Read $[HOME]/.fvwm/testNew.sy

Module FvwmButtons TestBtm
DestroyModuleConfig TestBtm: *
*TestBtm: Geometry 90x50-200+100
*TestBtm: Rows 1
*TestBtm: (90x1, Title "TEST", Fore #ffffff, Action NewBtm )

Style TestBtm !Title, StaysOnTop
  1. New button
# testNew.sy

Module FvwmButtons TestNewBtm
DestroyModuleConfig TestNewBtm: *
*TestNewBtm: Geometry 90x50-300+200
*TestNewBtm: Rows 1
*TestNewBtm: (90x1, Title "NEW", Back #000000, Fore #ffffff  )

Style TestNewBtm !Title, StaysOnTop

Schedule 1000 DestroyFunc NewBtm
Schedule 1000 AddToFunc NewBtm
Schedule 1000 + I KillModule FvwmButtons TestNewBtm
Schedule 1000 + I Read $[HOME]/.fvwm/reset.sy
  1. Reset function NewBtm
# reset.sy

Schedule 1000 DestroyFunc NewBtm
Schedule 1000 AddToFunc NewBtm
Schedule 1000 + I Read $[HOME]/.fvwm/testNew.sy
1 Like

Thank youuuuu, made my day. Couldn’t get a workable 3rd (reset) function. Also, it works on Title bar button’s mouse binding.

## WTile to DeTile
Mouse 1 8 A DeTile
## DeTile to WTile
Schedule 1000 Mouse 1 8 A WTile

You could just use “PipeRead” to enforce blocking fvwm each time the button is pressed. Using “Schedule” is just asking for a race condition to occur.