X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=i3-save-tree;h=b00e1fe18330926dc638dcc879156e0eabe6eaf3;hb=d6aece03ee27e2f1819c25663c6b2f20f1879892;hp=b6ed085ec7b836a55d3ec3e22dd58ff7cf59acd9;hpb=80f119f0e248211babadcfbfb0ffecfd66ea8e16;p=i3%2Fi3 diff --git a/i3-save-tree b/i3-save-tree index b6ed085e..b00e1fe1 100755 --- a/i3-save-tree +++ b/i3-save-tree @@ -1,7 +1,7 @@ #!/usr/bin/env perl # vim:ts=4:sw=4:expandtab # -# © 2013-2014 Michael Stapelberg +# © 2013 Michael Stapelberg # # Requires perl ≥ v5.10, AnyEvent::I3 and JSON::XS @@ -99,6 +99,7 @@ my %allowed_keys = map { ($_, 1) } qw( geometry window_properties mark + rect ); sub strip_containers { @@ -116,6 +117,9 @@ sub strip_containers { delete $tree->{geometry} if zero_rect($tree->{geometry}); + # Retain the rect for floating containers to keep their positions. + delete $tree->{rect} unless $tree->{type} eq 'floating_con'; + delete $tree->{current_border_width} if $tree->{current_border_width} == -1; for my $key (keys %$tree) { @@ -222,7 +226,7 @@ my $tree = $i3->get_tree->recv; my $dump; if (defined($workspace)) { $dump = filter_containers($tree, sub { - $_->{type} eq 'workspace' && $_->{name} eq $workspace + $_->{type} eq 'workspace' && ($_->{name} eq $workspace || ($workspace =~ /^\d+$/ && $_->{num} eq $workspace)) }); } else { $dump = filter_containers($tree, sub { @@ -252,7 +256,7 @@ for my $key (qw(nodes floating_nodes)) { =head1 SYNOPSIS - i3-save-tree [--workspace=name] [--output=name] + i3-save-tree [--workspace=name|number] [--output=name] =head1 DESCRIPTION @@ -271,9 +275,10 @@ If neither argument is specified, the currently focused workspace will be used. =over -=item B<--workspace=name> +=item B<--workspace=name|number> -Specifies the workspace that should be dumped, e.g. 1. +Specifies the workspace that should be dumped, e.g. 1. This can either be a +name or the number of a workspace. =item B<--output=name>