package i3test;
# vim:ts=4:sw=4:expandtab
+use strict; use warnings;
use File::Temp qw(tmpnam tempfile tempdir);
use Test::Builder;
use AnyEvent::I3;
use EV;
use List::Util qw(first);
-use List::MoreUtils qw(lastval);
use Time::HiRes qw(sleep);
-use Try::Tiny;
use Cwd qw(abs_path);
-use Proc::Background;
use SocketActivation;
use v5.10;
$lf = $focused[0];
last unless defined($con->{focus});
@focused = @{$con->{focus}};
- @cons = grep { $_->{id} == $lf } (@{$con->{nodes}}, @{$con->{'floating_nodes'}});
+ my @cons = grep { $_->{id} == $lf } (@{$con->{nodes}}, @{$con->{'floating_nodes'}});
$con = $cons[0];
}
my $first = first { $_->{type} == 5 } @{$output->{nodes}};
@docked = (@docked, @{$first->{nodes}});
} elsif ($which eq 'bottom') {
- my $last = lastval { $_->{type} == 5 } @{$output->{nodes}};
+ my @matching = grep { $_->{type} == 5 } @{$output->{nodes}};
+ my $last = $matching[-1];
@docked = (@docked, @{$last->{nodes}});
}
}
$socketpath ||= get_socket_path();
my $exited = 0;
- try {
+ eval {
say "Exiting i3 cleanly...";
i3($socketpath)->command('exit')->recv;
$exited = 1;