vfmg (DEVEL): vfmg - reworked options so now are siutable to use w...
sparky
sparky at pld-linux.org
Mon Oct 31 23:20:55 CET 2005
Author: sparky Date: Mon Oct 31 22:20:55 2005 GMT
Module: vfmg Tag: DEVEL
---- Log message:
- reworked options so now are siutable to use with rc file, no backward
compatibility but I don't realy care
---- Files affected:
vfmg:
vfmg (1.73.2.14 -> 1.73.2.15)
---- Diffs:
================================================================
Index: vfmg/vfmg
diff -u vfmg/vfmg:1.73.2.14 vfmg/vfmg:1.73.2.15
--- vfmg/vfmg:1.73.2.14 Mon Oct 31 19:42:38 2005
+++ vfmg/vfmg Mon Oct 31 23:20:50 2005
@@ -2,74 +2,121 @@
#$Id$
use strict;
-use File::Find;
+use File::Find qw(find);
use Getopt::Long;
-use Encode;
+use Encode qw(encode decode);
# header {{{
my $o_help=0;
my $o_tags=0;
my $o_end=0;
my $o_verbose=0;
-my %opt = (
- icons => 0,
- exec => 0,
- clear => 0,
- promote => 0,
- full => 0,
- strip => 0,
- utf => 0,
- enc => "",
- nomenu => 0,
- xterm => "xterm -name xterm-%1 -e %2",
+my %defopt = (
+ exec => 0,
+ exec_full => 0,
+ icons => 1,
+ icons_full => 0,
+ icons_scale => 0,
+# icons_dir => "", should be used only if defined
+
+ utf => 0,
+ encoding => "",
+
+ clear => 0,
+ promote => 0,
+ strip => 0,
+ nomenu => 0,
+ xterm => "xterm -name xterm-%1 -e %2",
+ convert => "convert \%in \%out -geometry 18x18",
);
-my $o_output="";
-
-$opt{xterm}="$ENV{'VFMG_TERM'}" if $ENV{'VFMG_TERM'};
+my %opt;
+my $o_output;
+$defopt{xterm}="$ENV{'VFMG_TERM'}" if $ENV{'VFMG_TERM'};
+
+Getopt::Long::Configure("bundling");
+GetOptions(
+ 'help|h' => \$o_help,
+ 'tags|t' => \$o_tags,
+ 'end|e' => \$o_end,
+ 'verbose|v' => \$o_verbose,
+
+ 'exec|x!' => \$opt{exec},
+ 'exec-full|X!' => \$opt{exec_full},
+ 'icons|i!' => \$opt{icons},
+ 'icons-full|I!' => \$opt{icons_full},
+ 'icons-scale|S!'=> \$opt{icons_scale},
+ 'icons-dir|d=s' => \$opt{icons_dir},
-GetOptions('help'=>\$o_help,
- 'tags'=>\$o_tags,
- 'end|e'=>\$o_end,
- 'icons'=>\$opt{icons},
- 'exec|x'=>\$opt{exec},
- 'clear'=>\$opt{clear},
- 'promote'=>\$opt{promote},
- 'verbose'=>\$o_verbose,
- 'full'=>\$opt{full},
- 'strip'=>\$opt{strip},
- 'utf8'=>\$opt{utf},
- 'nomenu|m'=>\$opt{nomenu},
- 'output=s'=>\$opt{enc},
- 'xterm|r=s'=>\$opt{xterm}
+ 'utf8|u' => \$opt{utf},
+ 'encoding|E=s' => \$opt{encoding},
+
+ 'clear|c' => \$opt{clear},
+ 'promote|p' => \$opt{promote},
+ 'strip|s' => \$opt{strip},
+ 'nomenu|m' => \$opt{nomenu},
+ 'xterm|r=s' => \$opt{xterm},
+ 'convert|C' => \$opt{convert},
);
+my @wms = qw(aewm afterstep blackbox enlightenment fbpanel fluxbox fvwm fvwm2
+ icewm metisse openbox olvwm qvwm wmaker wmaker-old xfce4 xpde);
+
if($o_help) {
+ local $" = ", ";
print<<EOF;
-Usage: $0 [options] {aewm, afterstep, blackbox, enlightenment, fbpanel, fluxbox, fvwm, fvwm2, icewm, metisse, openbox, olvwm, qvwm, wmaker, wmaker-old, xfce4, xpde}
- -h, --help - print this help
- -t, --tags - echo omitted tags to stderr
- -e, --end - echo omitted XDG file ending to stderr
- -v, --verbose - verbose stderr output
- -i, --icons - check for icons existence
- -x, --exec - check for binaries existence
- -f, --full - extend icons and binaries to full path (needs -i or -x)
- -c, --clear - remove empty menus
- -p, --promote - promote submenus with single entry
- -s, --strip - strip 1st level menu
- -u, --utf8 - output in utf8 (default is locale setting)
- -o, --output= - output in given encoding (e.g. iso-8859-2)
- -m, --nomenu - don't add additional menu info (valid for blackbox, fluxbox, openbox, xfce4)
- -r, --xterm= - set x terminal application (default "xterm -name xterm-%1 -e %2")
- example "gnome-terminal -t Terminal.%1 -x %2"
+Usage: $0 [options] {@wms}
+
+Options:
+ -h, --help - print this help
+
+ Diagnostics:
+ -t, --tags - echo omitted tags to stderr
+ -e, --end - echo omitted XDG file ending to stderr
+ -v, --verbose - verbose stderr output
+
+ Executables and icons:
+ -x, --exec - check for binaries existence
+ -X, --exec-full - extend binaries to full path (implies -x)
+ -i, --icons - add icons to menu (default: yes)
+ -I, --icons-full - check for icons existence and extend to full path
+ -S, --icons-scale - scale (shrink) icons (implies -i -I)
+ -d, --icons-dir= - output dir for icons
+
+ Output encoding:
+ -u, --utf8 - output in utf8 (default is locale setting)
+ -E, --encoding= - output in given encoding (e.g. iso-8859-2)
+
+ Menu structure:
+ -c, --clear - remove empty menus
+ -p, --promote - promote submenus with single entry
+ -s, --strip - strip 1st level menu
+ -m, --nomenu - don't add additional menu info (valid for blackbox, fluxbox, openbox, xfce4)
+
+ -r, --xterm= - set x terminal application
+ default: "$defopt{xterm}"
+ example "gnome-terminal -t Terminal.%1 -x %2"
+ -C, --convert= - command to use to scale icons
+ default: "$defopt{convert}"
+
+ Most boolean options have oposite --no-<name> version too.
+
EOF
exit;
}
-die "Missing argument {aewm, afterstep, blackbox, enlightenment, fbpanel, fluxbox, fvwm, fvwm2, icewm, metisse, openbox, olvwm, qvwm, wmaker, wmaker-old, xfce4, xpde}\n"
- unless exists $ARGV[0];
+foreach my $opt (keys %opt) {
+ $opt{$opt} = $defopt{$opt} unless defined $opt{$opt};
+ print "$opt => $opt{$opt}\n";
+}
+exit;
+
+unless (exists $ARGV[0]) {
+ local $" = ", ";
+ die "Missing argument {@wms}\n";
+}
$o_output=$ARGV[0];
die "Unrecognized argument: $o_output\n"
- unless $o_output=~/^(aewm|afterstep|blackbox|enlightenment|fbpanel|fluxbox|fvwm|fvwm2|icewm|metisse|openbox|olvwm|qvwm|wmaker|wmaker-old|xfce4|xpde)$/;
+ unless grep { $o_output eq $_ } @wms;
$opt{full}=1 if $opt{icons} and $o_output=~/^(enlightenment|metisse)$/;
# header }}}
@@ -125,7 +172,7 @@
}
# search dirs }}}
-# get locale (for Name[*])
+# get locale (for Name[*]) {{{
my @lang;
sub addlang {
my $l = $_[0];
@@ -153,7 +200,7 @@
return 1 if $b eq "Name[$lang]";
}
return 0;
-}
+} # }}}
# what is $DESKTOP_FILE_PATH?
@@ -825,7 +872,7 @@
$name = $$d[1];
$name =~ s/\"/\\\"/g;
$apps .= qq(\tExec "$name"\texec $$d[3]\n);
- } else {
+ } else {
$name = $$d[0];
$name =~ s/\s+/_/g;
$this_menu .= qq(\tPopup "$$d[1]"\t$file.$name\n);
@@ -1112,7 +1159,6 @@
fvwm2($opt{strip});
exit;
}
-
if($o_output eq "metisse") {
$icon_dir="$ENV{'HOME'}/.fvwm-metisse/icons";
if(! -d "$icon_dir") {
@@ -1124,7 +1170,6 @@
metisse($opt{strip},"", "metisse");
exit;
}
-
if($o_output eq "olvwm") {
olvwm($opt{strip});
exit;
================================================================
---- CVS-web:
http://cvs.pld-linux.org/vfmg/vfmg?r1=1.73.2.14&r2=1.73.2.15&f=u
More information about the pld-cvs-commit
mailing list