vfmg: vfmg - cleanups and small changes

sparky sparky at pld-linux.org
Fri Dec 1 20:42:25 CET 2006


Author: sparky                       Date: Fri Dec  1 19:42:25 2006 GMT
Module: vfmg                          Tag: HEAD
---- Log message:
- cleanups and small changes

---- Files affected:
vfmg:
   vfmg (1.97 -> 1.98) 

---- Diffs:

================================================================
Index: vfmg/vfmg
diff -u vfmg/vfmg:1.97 vfmg/vfmg:1.98
--- vfmg/vfmg:1.97	Wed Jul 19 03:58:53 2006
+++ vfmg/vfmg	Fri Dec  1 20:42:20 2006
@@ -64,47 +64,44 @@
 # }}}
 
 GetOptions( # {{{
-	'help|h'		=>	\$o_help,
-	'version|V'		=>	\$o_version,
-	'tags|t'		=>	\$o_tags,
-	'end|e'			=>	\$o_end,
-	'verbose|v'		=>	\$o_verbose,
+	'help|h'			=>	\$o_help,
+	'version|V'			=>	\$o_version,
+	'tags|t'			=>	\$o_tags,
+	'end|e'				=>	\$o_end,
+	'verbose|v'			=>	\$o_verbose,
 	
-	'exec|x!'		=>	\$opt{exec},
+	'exec|x!'			=>	\$opt{exec},
 	'exec-full|full-exec|X!'
-					=>	\$opt{exec_full},
-	'icons|i!'		=>	\$opt{icons},
-	'icons-ext|T!'	=>	\$opt{icons_ext},
+						=>	\$opt{exec_full},
+	'icons|i!'			=>	\$opt{icons},
+	'icons-ext|T!'		=>	\$opt{icons_ext},
 	'icons-full|full-icons|I!'	
-					=>	\$opt{icons_full},
+						=>	\$opt{icons_full},
 	'icons-scale|scale-icons|S!'
-					=>	\$opt{icons_scale},
-	'icons-fork!'	=>	\$opt{icons_fork},
-	'icons-dir|d=s'	=>	\$opt{icons_dir},
-	'icons-oext|O=s'
-					=>	\$opt{icons_oext},
-	'text-icon=s'	=>	\$opt{text_icon},
+						=>	\$opt{icons_scale},
+	'icons-fork!'		=>	\$opt{icons_fork},
+	'icons-dir|d=s'		=>	\$opt{icons_dir},
+	'icons-oext|O=s'	=>	\$opt{icons_oext},
+	'text-icon=s'		=>	\$opt{text_icon},
 	
-	'wcnt-file=s'	=>	\$opt{wcnt_file},
-	'termapp-class=s'
-					=>	\$opt{termapp_class},
-	'termapp-name=s'
-					=>	\$opt{termapp_name},
+	'wcnt-file=s'		=>	\$opt{wcnt_file},
+	'termapp-class=s'	=>	\$opt{termapp_class},
+	'termapp-name=s'	=>	\$opt{termapp_name},
 
 
-	'utf8|u!'		=>	\$opt{utf},
-	'encoding|E=s'	=>	\$opt{encoding},
+	'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},
-	'only-in|o=s'	=>	\$opt{only_in},
+	'clear|c!'			=>	\$opt{clear},
+	'promote|p!'		=>	\$opt{promote},
+	'strip|s!'			=>	\$opt{strip},
+	'nomenu|m!'			=>	\$opt{nomenu},
+	'only-in|o=s'		=>	\$opt{only_in},
 	
-	'xterm|r=s'		=>	\$opt{xterm},
-	'convert|C=s'	=>	\$opt{convert},
-	'full-regen|f!'	=>	\$opt{full_regen},
-	'destdir|D=s'	=>	\$opt{destdir},
+	'xterm|r=s'			=>	\$opt{xterm},
+	'convert|C=s'		=>	\$opt{convert},
+	'full-regen|f!'		=>	\$opt{full_regen},
+	'destdir|D=s'		=>	\$opt{destdir},
 	); # }}}
 
 if($o_help) { # {{{
@@ -153,10 +150,6 @@
 
     -f, --full-regen - regenerate everything (delete scaled icons)
     -D, --destdir=   - directory to save multifile menu
-EOF
-	print "                       (used in: ",
-		(join ", ", sort keys %destdir), ")\n";
-	print<<EOF;
 
   All but diagnostics boolean options have oposite --no-<name> version too.
 
@@ -180,12 +173,11 @@
 	unless grep { $o_output eq $_ } @wms;
 
 # vfmgrc {{{
-my @rcFiles = (qw(/etc/vfmgrc), "$ENV{'HOME'}/.vfmgrc");
+my @rcFiles = ("/etc/vfmgrc", "$ENV{'HOME'}/.vfmgrc");
 push @rcFiles, "$ENV{'HOME_ETC'}/.vfmgrc" if exists $ENV{'HOME_ETC'};
- at rcFiles = grep -r, @rcFiles;
 
 my @rcBody;
-foreach my $rc (@rcFiles) {
+foreach my $rc (grep -r, @rcFiles) {
 	open F_IN, $rc or next;
 	my $read = 1;
 	while (<F_IN>) {
@@ -238,11 +230,9 @@
 } else {
 	delete $opt{destdir};
 }
-my @OSI_accept;
+my %OSI_accept;
 if ( defined $opt{only_in} ) {
-	foreach my $cat ( split /[,\s]+/, $opt{only_in} ) {
-		push @OSI_accept, $cat;
-	}
+	%OSI_accept = map {($_, 1)} split /[,\s]+/, $opt{only_in};
 }
 # header }}}
 
@@ -280,20 +270,20 @@
 
 my @path;
 if ( $opt{exec} ) {
-	@path=(grep (-d, split(/:+/,$ENV{'PATH'})), "");
+	@path = (grep (-d, split(/:+/,$ENV{'PATH'})), "");
 	if( length $opt{xterm} ) {
-		my $exists=0;
-		my $bin=$opt{xterm};
-		$bin=~s/(\S+).*/$1/;  #v---------v
-		foreach my $dir(@path) {	 # would be "//dir/.../file" correct?
-			if (-x "$dir/$bin") {#----^
-				$exists=1;
-				$opt{xterm}="$dir/$opt{xterm}" if $opt{exec_full};
+		my $exists = 0;
+		my $bin = $opt{xterm};
+		$bin =~ s/(\S+).*/$1/;
+		foreach my $dir (@path) {
+			if (-x "$dir/$bin") {
+				$exists = 1;
+				$opt{xterm} = "$dir/$opt{xterm}" if $opt{exec_full};
 				last;
 			}
 		}
 		unless ($exists) {
-			$opt{xterm}="";
+			$opt{xterm} = "";
 			warn "Can't find $bin.",
 				" Terminal applications will not be included.\n";
 		}
@@ -365,22 +355,19 @@
 	return unless lc $tags{Type} eq 'application';
 	return if lc $tags{NoDisplay} eq 'true';
 	if ( defined $tags{OnlyShowIn} ) {
-		my $found = 0;
-		foreach my $cat ( split /;+/, $tags{OnlyShowIn} ) {
-			$found++ if grep {$cat eq $_} @OSI_accept;
-		}
-		return unless $found;
+		return unless
+			grep {exists $OSI_accept{$_}} split /;+/, $tags{OnlyShowIn};
 	}
 	  
 	$tags{term} =
 	  ($tags{Terminal} && $tags{Terminal} =~ /^(?:1|true)$/i) ? 1 : 0;
 	return if $tags{term} and not $opt{xterm};
 
-	($tags{bin}) = ($tags{Exec} =~ /(\S+)/);    #v---------v
+	($tags{bin}) = ($tags{Exec} =~ /(\S+)/);
 	if ( $opt{exec} ) {
-		my $exists;
-		foreach my $dir (@path) {    # would be "//dir/.../file" correct?
-			if (-x "$dir/$tags{bin}") {    #----^
+		my $exists = 0;
+		foreach my $dir (@path) {
+			if (-x "$dir/$tags{bin}") {
 				$exists++;
 				$tags{Exec} = "$dir/$tags{Exec}" if $opt{exec_full};
 				last;
@@ -389,10 +376,10 @@
 		return unless $exists;
 	}
 	if ( $tags{term} ) {
-		$tags{bin} =~ s|.*/||;
+		$tags{bin} =~ s#.*/##;
 		$_ = $opt{xterm};
-		s/%1/$tags{bin}/;
-		s/%2/$tags{Exec}/;
+		s/%1/$tags{bin}/g;
+		s/%2/$tags{Exec}/g;
 		$tags{Exec} = $_;
 	}
 	if ( $opt{icons_ext} ) {
================================================================

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



More information about the pld-cvs-commit mailing list