vfmg (DEVEL): vfmg - two new options: --destdir= and --full-regen

sparky sparky at pld-linux.org
Tue Nov 1 12:40:56 CET 2005


Author: sparky                       Date: Tue Nov  1 11:40:56 2005 GMT
Module: vfmg                          Tag: DEVEL
---- Log message:
- two new options: --destdir= and --full-regen

---- Files affected:
vfmg:
   vfmg (1.73.2.20 -> 1.73.2.21) 

---- Diffs:

================================================================
Index: vfmg/vfmg
diff -u vfmg/vfmg:1.73.2.20 vfmg/vfmg:1.73.2.21
--- vfmg/vfmg:1.73.2.20	Tue Nov  1 04:20:49 2005
+++ vfmg/vfmg	Tue Nov  1 12:40:51 2005
@@ -29,11 +29,20 @@
 	nomenu		=> 0,
 	xterm		=> "xterm -name xterm-%1 -e %2",
 	convert		=> "convert -geometry 16x16 \%in \%out",
+	full_regen	=> 0,
+	destdir		=> "",
+	
 );
 my %opt;
 my $o_output;
 $defopt{xterm}="$ENV{'VFMG_TERM'}" if $ENV{'VFMG_TERM'};
 
+my %destdir = (
+	afterstep		=>	"$ENV{'HOME'}/GNUstep/Library/AfterStep/start",
+	enlightenment	=>	"$ENV{'HOME'}/.enlightenment/menus",
+	xpde			=>	"$ENV{'HOME'}/.xpde/Start Menu/Programs",
+);
+
 Getopt::Long::Configure("bundling");
 GetOptions(
 	'help|h'		=>	\$o_help,
@@ -58,6 +67,8 @@
 	'nomenu|m!'		=>	\$opt{nomenu},
 	'xterm|r=s'		=>	\$opt{xterm},
 	'convert|C=s'	=>	\$opt{convert},
+	'full-regen|f!'	=>	\$opt{full_regen},
+	'destdir|D=s'	=>	\$opt{destdir},
 	);
 
 my @wms = qw(aewm afterstep blackbox enlightenment fbpanel fluxbox fvwm fvwm2
@@ -102,6 +113,13 @@
     -C, --convert= - command to use to scale icons
                      default: "$defopt{convert}"
 
+    -f, --full-regen - regenerate everything (delete scaled icons)
+    -D, --destdir=   - directory to seve multifile menu
+EOF
+	print "                       (used in: ",
+		(join ", ", sort keys %destdir), ")\n";
+	print<<EOF;
+
   Most boolean options have oposite --no-<name> version too.
 
 EOF
@@ -164,6 +182,11 @@
 	}
 }
 $opt{encoding}="utf8" if $opt{utf};
+if ( grep { $o_output eq $_ } keys %destdir ) {
+	$opt{destdir} = $destdir{$o_output} unless (length $opt{destdir});
+} else {
+	delete $opt{destdir};
+}
 # header }}}
 
 # search dirs {{{
@@ -1053,7 +1076,7 @@
 sub enlightenment { # {{{
 	my ($no, $mfile, $title)=@_;
 	my $F_OUT;
-	open $F_OUT, ">> $dir/$mfile.menu" or warn "$dir/$mfile.menu: $!\n";
+	open $F_OUT, ">> $opt{destdir}/$mfile.menu" or warn "$opt{destdir}/$mfile.menu: $!\n";
 	print $F_OUT qq("$title"\n);
 	my $apps="";
 	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
@@ -1065,7 +1088,7 @@
 		if($menu[$no]{$entry}<0) {
 			$apps .= qq("$name" "$icon" exec "$$d[EXEC]"\n);
 		} else {
-			print $F_OUT qq("$name" "$icon" menu "$dir/$$d[FILENAME].menu"\n);
+			print $F_OUT qq("$name" "$icon" menu "$opt{destdir}/$$d[FILENAME].menu"\n);
 			enlightenment($menu[$no]{$entry},$$d[FILENAME],$name);
 		}
 	}
