Re: [i3] Get list of workspaces

  • From: Anders Bo Rasmussen <fuzz@xxxxxxx>
  • To: "Discussions/Questions about the i3 window manager" <i3-discuss@xxxxxxxxxxxxx>
  • Date: Tue, 31 Jul 2012 16:19:59 +0200

On Wed, Jul 25, 2012 at 3:40 PM, Michael Stapelberg <michael@xxxxxxxx> wrote:

Is there a more easy way to do this?
No, it’s the same way I would do it right now.

Hi. I've figured out to get the current workspace with AnyEvent::I3.
I've also figured out to get a call back when the workspace changes.
But when I combine it I get an error, as it seems like I can't call
get_tree() while I'm in a call back. I've made a small script to show
the problem:

#!/usr/bin/perl

use warnings;
use strict;
use AnyEvent::I3;

my $i3=i3();
$i3->connect();
if ($i3->connect->recv) {
print "Connected to i3\n";
}
my %callbacks = (
workspace => sub { i3->get_tree->recv}
);

while ($i3->subscribe(\%callbacks)->recv) {};


Which give the following output (second line first when I switch workspace):

Connected to i3
AnyEvent::CondVar: recursive blocking wait attempted at
/home/fuzz/perl5/lib/perl5/AnyEvent/I3.pm line 339

Am I doing something wrong?

/Anders

Other related posts: