#! /usr/bin/perl -w use strict; ## author: parv(at)pair(dot)com ## date: aug 31 2001 ## ## license: free to use as you please w/ credit given ## ## script name: menu-vtwm2fvwm2 ## ## purpose: ## this program/script simple mindedly takes a file containing only ## vtwm-style menus and changes them to fvwm2-style menu ## ## usage: ## menu-vtwm2fvwm2 file ## ## miscellaneous: ## other things to add: function change, and keybindings. sometime. die &err_msg("no file specified.") unless (defined $ARGV[0]); die &err_msg("file \"$ARGV[0]\" doesn't exist or isn't a text file.") if !(-f $ARGV[0] && -T $ARGV[0]); use Fcntl ':flock'; my $vtwm = $ARGV[0]; my $fvwm2 = $vtwm . '.fvwm2'; print "new file will be: $fvwm2\n"; open (VTWM, "< $vtwm") || die "cannot open $vtwm to read: $!"; flock VTWM, LOCK_EX; open (FVWM2, "> $fvwm2") || die "cannot open $fvwm2 to write: $!"; flock FVWM2, LOCK_EX; while () { # obliterate {, } s#[\}\{]##g; s#^\s*menu(\s+)#AddToMenu$1#i; # change f.separator/f.nop to Nop s#^(\s*\".*\"\s+)f\.(?:separator|nop)$#+$1 \uNop#i; # remove 2d pair of quotes s!(\w+\s+)\"(.+\&)\"!$1$2!; # change f.menu to Popup s#^(\s*\".*\"\s+)f\.menu(.+)$#+$1Popup$2#i; # change f.xyz to Xyz s#^(\s*\".+\"\s+)f\.(.+)$#+$1 \u$2#i; # blast empty lines s#^\s*$##sg; print FVWM2; } flock FVWM2, LOCK_UN; close FVWM2 || die "couldnot close $fvwm2: $!"; flock VTWM, LOCK_UN; close VTWM || die "couldnot close $vtwm: $!"; print "...done\n"; sub err_msg { print "\n$_[0]\n\n"; return "- supply a valid text file containing vtwm-style menus.\n- file is assumed to contain only vtwm menus.\n- usage:\n\t$0 /path/to/vtwm-menu\n"; }