migrate-config: convert old 'with container' commands to 'focus parent; $command' (+test) (Thanks Marcus)

This commit is contained in:
Michael Stapelberg 2011-07-27 14:36:22 +02:00
parent 2b940296a8
commit eea804cd94
2 changed files with 20 additions and 3 deletions

View File

@ -321,7 +321,24 @@ sub convert_command {
# With Container-commands are now obsolete due to different abstraction # With Container-commands are now obsolete due to different abstraction
if ($command =~ /^wc/) { if ($command =~ /^wc/) {
print "# XXX: 'with container' commands are obsolete in 4.x: $line\n"; $command =~ s/^wc//g;
my $wc_replaced = 0;
for (my $c = 0; $c < @replace; $c += 2) {
if ($command =~ $replace[$c]) {
$command = $replace[$c+1];
$wc_replaced = 1;
last;
}
}
if (!$wc_replaced) {
print "# XXX: migration script could not handle command: $line\n";
} else {
# NOTE: This is not 100% accurate, as it only works for one level
# of nested containers. As this is a common use case, we use 'focus
# parent; $command' nevertheless. For advanced use cases, the user
# has to modify his config.
print "$statement $key focus parent; $command\n";
}
return; return;
} }

View File

@ -215,8 +215,8 @@ ok(line_exists($output, qr|^bindsym Mod1\+s border normal$|), 'bn replaced');
ok(line_exists($output, qr|^bindsym Mod1\+s border 1pixel$|), 'bp replaced'); ok(line_exists($output, qr|^bindsym Mod1\+s border 1pixel$|), 'bp replaced');
ok(line_exists($output, qr|^bindsym Mod1\+s border none$|), 'bb replaced'); ok(line_exists($output, qr|^bindsym Mod1\+s border none$|), 'bb replaced');
ok(line_exists($output, qr|^bindsym Mod1\+s border toggle$|), 'bt replaced'); ok(line_exists($output, qr|^bindsym Mod1\+s border toggle$|), 'bt replaced');
ok(line_exists($output, qr|^#.*with container.*obsolete.*wch$|), 'with container removed'); ok(line_exists($output, qr|^bindsym Mod1\+j focus parent; focus left$|), 'with container replaced with focus parent; focus left');
ok(line_exists($output, qr|^#.*with container.*obsolete.*wcml$|), 'with container removed'); ok(line_exists($output, qr|^bindsym Mod1\+j focus parent; move right$|), 'with container replaced with focus parent; move right');
ok(line_exists($output, qr|^bindsym Mod1\+k kill$|), 'kill unchanged'); ok(line_exists($output, qr|^bindsym Mod1\+k kill$|), 'kill unchanged');
ok(line_exists($output, qr|^bindsym Mod1\+n workspace next$|), 'nw replaced'); ok(line_exists($output, qr|^bindsym Mod1\+n workspace next$|), 'nw replaced');
ok(line_exists($output, qr|^bindsym Mod1\+p workspace prev$|), 'pw replaced'); ok(line_exists($output, qr|^bindsym Mod1\+p workspace prev$|), 'pw replaced');