X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=i3-migrate-config-to-v4;h=5da4e26ed447d7b30316adec7fd81af1bf6b9f22;hb=690e6d1f0e62437c06918ee21484cfafbce336ac;hp=0a8db2deb275c9894d065692a7be3e4965214798;hpb=042b10e0681e5274f81fdaf0d25eb1aa5c145a78;p=i3%2Fi3 diff --git a/i3-migrate-config-to-v4 b/i3-migrate-config-to-v4 index 0a8db2de..5da4e26e 100755 --- a/i3-migrate-config-to-v4 +++ b/i3-migrate-config-to-v4 @@ -67,7 +67,7 @@ sub need_to_convert { # have a look at bindings next unless $line =~ /^bind/; - my ($statement, $key, $command) = ($line =~ /([a-zA-Z_-]+)[ \t]+([^ \t]+)[ \t]+(.*)/); + my ($statement, $key, $command) = ($line =~ /([a-zA-Z_-]+)\s+([^\s]+)\s+(.*)/); return 0 if $command =~ /^layout/ || $command =~ /^floating/ || $command =~ /^workspace/ || @@ -94,7 +94,7 @@ for my $line (@lines) { # skip everything but workspace lines next unless defined($statement) and $statement eq 'workspace'; - my ($number, $params) = ($parameters =~ /[ \t]+([0-9]+) (.+)/); + my ($number, $params) = ($parameters =~ /\s+([0-9]+)\s+(.+)/); # save workspace name (unless the line is actually a workspace assignment) $workspace_names{$number} = $params unless $params =~ /^output/; @@ -117,14 +117,13 @@ for my $line (@lines) { # new_container changed only the statement name to workspace_layout if ($statement eq 'new_container') { - # TODO: new_container stack-limit print "workspace_layout$parameters\n"; next; } # workspace_bar is gone, you should use i3bar now if ($statement eq 'workspace_bar') { - $workspace_bar = ($parameters =~ /[ \t+](yes|true|on|enable|active)/); + $workspace_bar = ($parameters =~ /\s+(yes|true|on|enable|active)/); print "# XXX: REMOVED workspace_bar line. There is no internal workspace bar in v4.\n"; next; } @@ -153,7 +152,7 @@ for my $line (@lines) { # one form of this is still ok (workspace assignments), the other (named workspaces) isn’t if ($statement eq 'workspace') { - my ($number, $params) = ($parameters =~ /[ \t]+([0-9]+) (.+)/); + my ($number, $params) = ($parameters =~ /\s+([0-9]+)\s+(.+)/); if ($params =~ /^output/) { print "$line\n"; next; @@ -184,10 +183,9 @@ sub convert_command { restart reload exit - stack-limit ); - my ($statement, $key, $command) = ($line =~ /([a-zA-Z_-]+)[ \t]+([^ \t]+)[ \t]+(.*)/); + my ($statement, $key, $command) = ($line =~ /([a-zA-Z_-]+)\s+([^\s]+)\s+(.*)/); # turn 'bind' to 'bindcode' $statement = 'bindcode' if $statement eq 'bind'; @@ -202,7 +200,7 @@ sub convert_command { # simple replacements my @replace = ( qr/^s/ => 'layout stacking', - qr/^d/ => 'layout default', + qr/^d/ => 'layout toggle split', qr/^T/ => 'layout tabbed', qr/^f($|[^go])/ => 'fullscreen', qr/^fg/ => 'fullscreen global', @@ -234,14 +232,14 @@ sub convert_command { # goto command is now obsolete due to criteria + focus command if ($command =~ /^goto/) { - my ($mark) = ($command =~ /^goto (.*)/); + my ($mark) = ($command =~ /^goto\s+(.*)/); print qq|$statement $key [con_mark="$mark"] focus\n|; return; } # the jump command is also obsolete due to criteria + focus if ($command =~ /^jump/) { - my ($params) = ($command =~ /^jump (.*)/); + my ($params) = ($command =~ /^jump\s+(.*)/); if ($params =~ /^"/) { # jump ["]window class[/window title]["] ($params) = ($params =~ /^"([^"]+)"/); @@ -262,8 +260,8 @@ sub convert_command { } if (!$replaced && $command =~ /^focus/) { - my ($what) = ($command =~ /^focus (.*)/); - $what =~ s/[ \t]//g; + my ($what) = ($command =~ /^focus\s+(.*)/); + $what =~ s/\s//g; if ($what eq 'ft') { $what = 'mode_toggle'; } elsif ($what eq 'floating' || $what eq 'tiling') { @@ -277,7 +275,7 @@ sub convert_command { } if ($command =~ /^mode/) { - my ($parameters) = ($command =~ /^mode (.*)/); + my ($parameters) = ($command =~ /^mode\s+(.*)/); print qq|$statement $key mode "$parameters"\n|; return; } @@ -286,7 +284,7 @@ sub convert_command { if ($command =~ /^resize/) { # OLD: resize [+|-]\n") # NEW: resize [ px] [or ppt] - my ($direction, $sign, $px) = ($command =~ /^resize (left|right|top|bottom) ([+-])([0-9]+)/); + my ($direction, $sign, $px) = ($command =~ /^resize\s+(left|right|top|bottom)\s+([+-])([0-9]+)/); my $cmd = 'resize '; $cmd .= ($sign eq '+' ? 'grow' : 'shrink') . ' '; if ($direction eq 'top') { @@ -316,10 +314,10 @@ sub convert_command { if ($command =~ /^m[0-9]+/) { my ($number) = ($command =~ /^m([0-9]+)/); if (exists $workspace_names{$number}) { - print qq|$statement $key move workspace $workspace_names{$number}\n|; + print qq|$statement $key move container to workspace $workspace_names{$number}\n|; return; } else { - print qq|$statement $key move workspace $number\n|; + print qq|$statement $key move container to workspace $number\n|; return; } } @@ -341,7 +339,7 @@ sub convert_command { # 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. + # has to modify their config. print "$statement $key focus parent; $command\n"; } return; @@ -358,6 +356,8 @@ sub convert_command { # add an i3bar invocation automatically if no 'workspace_bar no' was found if ($workspace_bar) { print "\n"; - print "# XXX: Automatically added a call to i3bar to provide a workspace bar\n"; - print "exec i3status | i3bar -d\n"; + print "# XXX: Automatically added a bar configuration\n"; + print "bar {\n"; + print " status_command i3status\n"; + print "}\n"; }