Page Indicator with SendToModule

I am not familiar with SendToModule command. It was suggested to make a change to this Page Indicator config.


Use SendToModule to change the FvwmButton’s desk and page numbers. I did a Google search, but couldn’t find related examples.

Earlier, it was copied from this topic.

One of my favorite scripts, tracking where I am. :mag_right:
Combine the two FvwmButtons.

+ I *Pgfunc: Geometry 240x32+8+10
+ I *Pgfunc: Rows 1
+ I *Pgfunc: (80x1, Back #2b4e5e, Title "DESK NO:", \
	Font "xft:Sans:Bold:size=10:antialias=True")
+ I *Pgfunc: (160x1, Colorset 15, Title ' Desk: $[desk.n] | Page: $[page.nx]  $[page.ny]', \
	Action (Mouse 1) Nop)

I don’t know how to put SendToModule. Somebody else.

Here’s what I’ve been using:

DesktopSize 2x2
#EdgeScroll 100 100
EdgeScroll 0 0

Colorset 40 bg SlateBlue, fg black
Colorset 41 bg Orchid, fg black

Style FP* !Title, BorderWidth 4, Sticky, WindowListSkip
Style FB-FP1 StartsOnScreen DP1-8, WindowListHit
Style FB-FP2 StartsOnScreen DP1-1-8, WindowListHit
Style FB-FP3 StartsOnScreen HDMI2, WindowListHit

DestroyModuleConfig FP1:*
*FP1: Font "Xft:Book:size=8"
*FP1: Columns 1
*FP1: SmallFont none
*FP1: DeskHilight
*FP1: Back SlateBlue
*FP1: Fore Black
*FP1: Hilight Orchid
*FP1: WindowColors Black '#60A0C0' Black '#c06077'
*FP1: Monitor DP1-8
*FP1: UseSkipList

KillModule FvwmPager FP1

KillModule FvwmButtons FB-FP1
DestroyModuleConfig FB-FP1:*
*FB-FP1: Back slateblue
*FB-FP1: (1x1, Swallow (UseOld, Respawn) "FP1" "Module FvwmPager FP1 0 4")
Module FvwmButtons -g 74x251+1830+21@g FB-FP1

DestroyModuleConfig FB-Page-A:*
*FB-Page-A: Rows 2
*FB-Page-A: Columns 2
*FB-Page-A: Back slateblue
*FB-Page-A: (1x1, Id "A.00", Title "0 0", Action "GotoPage $$$$[monitor.current] 0 0")
*FB-Page-A: (1x1, Id "A.10", Title "1 0", Action "GotoPage $$$$[monitor.current] 1 0")
*FB-Page-A: (1x1, Id "A.01", Title "0 1", Action "GotoPage $$$$[monitor.current] 0 1")
*FB-Page-A: (1x1, Id "A.11", Title "1 1", Action "GotoPage $$$$[monitor.current] 1 1")

Style FB-Page* BorderWidth 4, !Handles

KillModule FvwmButtons FB-Page-A

Module FvwmButtons -g 82x73+1830+348@g FB-Page-A

DestroyModuleConfig FE-NP:*
*FE-NP: Cmd Function
*FE-NP: new_page PageButton

Module FvwmEvent FE-NP

InfoStoreAdd FB-Page-eDP1 A

DestroyFunc PageButton
AddToFunc   PageButton
+ I InfoStoreAdd FB-Page-Done 0
+ I Test (EnvMatch infostore.FB-Page-Done 1) Break
+ I SendToModule FB-Page-$[infostore.FB-Page-$[monitor.current]] ChangeButton $[infostore.FB-Page-$[monitor.current]].00 Colorset 40
+ I SendToModule FB-Page-$[infostore.FB-Page-$[monitor.current]] ChangeButton $[infostore.FB-Page-$[monitor.current]].10 Colorset 40
+ I SendToModule FB-Page-$[infostore.FB-Page-$[monitor.current]] ChangeButton $[infostore.FB-Page-$[monitor.current]].01 Colorset 40
+ I SendToModule FB-Page-$[infostore.FB-Page-$[monitor.current]] ChangeButton $[infostore.FB-Page-$[monitor.current]].11 Colorset 40
+ I SendToModule FB-Page-$[infostore.FB-Page-$[monitor.current]] ChangeButton $[infostore.FB-Page-$[monitor.current]].$[monitor.$[monitor.current].pagex]$[monitor.$[monitor.current].pagey] Colorset 41
+ I InfoStoreAdd FB-Page-Done 1

