Re: [i3] Get list of workspaces
- From: Michael Stapelberg <michael@xxxxxxxx>
- To: Discussions/Questions about the i3 window manager <i3-discuss@xxxxxxxxxxxxx>
- Date: Tue, 31 Jul 2012 19:31:12 +0200
Hi Anders,
Quoting Anders Bo Rasmussen (2012-07-31 16:19:59)
$i3->connect();
if ($i3->connect->recv) {
There’s no need to call ->connect twice. Kill the first line.
while ($i3->subscribe(\%callbacks)->recv) {};
Ugh, this is very wrong. You should only subscribe once, not in a loop.
Also, as you have noticed, you cannot call ->recv "twice". Instead, use:
#!/usr/bin/env perl
use strict;
use warnings;
use AnyEvent::I3;
use EV;
use Data::Dumper;
my $i3 = i3();
$i3->connect->recv;
my %callbacks = (
workspace => sub {
my $tree = i3->get_tree->recv;
print "tree = " . Dumper($tree) . "\n";
}
);
$i3->subscribe(\%callbacks)->recv;
EV::loop;
(I have noticed a few strange things while hacking up this example, so there
might be a new release of AnyEvent::I3 soon ;-)).
Best regards,
Michael
Other related posts: