Hi,
I'm wondering if there is any interest in a little patch at the
fvwm-menu-directory.

An additional command line what should define with what kind of a
program files with specific endings should get opened.

the additional command line option would look like this:

exec-gen="xv=jpg|jpeg,mplayer=mov|mpg|mpeg,xmms=mp3"

that would mean, xv should open all endings: jpg, jpeg, 
                 mplayer should open endings: mov, mpg, mpeg and
                 xmms should be used to open mp3 files.

for personal use this would be already enough for me actually,
but when this would be interesting to enhance ( icons ), i could
do it as well.

Actually a quick hack with special markings to see where i hacked
around. I'm not really a perl programmer, but I hope it's all ok anyway.

--- /usr/local/bin/fvwm-menu-directory2	2004-02-15 19:45:48.000000000 +0100
+++ /usr/local/bin/fvwm-menu-directory	2004-02-27 11:26:25.000000000 +0100
@@ -26,6 +26,10 @@
 my $execT = $ENV{'SHELL'} || '/bin/sh';
 my $execF = $ENV{'EDITOR'} || "vi";  # the command to execute on plain files
 my $execA = undef;
+### calmar hacked here ###
+my $extGen = "xv=jpg|jpeg,mplayer=mov|mpg|mpeg,xmms=mp3";
+my $commGen = undef;
+#######################
 my $commT = undef;
 my $commF = undef;
 my $commA = undef;
@@ -61,6 +65,10 @@
 	"exec-title=s" => \$execT,
 	"exec-file=s"  => \$execF,
 	"exec-app:s"   => \$execA,
+### calmar hacked here ###
+        "exec-gen=s"       => \$extGen,
+#######################
+
 	"command-title=s" => \$commT,
 	"command-file=s"  => \$commF,
 	"command-app=s"   => \$commA,
@@ -140,7 +148,6 @@
 $commT = defined $execT? qq(Exec cd "%d"; $execT): "Nop" if !defined $commT;
 $commF = defined $execF? qq(Exec $execF "%f"):     "Nop" if !defined $commF;
 $commA = defined $execA? qq(Exec $execA "%f"):    $commF if !defined $commA;
-
 # manage special directories if needed
 my ($specialDirLines, $specialDirPos, @specialDirs) = ("");
 $specialDirVal = "1,2" if defined $specialDirVal && $specialDirVal eq "";
@@ -207,6 +214,29 @@
 # add special dirs at the top if needed
 print qq($specialDirLines+ "" Nop\n) if $specialDirPos > 0;
 
+### calmar hacked here ###
+# puts strings like this: gimp=jpg|jpeg|png,emacs=c|cc|h 
+# into an hash: --> may uncomment foreach loop below to see output
+	   
+	     my %extHash;
+	     my $prog;
+	     my $ext;
+	     my $rest;
+
+	     foreach (split (/,/,$extGen)) {
+		 ($prog, $rest) = split ( /=/, $_ , 2);
+		 foreach $ext ( split (/\|/, $rest)) { 
+		     $extHash{$ext} =  $prog ;
+		     print qq($ext -> $prog\n);
+		 }
+	     }
+
+#	     foreach $ext ( keys %extHash ) {
+#		 print "$ext: $extHash{$ext}\n";
+#	     }
+
+######################
+
 # add directory contents
 foreach (@files) {
 	next if $_ eq '.' or $_ eq '..';
@@ -222,6 +252,15 @@
 		my $isApp = -x && -f;
 		my $iconStr = $isApp && $iconAStr? $iconAStr: $iconFStr;
 		my $fileAct = $isApp? $commA: $commF;
+### calmar hacked here ### 
+# overwrite $fileAct when the file ending and the program are in @extHash
+	        my $fileEnd = lc(); #lowercase $_ 
+                $fileEnd =~ s|.*\.||; # get ending
+		if  ($extHash{$fileEnd}) {
+		    $commGen =  $extHash{$fileEnd};
+		    $fileAct = qq(Exec $commGen "%f");
+		}
+#######################
 		$fileAct =~ s/%f/&escapeFileName($filePath)/ge;
 		print qq(+ "$iconStr$itemStr" $fileAct\n);
 	}
Greetings
marco candrian

-- 
  calmar 
           (o_         GNU/Linux is GREAT      
           //\                 
           V_/_        http://www.calmar.ws 
                                          

Reply via email to