/usr/bin/fvwm-menu-xlock is in fvwm 1:2.6.5.ds-4.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | #!/usr/bin/perl
# Copyright (c) 1999-2009 Mikhael Goikhman
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Filter this script to pod2man to get a man page:
# pod2man -c "Fvwm Utilities" fvwm-menu-xlock | nroff -man | less -e
use Getopt::Long;
my $version = "2.6.5";
my $name = 'XLockMenu';
my $title = 'XLock Modes';
my $itemf = '%n\t(%d)'; # may contain %n, %d, %D.
my $icont = '';
my $iconi = '';
my $wm_icons = 0;
my $special_first = 0;
GetOptions(
"help|h|?" => \&show_help,
"version|V" => \&show_version,
"name=s" => \$name,
"title=s" => \$title,
"item=s" => \$itemf,
"icon-title=s" => \$icont,
"icon-item=s" => \$iconi,
"wm-icons" => \$wm_icons,
"special-first" => \$special_first,
) || wrong_usage();
if ($wm_icons) {
$icont ||= "";
$iconi ||= "menu/lock.xpm";
}
my $icont_str = $icont ? "%$icont%" : "";
my $iconi_str = $iconi ? "%$iconi%" : "";
my $params = @ARGV ? ' ' . join(' ', @ARGV) : '';
my $lines1 = ""; # non-special mode lines
my $lines2 = ""; # special mode lines
my $start = 0;
my $special = 0;
$itemf =~ s/\\t/\t/g;
open(XL, "xlock -display NONE -help 2>&1 |")
|| die "Exec echo 'Could not run xlock'\n";
print "DestroyMenu $name\n";
print "AddToMenu $name \"$icont_str$title\" Title\n";
while (<XL>) {
chomp;
/where mode is one of:/ && do {
$start = 1;
next;
};
if ($start && $_) {
my ($misc, $name, $dsc) = split(/\s+/, $_, 3);
next if $name =~ /^-/;
my $dsc2 = $dsc =~ /^Shows (.*)$/ ? $1 : $dsc;
my $item_str = $itemf;
$item_str =~ s/\\t/\t/g;
&expand_width_specifier(\$item_str, 'n', $name);
&expand_width_specifier(\$item_str, 'd', $dsc);
&expand_width_specifier(\$item_str, 'D', $dsc2);
$special = 1 if !$special && $name eq 'blank';
($special ? $lines2 : $lines1) .=
qq(+ "$iconi_str$item_str" Exec xlock$params -mode $name\n);
}
}
close XL;
print $special_first
? qq($lines2+ "" Nop\n$lines1)
: qq($lines1+ "" Nop\n$lines2);
exit(0);
# ---------------------------------------------------------------------------
# Substitutes all %N1*N2x in $name by properly stripped and justified $value.
sub expand_width_specifier (\$$$) {
my ($name, $char, $value) = @_;
$$name =~ s/%(-?\d+)?(\*(-?)(\d+))?$char/
my $value = !$2 || $4 <= 3 || $4 > length($value) ? $value : $3
? "..." . substr($value, -$4 + 3, $4 - 3)
: substr($value, 0, $4 - 3) . "...";
$1? sprintf("%$1s", $value): $value;
/ge;
}
sub show_help {
print "A small perl script which builds xlock menu for fvwm.\n\n";
print "Usage: $0 [OPTIONS] [-- XLOCK-OPTIONS]\n";
print "Options:\n";
print "\t--help show this help and exit\n";
print "\t--version show the version and exit\n";
print "\t--name=NAME menu name, default is '$name'\n";
print "\t--title=NAME menu title, default is '$title'\n";
print "\t--item=NAME menu item format, default is '$itemf'\n";
print "\t--icon-title=XPM menu title icon, default is no\n";
print "\t--icon-item=XPM menu item icon, default is no\n";
print "\t--wm-icons define icon names to use with wm-icons\n";
print "\t--special-first put special modes first\n";
print "Short options are ok if not ambiguous: -h, -t.\n";
print "\nSome useful xlock(1) options, 'xlock -h' for more:\n";
print "\t-delay usecs delay between batches of animations\n";
print "\t-nolock screensaver, don't lock the display\n";
print "\t-inwindow run in window as opposite to -inroot\n";
print "\t-sound turn on sound if enabled\n";
print "\t-nice level decrease the process priority (0 .. 19)\n";
exit 0;
}
sub show_version {
print "$version\n";
exit 0;
}
sub wrong_usage {
print STDERR "Try '$0 --help' for more information.\n";
exit -1;
}
__END__
# ---------------------------------------------------------------------------
=head1 NAME
fvwm-menu-xlock - builds xlock menu definition for fvwm
=head1 SYNOPSIS
B<fvwm-menu-xlock>
[ B<--help>|B<-h>|B<-?> ]
[ B<--version>|B<-V> ]
[ B<--name>|B<-n> name ]
[ B<--title>|B<-t> title ]
[ B<--item> format ]
[ B<--icon-title> icon ]
[ B<--icon-item> icon ]
[ B<--special-first>|B<-s> ]
[ -- xlock params ]
=head1 DESCRIPTION
A simple perl script which parses xlock's output to build an fvwm
menu definition of all xlock's modes.
=head1 OPTIONS
=over 4
=item B<--help>
show the help and exit
=item B<--version>
show the version and exit
=item B<--name> name
define menu name in the following argument.
Default is "XLockMenu"
=item B<--title> title
define menu title in the following argument.
Default is "XLock Modes".
=item B<--item> format
define menu item format in the following argument,
default is '%n\t(%d)'.
TAB can be specified as '\t', but in .fvwm2rc you should specify a double
backslash or a real TAB.
Format specifiers:
%n - mode name
%d - mode description
%D - mode description without "Shows " prefix if any
These specifiers can receive an optional integer size, positive for right
adjusted string or negative for left adjusted, example: %8x; and optional
*num or *-num, which means to leave only the first or last (if minus) num of
chars, the num must be greater than 3, since the striped part is replaced
with "...", example: %*30x. Both can be combined: %-10*-20x, this instructs to
get only the 20 last characters, but if the length is less then 10 - to fill
with up to 10 spaces on the right.
=item B<--icon-title> icon
=item B<--icon-item> icon
define menu icon for title and regular item accordingly.
Default is no menu icons (equivalent to an empty icon argument).
=item B<--wm-icons>
define icon names suitable for use with wm-icons package.
Currently this is equivalent to: --icon-title '' --icon-item
menu/lock.xpm.
=item B<--special-first>
instructs to include special modes (usually black, bomb and random) first.
=back
Option parameters can be specified either using '=' or in the next argument.
Short options are ok if not ambiguous: -h, -t; but be careful with
short options, what is now unambiguous, can became ambiguous in the next
versions.
Additional arguments (after B<-->) will be passed to xlock.
Please see the B<xlock>(1) man page for the xlock options.
=head1 USAGE
Add these lines to your fvwm configuration file:
PipeRead 'fvwm-menu-xlock --name MenuSSaver --title "Screensaver" \
--icon-item mini-bball.xpm --special-first -- -nice 19 -nolock'
PipeRead 'fvwm-menu-xlock --name MenuSLock --title "Lock Screen" \
--icon-item mini-rball.xpm --special-first -- -nice 19'
AddToMenu "Utilities" "Screensaver%mini-monitor.xpm%" Popup MenuSSaver
AddToMenu "Utilities" "Screenlock%mini-lock.xpm%" Popup MenuSLock
=head1 AUTHORS
Charles K. Hines <chuck_hines@vnet.ibm.com>, initial version.
Mikhael Goikhman <migo@homemail.com>, from 24 Feb 1999.
=head1 COPYING
The script is distributed by the same terms as fvwm itself.
See GNU General Public License for details.
=head1 BUGS
Depends on the output of xlock. Will produce an empty menu if the structure
of the output is changed.
Report bugs to fvwm-bug@fvwm.org.
=cut
# ***************************************************************************
|