#!/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
name
geometry
window_properties
- mark
+ marks
+ rect
);
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) {
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 {
=head1 SYNOPSIS
- i3-save-tree [--workspace=name] [--output=name]
+ i3-save-tree [--workspace=name|number] [--output=name]
=head1 DESCRIPTION
=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>