i3 ipc with libanyevent
Currently, I am working on small script for my i3 configuration, which needs to react to the workspace-focus event. At this point, I need both, the old and the current workspace, which should be saved in the eventhandler arguments. But when I try the following snippet with perl and libanyevent, the old and the current workspace objects are identical. Any suggestion why this might be the case?
#!/usr/bin/perl
use strict;
use warnings;
use AnyEvent::I3 qw(:all);
use EV;
use Data::Dumper;
my $i3 = i3("~/.i3/ipc.sock");
$i3->connect->recv or die "Error connecting";
my %handler = (
workspace => sub {
my ($msg) = @_;
if (($msg->{'change'} eq 'focus')) {
print Dumper($msg);
}
}
);
$i3->subscribe(\%handler)->recv;
EV::loop;
I am running the latest i3 (v4.5.1) and anyevent-i3 (v0.15).
Thanks!
P.S.: So, I looked into it a bit further, and have to correct myself. The old and current object in the event argument are updated correctly, but are handled seperately for each output monitor. So the old workspace is assigned to the workspace, which was previously focused on the newly focused ouput, and the current workspace refers to the workspace that is now focused on that output. Is this the desired behaviour? I assumed, old would refer to the previously focused workspace across all outputs.