Note the use of SendToModule which accepts the alias of the FvwmButtons instance as its first command. The ChangeButton command is what FvwmButtons listens to. Options include Text.

SendToModule is just a way for fvwm to send commands to a module to respond to. What commands the module respond to depend on the module itself, see the FvwmButtons manual. In this case FvwmButtons can update any button you give an ID too, so you can update what is shown. The RightPanel in the default-config shows how to use this with FvwmEvent to update the desk numbers on desk changes.

The two FvwmButton samples (FB-Page-A and RightPanel). Both with SendToModule, have a fixed number of desks/pages… Id A.00 - Id A.11 and Id desk0 - Id desk3

The Page Indicator, show any number of desk and pages. No fixed text. How does SendToButton know the current FvwmButton desk/page number and changes it when desk/page changes? Looks like a static command.

Something is missing!!! What does function PageButton supposed to do by SendToModule? FB-Page-A changes the page, but color or text don’t change.

SendToModule doesn’t do anything.

Hi @rasat

Ah, I see your confusion. I hadn’t given you the specific answer to your question. My apologies. I’d hoped it would have lead you to the answer. If the below is still unclear, let me know and I’ll see if I can draw some diagrams or try a different means of communicating this for you.

Here’s something more to your original request:

  DestroyModuleConfig FB-A:*                                                       
  *FB-A: (1x1, Title "Desk: $[monitor.$[monitor.current].desk]", Id D)             
  KillModule FvwmButtons FB-A                                                      
  FvwmButtons FB-A                                                                 
  DestroyModuleConfig FE-E:*                                                       
  *FE-E: Cmd                                                                       
  *FE-E: new_desk "SendToModule FB-A ChangeButton D Title 'Desk: $$$$[monitor.$[monitor.current].desk]'"
  KillModule FvwmEvent FE-E                                                        
  Module FvwmEvent FE-E                                                            

To break this down for you:

*FB-A: (1x1, Title "Desk: $[monitor.$[monitor.current].desk]", Id D)

This creates a button with an Id of D, so we can refer to it later on. We also set the initial Title of the button to be the monitor’s current desk.

*FE-E: new_desk "SendToModule FB-A ChangeButton D Title 'Desk: $$$$[monitor.$[monitor.current].desk]'"

Then, using FvwmEvent, we set up a listener for when we change desk, such that we use the SendToModule command to reference the FvwmButtons alias we created earlier (FB-A), issuing the command ChangeButton. In doing so, we give it the button Id we want (in this case, it’s D), and issue the further command of Title, to which we specify the new title string ('Desk: $$$$[monitor.$[monitor.current].desk]').

As an addendum, the reason we specify $$$$ here is so that the parsing rules in fvwm dont’ expand the string too early, and only do so when the desk changes, and not before.

I hope this helps.

Thanks. What is the title string for $[page.nx] $[page.ny]?

Page x y are added. This title string is unstable. Desk number works fine but page number changes irregularly.

*FB-A: (1x1, Title "Desk: $[monitor.$[monitor.current].desk] \
Page: $[monitor.$[monitor.current].pagex] $[monitor.$[monitor.current].pagey]", \
Id D, Action (Mouse 1) Nop)

*FE-E: new_desk "SendToModule FB-A ChangeButton D \
Title 'Desk: $$$$[monitor.$[monitor.current].desk] \
Page: $$$$[monitor.$[monitor.current].pagex] \

You are only triggering hit action on the new_desk event, which only happens when you change desks, not when you change pages, that is why it won’t update every page. There is a new_page event too.

More to learn. :sunny: Works well.

*FE-E: new_desk "SendToModule FB-A ChangeButton D \
Title 'Desk: $$$$[monitor.$[monitor.current].desk]'"
*FE-E: new_page "SendToModule FB-A ChangeButton P \
Title 'Page: $$$$[monitor.$[monitor.current].pagex]  \

@Mjaakko check the new update.



Aside from the… learnings which you’re a part of, @rasat, I suppose I could be willing to patch FvwmButtons such that it opened by default.

I can completely understand why panels work the way they do, and why they currently behave this way. It does help to remove a lot of boilerplate config.

I might look into it in 2078. But you can still make it work as-is.