Subject: Re: FVWM: Argument Passing?

From: [email-masked]
Date: Fri, 14 Jan 2000 20:58:22 GMT

> From [email-masked]  Fri Jan 14 20:38:13 2000

> >         AddToFunc SwitchDecor
> >         + "I" Exec echo $0 > HOME/USER_WM_STYLE
> >         + "I" Restart HOME/bin/RunWM
> > 
> > I believe the Exec is guaranteed to finish before the Restart begins (can
> > anyone confirm this?).
>
> >From the man page:
>
>           Note that this function doesn't  wait  for  command  to
>           complete, so things like:
>
>                Exec "echo AddToMenu ... > /tmp/file"
>                Read /tmp/file
>
>           won't work reliably.

True, but I've found that a Restart *appears* to wait for current Exec's to
finish. Thinking more about it, perhaps I was just being lucky!! Is a Restart
treated differently in this respect to any other fvwm2 command?

In other places where I want to wait for an Exec to complete before moving on,
I use PipeRead instead: so, one could try:

         AddToFunc SwitchDecor
         + "I" PipeRead "echo $0 > HOME/USER_WM_STYLE"
         + "I" Restart HOME/bin/RunWM

Or even:

         AddToFunc SwitchDecor
         + "I" PipeRead "echo $0 > HOME/USER_WM_STYLE; echo Restart HOME/bin/RunWM"

(which now suggests one doesn't even need the function SwitchDecor, although
perhaps it's nicer than having the PipeRead repeated for each menu item).

John Latham
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dan Espen <[email-masked]>
Date: Fri, 14 Jan 2000 16:14:05 -0500

> treated differently in this respect to any other fvwm2 command?

Once you do an Exec, the actual execution is controlled by the OS.

I'm not  surprised that this  "mostly"  works.  A  typical echo  would
normally  complete long before fvwm  got around  to reading its config
files.

> In other places where I want to wait for an Exec to complete before moving on

Both of these look like winners to me.

--
Dan Espen
444 Hoes Lane  Room RRC 1C-214           E-mail: [email-masked]
Piscataway, NJ 08854                     Phone: (732) 699-5570
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: "Thomas A. Gardiner" <[email-masked]>
Date: Fri, 14 Jan 2000 19:16:56 -0500 (EST)

Hi,

Sorry for not responding to this earlier.  John, I'm especially sorry for
not trying your suggestion yet.  So, I get varied results...

The first suggestion.

AddToFunc SwitchDecor

I tried the first suggestion below, and it works for me, but I too was
afraid that it would be unreliable from the excerpt of the fvwm2 man page
which Dan mentioned.

	won't work reliably.

>>          + "I" Restart HOME/bin/RunWM

This suggestion works just fine for me.  There is one interesting
difference from the first suggestion above.  I pipe stdout and stderr to
~/.FVWM2-errors with

fvwm2 -cmd 'FvwmM4 fvwm2rc.m4' > ~/.FVWM2-errors 2>&1

The first suggestion causes the output of subsequent restarts to be
appended to the file.  The second suggestion causes the file to be
overwritten.  There is definitely something going on here, but I'll be
damned if I know what...

The third suggestion gives me an error for some unknown reason.

>>          + "I" PipeRead "echo $0 > HOME/USER_WM_STYLE; echo Restart HOME/bin/

[FVWM][Done]: <<ERROR>> Call of '/home/tom/bin/RunWM' failed!!!! 
(restarting 'fvwm2' instead)

Anyone have an idea why???  I guess it doesn't matter, the second
suggestion works.  I should just use it and move on...

>> perhaps it's nicer than having the PipeRead repeated for each menu item).

Now one last demonstration of my ignorance.

What does this mean?

       PipeRead cmd option
              Causes fvwm to read commands output from  the  pro-
              gram  named  cmd.   Useful  for building up dynamic
              menu entries based on a directories  contents,  for
              example.

So this caused fvwm2 to read the result of the echo command and do nothing
with it?

PipeRead "echo $0 > HOME/USER_WM_STYLE"

Tom

---

From: Dan Espen <[email-masked]>
Date: Fri, 14 Jan 2000 20:09:24 -0500

> So this caused fvwm2 to read the result of the echo command and do nothing

Yes.

The echo caused HOME/USER_WM_STYLE to be created.
Since it didn't write anything to stdout, the command fvwm read
was blank.  Fvwm ignores blank commands.

> PipeRead "echo $0 > HOME/USER_WM_STYLE"

The reason to use PipeRead instead of Exec is that fvwm is waiting for
the command results before proceeding.