Subject: FVWM: Popup Menus

From: Simas Cepaitis <[email-masked]>
Date: Thu, 10 Apr 2003 16:21:25 +0300

Hello,

   I'm trying to do dynamic popup menus, dependent on the desktop 
number I'm on. It looks something like

Key F10  A  A  DynMenu

AddToFunc DynMenu
+ I Popup My$$d

So, I have 10 desktops and My0,My1 etc. Thing is, that I have 
"normal" popup menus, say, named remote-logins, which is the same 
as My4. Can I do 'alias' or something like this, not to duplicate 
my menu entries and also not to use mystic MySomeNumber name in 
RootMenu and elsewhere? I'm using fvwm 2.5.5 .

Simas Cepaitis
[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: Mikhael Goikhman <[email-masked]>
Date: Fri, 11 Apr 2003 10:08:02 +0000

> Hello,

Laba diena.

> RootMenu and elsewhere? I'm using fvwm 2.5.5 .

Unfortunately, it is currently impossible to alias menus.

But you may do the following to avoid duplication:

  AddToFunc CreateRemoteShellsMenu
  + I DestroyMenu $0
  + I AddToMenu   $0
  + I + "@menu/terminal-remote.xpm@rytas" Exec ssh ...
  + I + "@menu/terminal-remote.xpm@vakaras" Exec telnet ...
  + I + ...

  CreateRemoteShellsMenu RemoteShells
  CreateRemoteShellsMenu My3

Regards,
Mikhael.

---

From: Simas Cepaitis <[email-masked]>
Date: Fri, 11 Apr 2003 13:45:02 +0300

Hello,

>   CreateRemoteShellsMenu My3

This looks nice, but isn't really what I want in this situation. 
Still, I'll use this if everything other fails :) Now I'm 
thinking a little bit different way - name my menus not by 
number, but by desktop names, so I can use menus like 
'MenuRemote' elsewhere. And now I have another problem :)  I have 
DesktopName setup, and:

DestroyFunc DynMenu
AddToFunc DynMenu
+ I Popup Menu$$[desk.name$$d]

This doesn't work :( How can I mix variables (if I can), so 
they'll give me the effect I want?  It's strange, that with 
single '$' I can have $[desk.name1] == Web and get menu popup, 
but I can't do this dynamically..

P.S. Really nice lithuanian :)

Simas Cepaitis
[email-masked]

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 11 Apr 2003 11:49:59 +0000

> but I can't do this dynamically..

This is not the problem here.

The syntax here would be $[desk.name$$d] or better yet (in 2.5.6+)
$[desk.name$[desk.n]], note a single dollar is enough here.

The problem is that nothing inside $[] is expanded, i.e. you can't
nest variables. You hovewer may do currently the following:

  # be careful about shell escaping, there are extreme conditions
  DestroyFunc ExpandAndRun
  AddToFunc   ExpandAndRun
  + I PipeRead `echo '$*'`

  DestroyFunc DynMenu
  AddToFunc   DynMenu
  + I ExpandAndRun Popup Menu$$$$[desk.name$[desk.n]]

The plus command converts $$ to $, so ExpandAndRun and shell actually
get only 2 dollars and $[desk.n] is already expanded. Then PipeRead
expands the resulting $[desk.name3].

=--=

This is not the first message about nesting variables, so one option is
to introduce a new command (or prefix if you like) Expand for this.

  DestroyFunc DynMenu
  AddToFunc   DynMenu
  + I Expand Popup Menu$$$$[desk.name$[desk.n]]

Another option is to fix the expanding, so the inner $[] is expanded,
in this case only 2 dollars will be needed. And the third option is to
implement nested variable expansion, in this case one dollar will work
and no additional commands will be needed.

I will do the second option and then either the first or the third.

Regards,
Mikhael.