Merge pull request #1555 from Airblader/feature-i3-save-tree-current-ws
Make the --workspace optional by defaulting to the focused workspace.
This commit is contained in:
commit
e7753c839f
24
i3-save-tree
24
i3-save-tree
|
@ -13,6 +13,7 @@ use POSIX qw(locale_h);
|
||||||
use File::Find;
|
use File::Find;
|
||||||
use File::Basename qw(basename);
|
use File::Basename qw(basename);
|
||||||
use File::Temp qw(tempfile);
|
use File::Temp qw(tempfile);
|
||||||
|
use List::Util qw(first);
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use Pod::Usage;
|
use Pod::Usage;
|
||||||
use AnyEvent::I3;
|
use AnyEvent::I3;
|
||||||
|
@ -41,11 +42,7 @@ my $result = GetOptions(
|
||||||
|
|
||||||
die "Could not parse command line options" unless $result;
|
die "Could not parse command line options" unless $result;
|
||||||
|
|
||||||
if (!defined($workspace) && !defined($output)) {
|
if (defined($workspace) && defined($output)) {
|
||||||
die "One of --workspace or --output need to be specified";
|
|
||||||
}
|
|
||||||
|
|
||||||
unless (defined($workspace) ^ defined($output)) {
|
|
||||||
die "Only one of --workspace or --output can be specified";
|
die "Only one of --workspace or --output can be specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +54,15 @@ if (!$i3->connect->recv) {
|
||||||
die "Could not connect to i3";
|
die "Could not connect to i3";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub get_current_workspace {
|
||||||
|
my $current = first { $_->{focused} } @{$i3->get_workspaces->recv};
|
||||||
|
return $current->{name};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!defined($workspace) && !defined($output)) {
|
||||||
|
$workspace = get_current_workspace();
|
||||||
|
}
|
||||||
|
|
||||||
sub filter_containers {
|
sub filter_containers {
|
||||||
my ($tree, $pred) = @_;
|
my ($tree, $pred) = @_;
|
||||||
|
|
||||||
|
@ -259,19 +265,19 @@ specification. When a window is mapped (made visible on the screen) that
|
||||||
matches the specification, i3 will put it into that place and kill the
|
matches the specification, i3 will put it into that place and kill the
|
||||||
placeholder.
|
placeholder.
|
||||||
|
|
||||||
|
If neither argument is specified, the currently focused workspace will be used.
|
||||||
|
|
||||||
=head1 OPTIONS
|
=head1 OPTIONS
|
||||||
|
|
||||||
=over
|
=over
|
||||||
|
|
||||||
=item B<--workspace=name>
|
=item B<--workspace=name>
|
||||||
|
|
||||||
Specifies the workspace that should be dumped, e.g. 1. Either this or --output
|
Specifies the workspace that should be dumped, e.g. 1.
|
||||||
need to be specified.
|
|
||||||
|
|
||||||
=item B<--output=name>
|
=item B<--output=name>
|
||||||
|
|
||||||
Specifies the output that should be dumped, e.g. LVDS-1. Either this or
|
Specifies the output that should be dumped, e.g. LVDS-1.
|
||||||
--workspace need to be specified.
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue