4 # Convert .fvwm2rc from 2.2.x format to 2.4.x format.
6 # Originally written by Dan Espen <despen@telcordia.com> Sept 2000
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ($source,$dest) = @ARGV;
24 $source = "$ENV{'HOME'}/.fvwm2rc";
27 die "Can't find source file $source, giving up.\n";
31 $dest = "$ENV{'HOME'}/.fvwm/.fvwm2rc";
33 $dest2 = "$dest.pass1";
35 die "Output file $dest already exists, exiting.\n";
38 die "Output file $dest2 already exists, exiting.\n";
40 system "cp -p $source $dest 2>/dev/null"; # try to preserve permissions
41 system "cp -p $source $dest2 2>/dev/null"; # try to preserve permissions
43 $[ = 1; # set array base to 1
44 $, = ' '; # set output field separator
45 $\ = "\n"; # set output record separator
47 # GlobalOpts that became Styles:
48 %OPTS = ('SMARTPLACEMENTISREALLYSMART','MinOverlapPlacement',
49 'SMARTPLACEMENTISNORMAL','TileCascadePlacement',
50 'ACTIVEPLACEMENTHONORSSTARTSONPAGE',
51 'ManualPlacementHonorsStartsOnPage',
52 'ACTIVEPLACEMENTIGNORESSTARTSONPAGE',
53 'ManualPlacementIgnoresStartsOnPage',
54 'CLICKTOFOCUSDOESNTPASSCLICK', 'ClickToFocusPassesClickOff',
55 'CLICKTOFOCUSDOESNTRAISE', 'ClickToFocusRaisesOff',
56 'MOUSEFOCUSCLICKDOESNTRAISE', 'MouseFocusClickRaisesOff',
57 'NOSTIPLEDTITLES', 'StippledTitleOff',
58 'STIPLEDTITLES', 'StippledTitle');
60 # GlobalOpts that became BugOpts:
61 %BUGOPTS= ('RAISEOVERNATIVEWINDOWS','RaiseOverNativeWindows on',
62 'IGNORENATIVEWINDOWS','RaiseOverNativeWindows off');
64 print "Input from $source, output to $dest\n";
65 parse_pass($source, $dest2, 1);
66 parse_pass($dest2, $dest, 2);
72 local($sourcefile, $destfile, $pass) = @_;
74 open(IN, $sourcefile) || die "Can't open $source";
75 open(STDOUT, ">$destfile") || die "Can't redirect stdout to $dest2";
77 print '# This file changed by the .fvwm2rc to .fvwm/.fvwm2rc converter';
79 # create assoc array by imagepath:
80 $imagepath = '@FVWM_IMAGEPATH@';
81 $isize = (@iarray = split(/:/, $imagepath, 9999));
82 for ($i = 1; $i <= $isize; ++$i) {
83 $iassoc{$iarray[$i]} = '1';
87 $commchar="#"; # help un-confuse emacs.
88 line: while ( <IN> ) {
89 chomp; # strip record separator
90 @Fld = split(' ', $_, 9999);
91 if (/^\s*[$commchar]/) { # Comment, pass it thru
94 while (substr($line, length($line), 1) eq "\\") { # backslashed lines
101 if (/^\s*$/) { # Empty line, pass it thru
106 $lastwarn = $newwarn;
109 # Adds "path" to "newpath":
110 if (/^\s*ICONPATH|^\s*PIXMAPPATH/i) { # Fix up IconPath/PixmapPath:
112 &add_to_path($Fld[2]);
114 # prime possible loop
115 while (substr($line, length($line), 1) eq "\\") {
119 if ($newpath eq '') {
121 '# To use your own icons, uncomment and change the next line';
122 print "#ImagePath \$HOME/icons:+";
125 print 'ImagePath ' . $newpath . ':+';
130 # Change GlobOpts to "Style * xxx, ..." commands
131 if (/^\s*globalopts/i) { # Fix up GlobalOpts:
133 @rest=@Fld; # copy the whole line
134 shift @rest; # remove first element
135 &add_to_opts(join($",@rest)); # pass rest of line
136 $line = $_; # prime possible loop
137 while (substr($line, length($line), 1) eq "\\") { # backslashed lines
139 &add_to_opts($line); # build up newopts
141 if ($newopts eq '') {
142 next line; # GlobalOpts without argument, drop silently
145 print 'Style "*" ' . $newopts; # print as style command
150 if (/^\s*MODULEPATH/i) {
151 # Deletes continuation lines too, although if there are
152 # continuation lines, there might be some part of the path we want to
153 # Delete them anyway.
154 print '# Removed by fvwm-convert-2.4: ' . $_;
155 while (substr($_, length($_), 1) eq "\\") {
157 print '# Removed by fvwm-convert-2.4: ' . $_;
165 # collect continuation lines
166 while (substr($line, length($line), 1) eq "\\") { # backslashed lines
167 $old_line = substr($line, 1, length($line) - 1);
168 $new_line = &Getline1();
169 $single_lines = "$single_lines\n$new_line";
170 $line = "$old_line$new_line";
175 if (/^\s*HILIGHTCOLOR\s/i) {
176 @colors = split("/", $Fld[2], 9999);
177 if ($colors[2] eq '') {
178 $colors[1] = $Fld[2];
179 $colors[2] = $Fld[3];
181 print "Style \"*\" HilightFore " . $colors[1] . ', HilightBack ' .
186 if (/^\s*HILIGHTCOLORSET/i) {
187 print "Style \"*\" HilightColorset " . $Fld[2];
191 if (/^\s*WINDOWSHADEANIMATE/i) {
192 print "Style \"*\" WindowShadeSteps " . $Fld[2];
196 if (/^\s*WINDOWFONT/i) {
197 print "Style \"*\" Font " . $Fld[2];
201 if (/^\s*ICONFONT/i) {
202 print "Style \"*\" IconFont " . $Fld[2];
206 if (/^\s*COLORLIMIT/i) {
207 print '# Removed by fvwm-convert-2.4: ' . $_;
211 # generate warnings in pass 2 only
213 if (/^\s*[*].+PANEL/i) {
214 if ($lastwarn ne "panel") {
215 print STDERR "Possible old style FvwmButtons Panel definition found";
217 " See FvwmButtons(1), \"CONVERTING OLD PANEL CONFIGURATIONS\"";
226 if ($lastwarn ne "read") {
228 "Read command found, file(s) must be converted in a separate run:";
237 print STDERR "The FvwmConfig module is no longer part of fvwm:";
239 if (/^\s*[*]?\s*FvwmConfig/i) {
240 print STDERR " Line commented out.";
241 print '# Removed by fvwm-convert-2.4: ' . $_;
251 print STDERR "The FvwmPipe module is no longer part of fvwm:";
253 if (/^\s*[*]?\s*FvwmPipe/i) {
254 print STDERR " Line commented out.";
255 print '# Removed by fvwm-convert-2.4: ' . $_;
262 if (/RANDOMPLACEMENT|ACTIVEPLACEMENT|SMARTPLACEMENT/i ||
263 /DUMBPLACEMENT|CLEVERPLACEMENT/i) {
264 $newwarn = "placement";
265 if ($lastwarn ne $newwarn) {
267 "Placement style names can not be converted automatically:";
269 " See fvwm(1), \"Window manager placement\" for instructions.";
273 $newwarn = "placement";
278 print $single_lines; # pass everything else thru
296 $psize = (@parray = split(/:/, $path, 9999));
298 for ($i = 1; $i <= $psize; ++$i) {
299 # Drop any builtin imagepath:
300 if ($iassoc{$parray[$i]} eq '1') {
303 if ($parray[$i] eq "\\") {
307 # Maybe this next line should only skip files starting with $,
308 # that dont start with $HOME.
309 if (substr($parray[$i], 1, 1) eq "\$") {
313 if ($newpath eq '') {
314 $newpath = $parray[$i];
317 $newpath = $newpath . ':' . $parray[$i];
322 # take one GlobalOpt and convert it to a style argument -or-
323 # just print any bugOpts
326 $psize = (@parray = split(/[ ,\t]/, $opts, 9999));
328 for ($i = 1; $i <= $psize; ++$i) {
329 if ($parray[$i] eq "\\") {
332 if ($parray[$i] eq "") {
337 # Some args are the same in a style command
338 # Some are changed a little,
339 # the native window stuff becomes a BugOpt
341 $work = $parray[$i]; # init w. unconverted arg
342 $uwork = uc $work; # uppercase version for lookup
343 $newStyleArg = $OPTS{$uwork}; # do conversion using hash
344 if ($newStyleArg ne '') { # if arg got converted
345 $work = $newStyleArg; # save new arg
348 $bugArg = $BUGOPTS{$uwork}; # convert using hash
349 if ($bugArg ne '') { # if converted
350 print 'BugOpts ' . $bugArg;
351 } else { # if not bugOpt, accum
352 if ($newopts eq '') { # first time, just arg
355 $newopts = $newopts . ', ' . $work; # add comma and arg
357 } # end bugArg vs. style
363 if ($getline_ok = (($_ = <IN>) ne '')) {
364 chomp; # strip record separator