Subject: FVWM: question: Fvwm and Awk: more $1 expansion trouble

From: Neil Zanella <[email-masked]>
Date: Sat, 27 Jan 2001 22:52:16 -0330 (NST)

Hello,

I am trying to have fvwm2 process the following from a config file
but I am having some difficulties with the variables $1, $2, and $3.

The command is:

/usr/X11R6/bin/xterm -e /bin/sh -c (/usr/X11R6/bin/showrgb | /bin/awk '{
 printf("#%02X%02X%02X\t", $1, $2, $3); for (i = 4; i <= NF; i++)
 printf " " $i; print "" }' | /usr/bin/less)

(the parentheses are not working outside fvwm for some reason so you can
enter the above without parentheses at a shell prompt and have no less)

Note: the following works from a shell prompt (all one one line):

/usr/X11R6/bin/showrgb | /bin/awk '{
 printf("#%02X%02X%02X\t", $1, $2, $3); for (i = 4; i <= NF; i++)
printf " " $i; print "" }' | /usr/bin/less

Now I tried the following and a few other things but
they did not work (although the $i works fine)...

[snip]

+ "RGB" "I" Exec /usr/X11R6/bin/xterm-e /bin/sh -c
"(/usr/X11R6/bin/showrgb | /bin/awk '{ printf(\"#%02X%02X%02X\t\", $$$$1,
$$$$2, $$$$3); for (i = 4; i <= NF; i++) printf \" \" \$i; print \"\" }' |
/usr/bin/less)"

[snip]

Could someone please point what went wrong?

Thanks!

--
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: Dominik Vogt <[email-masked]>
Date: Sun, 28 Jan 2001 16:21:55 +0100

>  printf " " $i; print "" }' | /usr/bin/less)

This does not work because the shell that executes this line
interprets the parentheses and pipe symbols.  They have to be
quoted (and then you don't need the parentheses at all.  The
positional parameters have to be quoted too:

  /usr/X11R6/bin/xterm -e /bin/sh -c "/usr/X11R6/bin/showrgb | /bin/awk '{
   printf(\"#%02X%02X%02X\t\", \$1, \$2, \$3); for (i = 4; i <= NF; i++)
   printf \" \" $i; print \"\" }' | /usr/bin/less"
  
> they did not work (although the $i works fine)...

The easiest way to make it work is to put it in a script.  Then
you don't have to worry about fvwm's quoting.

> $$$$2, $$$$3); for (i = 4; i <= NF; i++) printf \" \" \$i; print \"\" }' |

Um, did you try to add this to a function or a menu?  If it's a
menu, the line must begin with

  + "RGB" Exec

if it's a funtion it must start with

  + "I" Exec

But you used

  + "RGB" "I" Exec

8-)

Also, the command must be "xterm -e" not "xterm-e".  And again,
the '$1' must be quoted (e.g. with a backslash):

  + I Exec /usr/X11R6/bin/xterm -e /bin/sh -c
  "/usr/X11R6/bin/showrgb | /bin/awk '{ printf(\"#%02X%02X%02X\t\",
  \$$$$1, \$$$$2, \$$$$3); for (i = 4; i <= NF; i++)
  printf \" \" $i; print \"\" }' | /usr/bin/less"

> Could someone please point what went wrong?

Just to give you an idea why this is so complicated:  This line
is executed as a normal fvwm command that adds a new item to a
complex function that executes an xterm command that starts a
shell to run a script that runs a pipe which includes an awk
script that prints positional parameters with a format mask.
If my count is correct, quotes, '|' symbols and '$' are
interpreted up to eight times by at least four different parsers
(fvwm, sh, awk and xterm) in this chain.  Each of these parsers
has a different idea how things work.  In this situation it is
almost always better to get these commands straight on the command
line, then put them in a shell script and execute the script from
the function.

Bye

Dominik ^_^  ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
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: Glen Lee Edwards <[email-masked]>
Date: Sun, 28 Jan 2001 13:42:27 -0600 (CST)

Is there a way to set a short delay on SloppyFocus before it brings a different
window into focus?  I line up all my windows to the upper left of the screen,
immediately under the task bar.  And I leave about 10p of space on the right
side clear so that the root window shows.  This allows me to move the cursor
over the root window so I can easily access the customized menus I have with the
mouse.  However, when I do this, if one of the under-lying windows extends
beyond the focused window, even if it's just a pixel or two, I lose focus of
the window I'm working on.  Is there a way to set up a short delay so I can pass
over another window on route to the root window without losing focus of the
window I'm working on?

Thanks,

Glen

---

From: Dan Espen <[email-masked]>
Date: Sun, 28 Jan 2001 14:58:57 -0500

Glen Lee Edwards <[email-masked]> writes:
> window into focus?

There is no way to do this that I'm aware of.

Either bind the menu to a key, or bind the menu to mouse button over
a window title, button, or frame.  To not interfere with existing
mouse bindings, you can use the motion or double click modifiers.

I think using a key makes the most sense.

--
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: Neil Zanella <[email-masked]>
Date: Sun, 28 Jan 2001 17:28:48 -0330 (NST)

Thanks Dominik for your comments. I got the script to work by
removing the parentheses and testing it first on the command line,
then within a subshell, then within an xterm that runs the subshell,
and finally through an Fvwm menu and by running ps aux | grep awk
I could debug the line in the fvwm script while my xterm was drunk.

Here is the line I eventually got to work in my .fvwm2rc file.
My mail client broke it all up but that's OK...

+                "RGB" Exec /usr/X11R6/bin/xterm -e /bin/sh -c
'/usr/X11R6/bin/showrgb | /bin/awk "{ printf(\"#%02X%02X%02X\t\", \$$$$1,
\$$$$2, \$$$$3); for (i = 4; i <= NF; i++) printf \" \" \$i; print
\"\" }" | /usr/bin/less'

It's a bit messy but at least I don't have to keep track of external
scripts! 8-)

Have a nice day,

Neil

---

From: Erik Steffl <[email-masked]>
Date: Mon, 29 Jan 2001 08:10:40 -0800

> I think using a key makes the most sense.

  while you cannot (probably) delay the focus grabbing you can prevent
the window from being raised (man FvwmAuto), it's not exactly the same
thing as you want but it's the closest thing I can think of...

	erik