FvwmButton that changes the value after pressing it

I am making one function to a FvwmButton that changes the value after pressing it. Now it is using three separate files, similar question I asked before, now, how to make it one file or one function? It starts and kills one FvwmPager same as autohide does but more effective.

FILE 1: testPager.txt (starts pager)

DestroyFunc StartPager
AddToFunc StartPager
+ I Module FvwmPager TestPager
+ I Schedule 1000 Read killTestPager.txt

FILE 2: killTestPager.txt

DestroyFunc StartPager
AddToFunc StartPager
+ I KillModule FvwmPager TestPager
+ I Schedule 1000 Read startTestPager.txt

FILE 3: startTestPager.txt

DestroyFunc StartPager
AddToFunc StartPager
+ I Module FvwmPager TestPager
+ I Schedule 1000 Read killTestPager.txt

Later I will change Schedule to PipeRead.

Hi,

If it were me, I would have one file which does this:

DestroyModuleConfig X:*
*X: ...
*X: ...

KillModule FvwmPager X
Module FvwmPager X

You can of course bind the above to a key press, or add it to StartFunction, etc.

This assumes you only ever have one instance of FvwmPager X running at the same time, but from what I can tell, I think that’s what you want.

Thanks for getting started. My limited fvwm experience, what to add in *X: ... ???

If this does not work, I am also looking at this wiki page: Another Alt-Tab Function. But I don’t know where and how to add “Module FvwmPager TestPager” and “KillModule FvwmPager TestPager” in the SwitchWindow function.

It will not be a key press or adding in StartFunction, but a FvwmButton with a mouse click:
Action(Mouse 1) 'StartPager'

Browsing around found this in Gentoo forum using Test (EnvMatch) and TestRc (NoMatch).

This code only uses one file: starts the pager, kills it, and starts it again. That’s all and then duplicates the pager. Not a solution but maybe something more can be added.

FILE 1: testPager.txt (starts pager)

Module FvwmPager TestPager
SetEnv Switch OFF

DestroyFunc StartPager
AddToFunc StartPager
+ I Test (EnvMatch Switch ON) Module FvwmPager TestPager
+ I Test (EnvMatch Switch OFF) KillModule FvwmPager TestPager
+ I SetEnv Switch ON

Although that works, you should really be using InfoStore for this (EnvMatch works with InfoStore as well, for example EnvMatch infostore.Switch On).

Great @Mjaakko. Most ideal is to read multiple commands in one line, the same as Bash does. Later I will check with PipeRead.

With Mjaakko’s code sample, this works indefinitely, pager turns on and off. Three functions in one file.

DestroyFunc putON
AddToFunc putON
+ I Module FvwmPager TestPager
+ I PipeRead 'echo InfoStoreAdd Switch OFF'

DestroyFunc putOFF
AddToFunc putOFF
+ I KillModule FvwmPager TestPager
+ I PipeRead 'echo InfoStoreAdd Switch ON'

## Start pager
Module FvwmPager TestPager

## Action(Mouse 1) 'StartPager' (add in FvwmButton)
DestroyFunc StartPager
AddToFunc StartPager
+ I Test (EnvMatch infostore.Switch ON) putON
+ I TestRc (NoMatch) putOFF
1 Like

I have updated share code with PipeRead and InfoStoreAdd. Two lines are removed by adding TestRc (NoMatch). This is great!!!

Still aiming to reduce it to two multiple command lines with PipeRead. Cannot get it to read Test (EnvMatch).

+ I PipeRead 'echo Test (EnvMatch infostore.Switch ON) Module FvwmPager TestPager' | 'echo InfoStoreAdd Switch OFF'
+ I PipeRead 'echo Test (EnvMatch infostore.Switch OFF) KillModule FvwmPager TestPager' | 'echo InfoStoreAdd Switch ON'

Thanks for the new function. I am using many value change buttons.

For PipeRead there is one topic with an example “if and else” in FvwmButtons.

Couldn’t get InfoStoreAdd to work but SetEnv does it.

SetEnv Switch OFF
Module FvwmPager TestPager

DestroyFunc StartPager
AddToFunc StartPager
+ I Piperead 'if [ $Switch = OFF ]; then echo "KillModule FvwmPager TestPager"; \
	echo "Schedule 500 SetEnv Switch ON"; fi'
+ I Piperead 'if [ $Switch = ON ]; then echo "Module FvwmPager TestPager"; \
	echo "SetEnv Switch OFF"; fi'
1 Like

Simple and clear, anywhere to switch on and off, or give multiple choices. This is what I liked about Bash. Easy to read with choices. PipeRead brings functions to a broader level, the bridge. :gear: Fvwm is truly 100% configurable.

But you don’t need to do any of this.

DestroyFunc Foo
AddToFunc Foo
+ I None (TestPager) FvwmPager TestPager
+ I TestRc (Match) KillModule FvwmPager TestPager

This way, you cut out all the other crap.

Individually the two lines work but not in same function. TestRc (Match) doesn’t block killing the TestPager. Gets killed immediately after load.