--- /usr/bin/freedesktop2menu.pl 2004-05-14 14:24:18 +0700 +++ /usr/bin/freedesktop2menu.pl 2005-09-13 16:34:40 +0700 @@ -13,8 +13,10 @@ # and to support .directory files # modified by Frederic Crozat Aug 07 2001 use new mimetype keyword for Mdk 8.1 # modified by Laurent Montel Fri Aug 10 2001 init icon variable some desktop -# modified by Sergey V Turchin Tue Mar 9 2004 to adopt for freedesktop -# file doesn't have icon +# modified by Sergey V Turchin Tue Mar 9 2004 to +# adopt for freedesktop file doesn't have icon +# modified by php-coder Tue Sep 13 2005 to +# small fixes and changed output format (($#ARGV == 3) or ($#ARGV == 4) or ($#ARGV == 5)) or die "E: You gave me $#ARGV parameters. This script must be invoked with parameters:
[requires] [title]\n"; @@ -32,15 +34,15 @@ ($requires eq "text") or ($requires eq "x11") or ($requires eq "kde") or ($requires eq "gnome") or print "W: requires is $requires (e.g. not text nor x11 nor kde nor gnome)\n"; my $debug = 1; -open (MDKVERSION,"/etc/altlinux-release") or die "Can't open /etc/altlinux-release"; -while () +open (ALTVERSION,"/etc/altlinux-release") or die "Can't open /etc/altlinux-release"; +while () { chomp; if (/\S+\s+\S+\s+\S+\s+(\S+)/) { $mdk_version = $1; } } -close (MDKVERSION); +close (ALTVERSION); open (INPUT, $ARGV[2]) or die "Can't open $ARGV[2]!\n"; open (OUTPUT, ">$ARGV[3]") or die "Can't open $ARGV[3]!\n"; @@ -49,7 +51,7 @@ next if (/^\s*#/); # Ignore comments next if (/^\s*$/); # Ignore void lines chomp; # Remove trailing slash - if (m/^([^=]+)\s*=(.*)/) # Line of the form Key = Value ? + if (m/^([^=]+)\s*=(.+)/) # Line of the form Key = Value ? { $key = $1; $value = $2; @@ -125,7 +127,7 @@ # if ($mdk_version >= 8.1) { if (1) { $_ = $command; - if ( $requires == "text" or $requires == "x11" ) { + if ( $requires eq "text" or $requires eq "x11" ) { if (/.*%u.*/) { $accept_url = "true"; $multiple_files = "false"; @@ -167,20 +169,16 @@ } # Ok, we've got all the info, write the menu file. -print OUTPUT "?package($package_name): needs=\"$requires\" extra_filename=\"$extra_filename\" section=\"$section\"". - " title=\"$name\" icon=\"$icon.png\""; -defined $command and print OUTPUT " command=\"$command\""; -defined $command and print OUTPUT " genericname=\"$genericname\""; -defined $comment and print OUTPUT " longtitle=\"$comment\""; -#if ($mdk_version >= 8.1) { -if (1) { - defined $mimetype and print OUTPUT " mimetypes=\"$mimetype\""; - defined $command and print OUTPUT " hints=\"$hint\""; - defined $multiple_files and print OUTPUT " multiple_files=\"$multiple_files\""; - defined $accept_url and print OUTPUT " accept_url=\"$accept_url\""; -} -else { - defined $mimetype and print OUTPUT " extra_mimetype=\"$mimetype\""; -} -print OUTPUT " extra_opt=\"$extra_opt\""; +print OUTPUT "?package($package_name):\\\n\tneeds=\"$requires\" \\\n\textra_filename=\"$extra_filename\" \\\n\tsection=\"$section\" \\\n\ttitle=\"$name\" \\\n"; +defined $icon and print OUTPUT "\ticon=\"$icon.png\" \\\n"; +defined $command and print OUTPUT "\tcommand=\"$command\" \\\n"; +defined $genericname print OUTPUT "\tgenericname=\"$genericname\" \\\n"; +defined $comment and print OUTPUT "\tlongtitle=\"$comment\" \\\n"; +defined $mimetype and print OUTPUT "\tmimetypes=\"$mimetype\" \\\n"; +defined $command and print OUTPUT "\thints=\"$hint\" \\\n"; +defined $multiple_files and print OUTPUT "\tmultiple_files=\"$multiple_files\" \\\n"; +defined $accept_url and print OUTPUT "\taccept_url=\"$accept_url\" \\\n"; +defined $mimetype and print OUTPUT "\textra_mimetype=\"$mimetype\" \\\n"; + +print OUTPUT "\textra_opt=\"$extra_opt\""; close(OUTPUT);