Re: FVWM: Popup Menus

From: Mikhael Goikhman <migo_at_homemail.com>
Date: Fri, 11 Apr 2003 11:49:59 +0000

On 11 Apr 2003 13:45:02 +0300, Simas Cepaitis wrote:
>
> Mikhael Goikhman wrote:
> >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 + "_at_menu/terminal-remote.xpm_at_rytas" Exec ssh ...
> > + I + "_at_menu/terminal-remote.xpm_at_vakaras" Exec telnet ...
> > + I + ...
> >
> > CreateRemoteShellsMenu RemoteShells
> > 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..

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.
--
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 majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Fri Apr 11 2003 - 06:51:58 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:54 BST