@@ -1155,13 +1178,23 @@
 binmode STDOUT, ":encoding($opt{encoding})";
 
 if ($opt{icons_scale}) {
-	unless (-d $opt{icons_dir}) { # must be set
+	if (not -d $opt{icons_dir} or $opt{full_regen}) {
+		warn "Nead to generate all icons.\n";
 		require File::Path;
-		import File::Path qw(mkpath);
-		rename($opt{icons_dir},$opt{icons_dir}.".old") if -f $opt{icons_dir};
+		import File::Path qw(mkpath rmtree);
+		rmtree($opt{icons_dir}.".old",0,0) if -e $opt{icons_dir}.".old";
+		rename($opt{icons_dir},$opt{icons_dir}.".old") if -e $opt{icons_dir};
 		mkpath($opt{icons_dir},0,0700);
 	}
 }
+if (exists $opt{destdir}) {
+	warn "Multi file output.\n";
+	require File::Path;
+	import File::Path qw(mkpath rmtree);
+	rmtree($opt{destdir}.".old",0,0) if -e $opt{destdir}.".old";
+	rename($opt{destdir},$opt{destdir}.".old") if -e $opt{destdir};
+	mkpath($opt{destdir},0,0700);
+}
 
 # WM case {{{
 if($o_output eq "icewm") {
@@ -1195,23 +1228,10 @@
 	print "</xfdesktop-menu>\n";
 	exit;
 }
-if($o_output eq "afterstep") { # {{{
-	require File::Path;
-	import File::Path qw(mkpath rmtree);
-	my $dir="$ENV{'HOME'}/GNUstep/Library/AfterStep/start";
-	if((-d "$dir")||(-f "$dir")) {
-		rmtree("$dir.old",0,0);
-		rename("$dir","$dir.old");
-		mkpath("$dir",0,0700);
-		#open F_OUT, ">> $dir/\.include" or warn "$dir/.include: $!\n";
-		#print F_OUT "keepname\ninclude \"../start.old\"\n";
-		#close F_OUT;
-	} else {
-		mkpath("$dir",0,0700);
-	}
-	afterstep($opt{strip},$dir);
+if($o_output eq "afterstep") {
+	afterstep($opt{strip},$opt{destdir});
 	exit;
-} # }}}
+}
 if($o_output eq "fvwm") {
 	fvwm($opt{strip},"", "fvwm");
 	exit;
@@ -1245,29 +1265,13 @@
 	exit;
 }
 if($o_output eq "enlightenment") {
-	require File::Path;
-	import File::Path qw(mkpath rmtree);
-	$dir="$ENV{'HOME'}/.enlightenment/menus";
-	if((-d "$dir")||(-f "$dir")) {
-		rmtree("$dir.old",0,0);
-		rename("$dir","$dir.old");
-	}
-	mkpath("$dir",0,0700);	# or die
 	enlightenment($opt{strip},"index","Enlightenment");
 	exit;
 }
-if($o_output eq "xpde") { # {{{
-	require File::Path;
-	import File::Path qw(mkpath rmtree);
-	my $dir="$ENV{'HOME'}/.xpde/Start Menu/Programs";
-	if ( (-d $dir) or (-f $dir) ) {
-		rmtree("$dir.old",0,0);
-		rename($dir,"$dir.old");
-	}
-	mkpath($dir,0,0700);
-	xpde($opt{strip},$dir);
+if($o_output eq "xpde") {
+	xpde($opt{strip},$opt{destdir});
 	exit;
-} # }}}
+}
 if($o_output eq "fbpanel") {
 	fbpanel($opt{strip});
 	exit;
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/vfmg/vfmg?r1=1.73.2.20&r2=1.73.2.21&f=u




More information about the pld-cvs-commit mailing list