Running commands on a window that changes its title

I am trying to write some code to make a key combination run Iconify on a certain special xterm window. If the special xterm window does not exist it should be created. I got this working, but there is an extra complication: my xterms change their titles to the current directory. In order for this all to work I had to disable the title changing (which is what “blankshell” does). But I want a solution that works with the changing titles.

I thought maybe WindowId could be used to do this, but I couldn’t figure out how I could start an xterm and determine its id. Or maybe there’s some other solution?

My current code:

Style superLterm Sticky 

DestroyFunc RestartSuperL
AddToFunc RestartSuperL
+ I Exec exec xterm  -T superLterm -e blankshell
+ I Wait superLterm
+ I Next (superLterm) Iconify


DestroyFunc ShowXterm
AddToFunc ShowXterm
+ I None (superLterm) Function RestartSuperL
+ I Next (superLterm) Iconify
+ I Next (superLterm) WarpToWindow 5 5

Key z           A       4       Function ShowXterm

Give this window a State number, and use that – you can get rid of your silly blankshell too:

Style superLterm Sticky, State 6

Then:

DestroyFunc RestartSuperL
AddToFunc RestartSuperL
+ I Exec exec xterm  -T superLterm -e blankshell
+ I Wait superLterm
+ I Next (State 6, XTerm) Iconify


DestroyFunc ShowXterm
AddToFunc ShowXterm
+ I None (XTerm, State 6) Function RestartSuperL
+ I Next (XTerm, State 6) Iconify
+ I Next (XTerm, State 6) WarpToWindow 5 5

Key z           A       4       Function ShowXterm

Easy.

– Thomas Adam

Thanks. That is working great. I close the window on restarts because otherwise it doesn’t get the style when FVWM starts back up. And I’m definitely happy to eliminate the “blankshell” kludge. I ended up with the following.

Style superLterm Sticky, WindowListSkip, !StickyStippledTitle, State 1

DestroyFunc RestartSuperL
AddToFunc RestartSuperL
+ I Exec exec xterm  -T superLterm -geometry 80x60+0+0 -bg lavender -e tcsh
+ I Wait superLterm

DestroyFunc FocusHere
AddToFunc FocusHere
+ I PointerWindow Focus

DestroyFunc ShowXterm
AddToFunc ShowXterm
+ I Next (XTerm, State 1) Iconify
+ I TestRc (NoMatch) Function RestartSuperL
+ I Next (XTerm, State 1, !Iconic) Focus
+ I TestRc (NoMatch) FocusHere

DestroyFunc RestartFunction
AddToFunc RestartFunction
+ I Next (XTerm, State 1) Close