Toggle(move) current window between page 0 and page 1

Hi, as a FVWM beginner I want to ask a simple question, how to toggle(move) current window between page 0 and page 1

e.g. when “toggle window” function is triggered, if current window is on page 0, then move the window to page 1, if current window is on page 1 then move the window to page 0

The basic pseudo code is as follows:
if “current page” == 0;
move current window to page 1
if “current page” == 1;
move current window to page 0

I tried something like:
DestroyFunc MoveToDiffPage
AddToFunc MoveToDiffPage

  • I Current PipeRead ‘if [ $[page.nx] -eq 0 ]; then echo MoveToPage 1 0; else echo MoveToPage 0 0;’

also tried :

  • I ThisWindow PipeRead ‘if [ $[page.nx] -eq 0 ]; then echo MoveToPage 1 0; else echo MoveToPage 0 0;’

it does not work either… BTW what difference between “Current” and “ThisWindow”?

Thanks!

Hi @glom,

This depends on what your DesktopSize is set to as to how complicated the maths needs to be. But here’s an example (where DesktopSize is 3x3):

DestroyFunc TogglePage
AddToFunc   TogglePage
+ I PipeRead `echo MoveToPage 0 $((1 - $[page.ny]))`

This would move a window between page 0 0, and the page below it (0 1).

There’s probably something missing from your example because it looks as though it should work. You can check STDERR as FVWM might have logged something there.

As to what the difference is between ThisWindow and Current is… not much. ThisWindow is in context of the implied window that’s being referenced. It might imply Current (as in the focused window), or it might be referencing a window via Pick or Next, etc.

HTH,
Thomas

Thanks Thomas,


Blockquote

  • I PipeRead echo MoveToPage 0 $((1 - $[page.ny]))

your solution is better, When Fvwm system reads the variables, the task of determining which is current desktop has been done, do not need “if bla bla …”
it works on my configs
Thanks for your patience to explain, nice weekend!

Hi Thomas,
your solution is better, it works :

    DestroyFunc TogglePage
    AddToFunc   TogglePage
    + I PipeRead `echo MoveToPage 0 $((1 - $[page.ny]))`

but why this version does not work? what is wrong with this one? I just want to understand more of FVWM funcations. (my FVWM only has 2 desks, each desk has 2 pages .)

 DestroyFunc TogglePagev2
 AddToFunc   TogglePagev2
 + I PipeRead `if [ $[page.ny]=0 ]; then echo MoveToPage 1 0; else echo  MoveToPage 0 0;`

Hi @glom,

You’ve a syntax error:

 + I PipeRead `if [ $[page.ny]=0 ]; then echo MoveToPage 1 0; else echo  MoveToPage 0 0;`

Note that you need a space for the comparison operator:

+ I PipeRead `[ $[page.ny] = 0 ] ....`

ok, the syntax is “space sensitive”, good to know that, thanks Thomas!