3 # Some time ago, Martin Kraemer <Martin.Kraemer@mch.sni.de> posted an
4 # incomplete script to convert fvwm-1 'rc' files to fvwm-2. I've just
5 # recently fixed and enhanced that script; it's complete (or nearly
6 # so) now. This should help if you choose to convert.
8 # I've also made a couple of other minor changes to make life easier
9 # for our users here: I changed the default initialization from "Read
10 # .fvwmrc" to "Read .fvwm2rc" (in fvwm/fvwmc), and I installed fvwm 2
11 # as "fvwm2". With these changes, users can easily convert at their
14 # Herewith the script. It's using GNU awk (gawk), but will run with
15 # any "new" awk (nawk on Suns (SunOS 4, Solaris), awk on most other
16 # systems). If you do not use gawk, it will be case-sensitive (the
17 # case of the fvwm commands must match those in the script
18 # exactly). With gawk, it'll be case-insensitive.
20 # It's not perfect: some old commands slip through, especially in the
21 # context of Mouse and Key commands. But it provides a good basis on
22 # which to go further.
25 # Convert fvwm 1.x configuration file to 2.2 configuration file
27 # Originally written by Martin Kraemer <Martin.Kraemer@mch.sni.de>
28 # Corrected, extended, and modified by Grant McDorman <grant@isgtec.com>
30 # Additional corrections and extensions by Bill Oswald <wamo@vnet.ibm.com>
31 # 8 Mar 96 thru 18 Jul 96
32 # Minor corrections to make it easier to customize by Charles Hines 08/01/96
33 # Further minor corrections by Julian Gilbey <jdg@debian.org> based on those
34 # of Austin Donnelly <and1000@debian.org>, 1 Mar 1999
35 # Further major corrections by Julian Gilbey <jdg@debian.org>, 3 Mar 1999
36 # and minor corrections March - May 1999.
37 # Correct some major gaffs: Julian Gilbey, January 2000, with thanks to
38 # Victor Meghesan <victorm@genesys.ro>
40 echo "fvwmrc-to-fvwm2rc" >&2
42 # gawk has IGNORECASE, so we use it if possible.
43 if [ -n `command -v gawk 2>/dev/null` ]
46 elif [ -x /usr
/bin
/gawk
]
49 elif [ -n `command -v awk 2>/dev/null` ]
52 elif [ -x /usr
/bin
/awk ]
58 echo "Can't find any awk, cannot run!" >&2
62 source=${1:-$HOME/.fvwmrc}
63 if [ ! -r $source ] ; then
64 echo "Can't find source file $source, giving up" >&2
68 dest
=${2:-$HOME/.fvwm2rc}
69 if [ "$dest" != "-" ] ;then
70 echo "Output to $dest" >&2
71 if [ -f $dest ] ; then
72 echo "Saving existing $dest as $dest.bak" >&2
73 cp -p $dest $dest.bak ||
{ echo "Couldn't save; aborting" >&2; exit 1; }
75 cp -p $source $dest 2>/dev
/null
# try to preserve permissions
77 exec >$dest ||
{ echo "Couldn't write to $dest, aborting" >&2; exit 1; }
79 if [ ! -w "$TTY" ] ;then
85 if [ ! -w "$TTY" ] ;then
91 printf ("# Trying to compile an old .fvwrc to the new fvwm-2.xx Format\n");
96 hiforecolor=""; dflt["hiforecolor"] = "black";
97 hibackcolor=""; dflt["hibackcolor"] = "CadetBlue";
100 stdforecolor=""; dflt["stdforecolor"] = "black";
101 stdbackcolor=""; dflt["stdbackcolor"] = "grey70";
107 placement = FALSE; dflt["placement"] = "ActivePlacement, DumbPlacement"
110 /^[ \t]*#/ { # Comment, pass it thru
115 /^[ \t]*$/ { # Empty line, pass it thru
120 ################ Rename common items ##############
121 /Restart/ && /fvwm/ {
122 gsub("fvwm", "fvwm2"); gsub("fvwm22","fvwm2"); # try to leave paths alone
124 /GoodStuff/ { gsub("GoodStuff", "FvwmButtons"); }
126 ############ Chop off trailing "&" from Exec commands ##########
127 /^Exec[ \t]+/ || /[ \t]+Exec[ \t]+/ { gsub ("\&[ \t]*$",""); }
129 ################ Highlight Colors ##############
130 /^[ \t]*HiBackColor[ \t]*/ {
131 dflt["hibackcolor"]=hibackcolor=$2;
132 printf ("#!%s (new command=HilightColor)\n", $0);
133 if (hibackcolor != "" && hiforecolor != "" && !hilightcolor) {
134 printf ("\n#Set the foreground and background color for selected windows\n");
135 printf ("HilightColor %s %s\n", hiforecolor, hibackcolor);
142 /^[ \t]*HiForeColor[ \t]*/ {
143 dflt["hiforecolor"]=hiforecolor=$2;
144 printf ("#!%s (new command=HilightColor)\n", $0);
145 if (hibackcolor != "" && hiforecolor != "" && !hilightcolor) {
146 printf ("\n#Set the foreground and background color for selected windows\n");
147 printf ("HilightColor %s %s\n", hiforecolor, hibackcolor);
155 ########## Menu Colors, Style and Font ###########
156 /^[ \t]*MenuForeColor[ \t]*/ {
157 printf ("#!%s\n", $0);
158 printf ("MenuStyle * Foreground %s\n", $2);
162 /^[ \t]*MenuBackColor[ \t]*/ {
163 printf ("#!%s\n", $0);
164 printf ("MenuStyle * Background %s\n", $2);
168 /^[ \t]*MenuStippleColor[ \t]*/ {
169 printf ("#!%s\n", $0);
170 printf ("MenuStyle * Greyed %s\n", $2);
174 /^[ \t]*MWMMenus[ \t]*/ {
175 printf ("#!%s\n", $0);
176 printf ("MenuStyle * mwm\n");
180 /^[ \t]*Font[ \t]*/ {
181 printf ("#!%s\n", $0);
182 printf ("MenuStyle * Font %s\n", $2);
187 # Translate both old ButtonStyle formats to the new format:
188 /^[ \t]*ButtonStyle[ \t]*/ {
189 if ($2 == ":") { # new style already
191 print "ERROR: ButtonStyle command incorrect\n" NR ": " $0 >"'$TTY'";
192 printf ("%s %d %d", $1, $3, $4);
193 for (i=5; i<=NF; ++i)
197 print "Note: Conversion of old ButtonStyle; values rounded" \
199 printf ("#! Old line was: %s\n", $0);
201 x=substr($3,1,p-1)/2;
203 printf ("%s %s 5 %dx%d@0 %dx%d@0 %dx%d@0 %dx%d@1 %dx%d@1\n",
204 $1, $2, 50-x,50+y, 50+x,50+y, 50+x,50-y, 50-x,50-y,
210 ########## Standard Colors ###########
211 /^[ \t]*StdForeColor[ \t]*/ {
212 dflt["stdforecolor"]=stdforecolor=$2;
213 printf ("#!%s (new command=Style \"*\" Color f/b)\n", $0);
214 print "Style \"*\" ForeColor " $2;
218 /^[ \t]*StdBackColor[ \t]*/ {
219 dflt["stdbackcolor"]=stdbackcolor=$2;
220 printf ("#!%s (new command=Style \"*\" Color f/b)\n", $0);
221 print "Style \"*\" BackColor " $2;
225 ########## Icon Related Stuff ##########
226 /^[ \t]*IconBox[ \t]*/ { print "Style \"*\" " $0; next; }
227 /^[ \t]*IconFont[ \t]*/ { print $0; next; }
228 /^[ \t]*SuppressIcons[ \t]*/ { print "Style \"*\" NoIcon"; next; }
229 /^[ \t]*StickyIcons[ \t]*/ { print "Style \"*\" StickyIcon"; next; }
230 /^[ \t]*ModulePath[ \t]*/ { print "#! (ModulePath command commented out)\n#" $0; next; }
231 /^[ \t]*PixmapPath[ \t]*/ { print $0; next; }
232 /^[ \t]*IconPath[ \t]*/ { print $0; next; }
233 # note: Icon must be followed by some white space
234 /^[ \t]*Icon[ \t]+/ { printf "Style %s Icon %s\n", $2, $3; next; }
236 ########## MWM hints ##########
237 /^[ \t]*MWMFunctionHints[ \t]*/ { printf ("Style \"*\" MWMFunctions\n"); next; }
238 /^[ \t]*MWMDecor[ \t]*/ { printf ("Style \"*\" MWMDecor\n"); next; }
239 /^[ \t]*MWMDecorHints[ \t]*/ { printf ("Style \"*\" MWMDecor\n"); next; }
240 /^[ \t]*MWMBorders[ \t]*/ { printf ("Style \"*\" MWMBorder\n"); next; }
241 /^[ \t]*MWMButtons[ \t]*/ { printf ("Style \"*\" MWMButtons\n"); next; }
242 /^[ \t]*MWMHintOverride[ \t]*/ { printf ("Style \"*\" HintOverride\n"); next; }
244 ########## Placement & Focus styles ##########
245 /^[ \t]*RandomPlacement[ \t]*/ { print "Style \"*\" " $0; placement = TRUE; next; }
246 /^[ \t]*SmartPlacement[ \t]*/ { print "Style \"*\" " $0; placement = TRUE; next; }
247 /^[ \t]*Sticky(Back|Fore)Color[ \t]*/ {
248 print "#! " $0 " (not supported in FVWM2)"; next;
250 /^[ \t]*Sticky[ \t]+/ { printf "Style \"%s\" Sticky\n", $2; next; }
251 /^[ \t]*NoPPosition[ \t]*/ { print "Style \"*\" " $0; next; }
252 /^[ \t]*ClickToFocus[ \t]*/ { print "Style \"*\" " $0; next; }
253 /^[ \t]*SloppyFocus[ \t]*/ { print "Style \"*\" " $0; next; }
254 /^[ \t]*StaysOnTop[ \t]*/ { printf "Style \"%s\" StaysOnTop\n", $2; next; }
255 /^[ \t]*AutoRaise[ \t]*/ {
256 print "#! " $0 " (use Module FvwmAuto)";
257 print "AddToFunc \"InitFunction\" \"I\" Module FvwmAuto " $2;
258 print "AddToFunc \"RestartFunction\" \"I\" Module FvwmAuto " $2;
262 ########## Decoration styles ##########
263 /^[ \t]*BorderWidth[ \t]*/ { print "Style \"*\" " $0; next; }
264 /^[ \t]*HandleWidth[ \t]*/ { print "Style \"*\" " $0; next; }
265 /^[ \t]*DecorateTransients[ \t]*/ { print "Style \"*\" DecorateTransient"; next; }
266 /^[ \t]*XORvalue[ \t]*/ { print $0; next; }
267 /^[ \t]*BoundaryWidth[ \t]*/ { printf "Style \"*\" HandleWidth %s\n", $2; next; }
268 /^[ \t]*NoBoundaryWidth[ \t]*/ { print "Style \"*\" BorderWidth " $2; next; }
269 /^[ \t]*NoTitle[ \t]*/ { print "Style \"*\" " $0; next; }
270 /^[ \t]*NoBorder[ \t]*/ { print "Style \"*\" " $0; next; }
274 ########## Etc ##########
275 /^[ \t]*Lenience[ \t]*/ { print "Style \"*\" " $0; next; }
276 /^[ \t]*Style[ \t]*/ { print $0; next; }
277 # Key keyname context mods (Exec|Module|Restart) ...
278 # used to be followed by a "name"; it is no longer
279 /^[ \t]*Key[ \t]+[^ \t]+[ \t]+[^ \t]+[ \t]+[^ \t]+[ \t]+(Exec|Module|Restart)[ \t]+\"/ {
280 # not going to handle escaped quotes
283 quoted=substr(label, 1, 1)=="\"" &&
284 substr(label, length(label), 1)!="\"";
285 for (i=7;i<=NF && quoted;i++) {
287 quoted=substr(label, length(label), 1)!="\"";
290 printf ("%s %s %s %s %s", $1, $2, $3, $4, $5);
291 for (i=first; i<=NF; ++i)
296 # Any other Key command
297 /^[ \t]*Key[ \t]*/ { print $0; next; }
299 # Similarly with Mouse commands
300 /^[ \t]*Mouse[ \t]+[^ \t]+[ \t]+[^ \t]+[ \t]+[^ \t]+[ \t]+(Exec|Module|Restart)[ \t]+\"/ {
301 # not going to handle escaped quotes
304 quoted=substr(label, 1, 1)=="\"" &&
305 substr(label, length(label), 1)!="\"";
306 for (i=7;i<=NF && quoted;i++) {
308 quoted=substr(label, length(label), 1)!="\"";
311 printf ("%s %s %s %s %s", $1, $2, $3, $4, $5);
312 for (i=first; i<=NF; ++i)
318 /^[ \t]*Mouse[ \t]*/ { print $0; next; }
319 # This is probably not necessary
320 # /^[ \t]*Mouse[ \t]*/ {
321 # if (sub("[ \t]Pop[uU]p[ \t]", " Menu ")) {
322 # if (!warn["Mouse"]) {
323 # print "Note: Setting mouse bindings to sticky menus">"'$TTY'";
324 # warn["Mouse"] = TRUE;
331 /^[ \t]*WindowListSkip[ \t]*/ { printf "Style %s WindowListSkip\n", $2; next; }
332 /^[ \t]*WindowFont[ \t]*/ { print $0; next; }
333 /^[ \t]*ClickTime[ \t]*/ { print $0; next; }
334 /^[ \t]*OpaqueMove[ \t]*/ { print "OpaqueMoveSize " $2; next; }
335 /^[ \t]*EdgeScroll[ \t]*/ { print $0; next; }
336 /^[ \t]*EdgeResistance[ \t]*/ { print $0; next; }
337 /^[ \t]*DeskTopSize[ \t]*/ { print $0; next; }
338 /^[ \t]*DeskTopScale[ \t]*/ {
339 printf ("#!%s (new command=*FvwmPagerDeskTopScale <scale>)\n", $0);
340 print "*FvwmPagerDeskTopScale " $2;
344 /^[ \t]*FvwmButtons[ \t]*/ {
345 sub("[ ]Swallow[ ]*[^ ]*", "& Exec");
347 if (length($0) > 199)
349 print "Warning: line" NR "too long" >"'$TTY'";
350 print ">> " $0 >"'$TTY'";
352 if (!warn["GoodStuff"])
354 print "Note: GoodStuff renamed to FvwmButtons" >"'$TTY'";
355 print "Note: FvwmButtons syntax may now be wrong; please check!" >"'$TTY'";
356 warn["GoodStuff"]=TRUE;
362 # other Module Configuration commands are passed thru
367 # hack: Modules spawned outside of a function, menu, or popup cannot have leading whitespace.
368 # add these to the initfunction
369 /^Module[ \t]*/ { printf "AddToFunc \"InitFunction\" \"I\" %s \n", $0; next; }
371 # hack: function declarations cannot have leading whitespace
374 print "ERROR: EndPopup missing\n" NR ": " $0 >"'$TTY'";
377 print "ERROR: EndFunction missing\n" NR ": " $0 >"'$TTY'";
379 prefix="AddToFunc " $2;
383 /^[ \t]*EndFunction[ \t]*/ {
385 print "ERROR: EndFunction outside of function" >"'$TTY'";
391 # hack: popup declarations cannot have leading whitespace
394 print "ERROR: EndPopup missing\n" NR ": " $0 >"'$TTY'";
396 print "ERROR: EndFunction missing\n" NR ": " $0 >"'$TTY'";
401 if (index($2, "\"") == 1) {
402 # not going to handle escaped quotes
404 quoted=substr(label, 1, 1)=="\"" &&
405 substr(label, length(label), 1)!="\"";
406 for (i=3;i<=NF && quoted;i++) {
408 quoted=substr(label, length(label), 1)!="\"";
413 prefix="AddToMenu " label;
417 /^[ \t]*EndPopup[ \t]*/ {
419 print "ERROR: EndPopup outside of popup\n" NR ": " $0 >"'$TTY'";
427 ########## Deleted Commands ##########
428 /^[ \t]*DontMoveOff[ \t]*/ ||
429 /^[ \t]*BackingStore[ \t]*/ ||
430 /^[ \t]*AppsBackingStore[ \t]*/ ||
431 /^[ \t]*SaveUnders[ \t]*/ ||
432 /^[ \t]*StubbornIcons[ \t]*/ ||
433 /^[ \t]*StubbornIconPlacement[ \t]*/ ||
434 /^[ \t]*StubbornPlacement[ \t]*/ ||
435 /^[ \t]*Cursor[ \t]*/ {
436 print "#! " $0 " [deleted]";
437 if (warned[$1]==FALSE) {
438 print "Warning: " $1 " not in Fvwm2, command dropped" >"'$TTY'";
444 /^[ \t]*Pager[ \t]*/ {
445 print "#! " $0 " [deleted]";
446 print "#! An FvwmPager config to emulate builtin pager would be as follows:"
447 print "# *FvwmPagerBack SlateGrey";
448 print "# *FvwmPagerFore Black";
449 print "# *FvwmPagerFont none";
450 print "# *FvwmPagerHilight SlateBlue4";
451 print "# *FvwmPagerGeometry <xsize> <ysize>";
452 print "# *FvwmPagerSmallFont -*-times-medium-r-*-*-*-80-*-*-*-*-*-*";
453 print "# *FvwmPagerDeskTopScale 32";
454 print "# #! Now start pager";
455 print "# Module FvwmPager 0 0";
456 if (warned[$1]==FALSE) {
457 print "Warning: " $1 " omitted, internal pager is obsolete (use FvwmPager)" >"'$TTY'";
463 /^[ \t]*PagingDefault[ \t]*/ ||
464 /^[ \t]*TogglePage[ \t]*/ {
465 print "#! " $0 " (use EdgeScroll 0 0)"; next;
466 print "Warning: " $1 " not in Fvwm2, use EdgeScroll">"'$TTY'";
469 ########## Old Internal Pager Colors ###########
470 /^[ \t]*PagerForeColor[ \t]*/ ||
471 /^[ \t]*PagerBackColor[ \t]*/ {
472 printf ("#!%s (new command=Style FvwmPager Color fore_color/back_color)\n", $0);
473 if (warned[$1]==FALSE) {
474 print "Warning: " $1 " omitted, internal pager is obsolete (use FvwmPager)" >"'$TTY'";
480 ########## Sticky Colors ###########
481 /^[ \t]*StickyForeColor[ \t]*/ {
482 printf ("#!%s (no sticky foreground color in fvwm2)\n", $0);
483 if (warned[$1]==FALSE) {
484 print "Warning: StickyForeColor not in fvwm2, omitted" > "'$TTY'"
485 print " Use the Style command to assign each sticky window the same ForeColor" > "'$TTY'"
490 /^[ \t]*StickyBackColor[ \t]*/ {
491 printf ("#!%s (no sticky background color in fvwm2)\n", $0);
492 if (warned[$1]==FALSE) {
493 print "Warning: StickyBackColor not in fvwm2, omitted" >"'$TTY'"
494 print " Use the Style command to assign each sticky window the same BackColor" > "'$TTY'"
502 #gsub("[ ]PopUp[ ]", " "); }
503 if ($2 == "\"Motion\"")
505 else if ($2 == "\"Click\"")
507 else if ($2 == "\"DoubleClick\"")
509 else if ($2 == "\"Immediate\"")
512 printf "%s", prefix " " context " " $1;
513 for (i=3; i<=NF; ++i)
518 } else if (inpopup) {
519 # not going to handle escaped quotes
522 quoted=substr(label, 1, 1)=="\"" &&
523 substr(label, length(label), 1)!="\"";
524 for (i=3;i<=NF && quoted;i++) {
526 quoted=substr(label, length(label), 1)!="\"";
529 printf ("%s %s %s", prefix, label, $1);
530 for (i=first; i<=NF; ++i)
537 if (warned[$1]==FALSE) {
538 printf ("#!Warning: Keyword \"%s\" not handled yet\n", $1);
540 print "Warning: Unknown keyword "$1" passed through">"'$TTY'";
548 printf ("\n#Set the foreground and background color for selected windows\n");
549 printf ("HilightColor %s %s\n", dflt["hiforecolor"], dflt["hibackcolor"]);
552 printf "# overide default RandomPlacement and SmartPlacement Styles\n";
553 printf "Style \"*\" %s\n", dflt["placement"];