Subject: Configurable BuildXLockMenu

From: Mikhael Goikhman <[email-masked]>
Date: Thu, 25 Feb 1999 02:09:10 +0200 (IST)

I have extended BuildXLockMenu, which is part of FVWM. Now you can define
your own menu name, title and optionally mini-icon. Also some
documentation is written.

Without arguments modified BuildXLockMenu prints the same output as it
did before, except one space replaced by TAB, so descriptions are now
propertly justified. The details are in inline pod, as usual you can
generate man page from pod using pod2man utility.

The original author says he is not active on fvwm any more, so I send
modified script to the list.

Migo.
-------- >8 --------

#!/usr/bin/perl

# ---------------------------------------------------------------------------

=head1 NAME

BuildXLockMenu - builds xlock menu definition for Fine Virtual Window Manager

=head1 SYNOPSIS

B<BuildXLockMenu> [B<--menu-name> name] [B<--menu-title> title]
[B<--menu-icon> icon] [xlock params]

=head1 DESCRIPTION

A simple perl script which parses xlock's output to build an fvwm 2.xx
menu definition of all xlock's modes.

=head2 Argument list

Arguments used by the script (must be first):

B<--menu-name>, B<--menu-title>, B<--menu-icon> - define menu name, title
and mini-icon acordingly given in the following argument. Default is name
"XLockMenu", title "XLock Modes" and no mini-icon.

Additional arguments will be passed to xload.

=head1 USAGE

 # add these lines to .fvwm2rc:
 PipeRead 'BuildXLockMenu --menu-name Screensaver --menu-title \
   "Screensaver" --menu-icon mini-bball.xpm -nice 20 -nolock'
 PipeRead 'BuildXLockMenu --menu-name Screenlock --menu-title \
   "Lock Screen" --menu-icon mini-rball.xpm -nice 20'
 AddToMenu "Utilities" "Screensaver%mini-monitor.xpm%" Popup Screensaver
 AddToMenu "Utilities" "Screenlock%mini-lock.xpm%"     Popup Screenlock

=head1 AUTHORS

 Charles K. Hines <[email-masked]>, initial version.
 Mikhael Goikhman <[email-masked]>, 24 Feb 1999.

=head1 BUGS

Depends on the output of 'xlock -h'. Will produce an empty menu, if the
structure of the output is changed.

=cut ========================================================================

$name  = "XLockMenu";
$title = "XLock Modes";
$icon  = "";

while ($ARGV[0] =~ /^--menu-/) {
  $_ = shift;
  /^--menu-n/ and $name  = shift;
  /^--menu-t/ and $title = shift;
  /^--menu-i/ and $icon  = '%' . shift() . '%';
}

$params = @ARGV? ' ' . join(' ', @ARGV): '';
$dscLen = 35 + length $icon;

$start = 0;

open(XL,"xlock -h 2>&1 |") || die "couldn't run xlock";

print "DestroyMenu $name\n";
print "AddToMenu $name \"$title\" Title\n";

while (<XL>)
{
  chomp;
  
  /where mode is one of:/ && do
  {
    $start = 1;
    next;
  };
  if ($start && $_)
  {
    @foo = split;
    $mode = shift @foo;
    $mode =~ /^-.*/ && next;
    printf "+ \"%-9s\t%-${dscLen}s Exec xlock$params -mode $mode\n",$mode,
      "(@foo)$icon\"";
  }
}

close XL;

#print "Beep\n";

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]