Re: FVWM: howto conditionally add menu entries?

Dan Espen <[email protected]>
Newsgroups gmane.comp.window-managers.fvwm
Message-ID <[email protected]>
Stuart Longland <[email protected]> writes:

> On 3/8/19 1:56 pm, hw wrote:
>> If I was to write some program to create the root menu, I would always
>> need to modify the program when new optional configurations are to be
>> added so it could recognize them.  That is something I would prefer to
>> avoid.
>
> Well no, the program will need to store its state somewhere, and have
> that state updated so that next time it is called by FVWM, its output
> reflects the new state.

The script may or may not have to save state, it could just be looking
at data.  Here is a fragment where a perl subroutine is given a
menu title and a command, it looks at the command and if the command
can be found (using "which") it goes on to add the menu entry:

# arg 1, the menu title
# arg 2-n, the command
sub Add {
  ($desc,$func,$accel)=@_;
  ($f1, $f2)=split(" ",$func);
  if ( $f1 eq "Exec" ) {
    $x=`which $f2 2>&1`;
    $rc=$?;
    if ( $rc != 0 ) {
#      print "cant find &f2, rc $rc, cmd o/p $x\n";
      return;
    }
  }
  ...

-- 
Dan Espen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.