Subject: FVWM: Questions on Fvwm page.nx

From: Michael Fischer <[email-masked]>
Date: Sun, 16 Jun 2002 18:15:04 -0400

Mail particularly addressed to Mikhael Goikhman, as
he helped me with this one before...

Problem: trying to get pager/GotoPage "wrap-around".

I use a 4 row desktop. So I assume that the leftmost
page is page.nx == 0, and the rightmost page is
page.nx == 3. Putting the following in my rc and testing
confirms this suspicion.

Key Left  A M GotoPage 0 +0p
Key Right A M GotoPage 3 +0p

To address my desire for the wrap-around feature, you once
supplied me with the following:

Key Left  A M PipeRead \
        `perl -e 'print "GotoPage ", \
        eval "($[page.nx] + 4) % 5", " +0p"`

Key Right A M PipeRead \
        `perl -e 'print "GotoPage ", \
        eval "($[page.nx] + 0) % 5", " +0p"`

The above did indeed do what I meant, but I wanted to
find a way for my usual page-changing keystrokes (C-Right,
C-Left) to "just work" with the wrap-around as well.

I tried:

Key Left A M PipeRead \
        `perl -e 'print "GotoPage ", \
        eval "($[page.nx] == 0) ? 3 : $[page.nx] - 1", " +0p"`

Key Right A M PipeRead \
        `perl -e 'print "GotoPage ", \
        eval "($[page.nx] == 3) ? 0 : $[page.nx] + 1", " +0p"`

But this does not work. So as a debugging measure, I tried

Key F12		A 	N	Exec exec \
	`perl -le 'print STDERR "current page.nx: $[page.nx]\n", \
	"dest page.nx: ", \
        eval "($[page.nx] == 0) ? 3 : $[page.nx] - 1", "\n"'`

and it turns out (tailing ~/.X.err on SuSE) that I always see
(irrespective of which page I am on):

current page.nx: 0
dest page.nx: 3

So, probably small surprise that my attempt to use the ?: operator
isn't doing what I want...

Could my stupidity, error be pointed out? Or is it a bug?

TIA.

Michael
-- 
Michael Fischer				Happiness is a config option.
[email-masked]			Recompile and be happy.
--
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: Mikhael Goikhman <[email-masked]>
Date: Mon, 17 Jun 2002 00:06:46 +0000

On 16 Jun 2002 18:15:04 -0400, Michael Fischer wrote:
> page.nx == 3.

[...]

> But this does not work.

You should use a double dollar here instead of a single dollar,
otherwise $[page.nx] is expanded in Key command, not in PipeRead.

The strange thing is that I didn't use a double dollar in my original
suggestion at http://www.hpc.uh.edu/fvwm/archive/0204/msg00145.html
and I always test what I post.

Anyway, if you use a double dollar it works in 2.4.x and 2.5.x:

  Key Left   A C  PipeRead `perl -e 'print "GotoPage ", ($$[page.nx] + 3 ) % 4, " +0p"'`
  Key Right  A C  PipeRead `perl -e 'print "GotoPage ", ($$[page.nx] + 1 ) % 4, " +0p"'`

Regards,
Mikhael.

---

From: Michael Fischer <[email-masked]>
Date: Mon, 17 Jun 2002 03:01:42 -0400

>   Key Right  A C  PipeRead `perl -e 'print "GotoPage ", ($$[page.nx] + 1 ) % 4, " +0p"'`

Bingo! 

Thanks much. Perhaps this should be mentioned in some way in the manpage?
I imagine it might be close to an FAQ for some...

Cheers.

Michael