Delay command startup at fvwm startup??

I use urxvtd and urxvtc as clients, and I have urxvtd in my init function of fvwm, but also some urxvtc commands. So many times urxvtc commands are requsted befor urxvtd running and tehy dont start:(
I need to delay them or wait until urxvtd running.

[code]

  • I Exec exec urxvtd
  • I Exec exec urxvtc …[/code]

This is a common question, and one that I have answered a hundred times before. What you need to do is during the startup of FVWM to delay further processing until those windows appear. FVWM (2.4.X and 2.5.X) have the wait command to achieve this. I note that you’ve said you’re using InitFunction. In FVWM 2.4.X this is fine, since FVWM 2.4.X cannot differentiate between startup states, however in FVWM 2.5.X, you should not be using InitFunction, in favour of StartFunction.

So… here’s the 2.4.X version:

AddToFunc InitFunction
+ I Exec exec urxvtd
+ I Wait urxvtd
+ I Next (urxvtd) do_something_here
+ I Exec exec urxvtc
+ I Wait urxvtc
+ I Next (urxvtc) do_something_here

[..presumably more things follow here..]

What that does is it starts up urxvtc. FVWM then immediately blocks (waits) for that window to appear. When it does, the said window (via the Next conditional command) is then acted upon. The same thing happens with urxvtd, too.

Note that the only problem with the Wait command is that FVWM really will wait for the window to show – and if it doesn’t, you can resume processing by pressing CTRL + ALT + ESC.

In FVWM 2.5.X, you should really be using StartFunction for all of your startup/restart/init logic, and using:

AddToFunc StartFunction
+ I Test (init) Exec exec urxvtd
+ I Test (init) Wait urxvtd
+ I Test (init) Next (urxvtd) do_something_here

Of course, you might not want to perform any action on the windows once they’re mapped – but rather just wait for them in which case you can shorten it all down to:

AddToFunc InitFunction
+ I Exec exec urxvtd
+ I Wait urxvtd
+ I Exec exec urxvtc
+ I Wait urxvtc

(Or StartFunction – depending on the version of FVWM you’re using).

That covers the approch that will work for both 2.4.X and 2.5.X. In FVWM 2.5.X, you can also use the Schedule command – this doesn’t do the same thing as Wait (in that it blocks), but it does provide suitable delays. You could do (depending on your needs), something like:

AddToFunc StartFunction
+ i Test (init) Exec exec urxvtd
+ I Test (Init) Schedule 900 some_command

Thus, assuming 900 (which is in milliseconds) was an appropriate time to delay, some_command would then run, under the assumption that the ‘urxvtd’ window was mapped. You could always add an addition check to see if this were true (as with Next in the previous examples).

I hope this has helped you, given that you gave me virtually no information as to what you were wanting to do. Note that with the Wait command, that matches the window name only.

Note again that I have assumed in the examples above that both urxvtd and urxvtc both produce windows when they run. Since I don’t know either application, I am going to go out on a limb and assume that urxvtd is the daemon and urxvtc is the client. If the deamon actually produces a window, then the examples above will work. If, OTOH, it’s just a process which urxvtc connects to, then you can use something like this:

AddToFunc StartFunction
+ I Test (Init) PipeRead `killall -0 urxvtd || exec urxvtd`
+ I Schedule <number> Exec exec urxvtc
+ I Wait urxvtc

Note that the PipeRead runs at the shell level. If the “killall” command can send a signal to urxvtd then it is running, and does nothing. Otherwise, it will execute urxvtd.

HTH,

– Thomas Adam

Thanks a lot:)

This is the solution that I need:

+ I Exec exec urxvtd
+ I Schedule 900 Exec exec urxvtc

tryed + I Wait but urxvtd is a deamon and never stops so it locks my fvwm.

No – it’s as I said in the last reply to this thread – urxvtd doesn’t create any windows – the Wait command causes FVWM to hang indefinitely because it’s expecting a window named ‘urxvtd’ to appear, but of course does not. So you don’t need to use it.

I still think you should consider checking whether urxvtd is running before you try to do so. Please see my last reply on how to do that.

– Thomas Adam