morgon has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am having problems scripting the window-manager i3 with perl using AnyEvent::I3 and as I could not get any help in an i3-forum, I try my luck here...
This works:
Running this changes to workspace 1.use strict; use AnyEvent; use AnyEvent::I3; my $i3 = i3(); $i3->connect->recv or die "Error connecting to i3"; $i3->command("workspace 1")->recv;
And this also works:
Running this prints "empty workspace!!" whenever a workspace become empty.use strict; use AnyEvent; use AnyEvent::I3; my $i3 = i3(); $i3->connect->recv or die "Error connecting to i3"; $i3->subscribe({ workspace => \&handle })->recv->{success} or die "Error subscribing to events" +; AE::cv->recv; sub handle { my($data)=@_; if($data->{change} eq "empty") { print "empty workspace!!\n"; } }
What I want now is to combine the logic, so whenever a workspace becomes empty we change to workspace 1.
Here is my attempt:
However this does not work. It prints "empty workspace!!" ok, but it does not send the command, the error is:use strict; use AnyEvent; use AnyEvent::I3; my $i3 = i3(); $i3->connect->recv or die "Error connecting to i3"; $i3->subscribe({ workspace => \&handle })->recv->{success} or die "Error subscribing to events" +; AE::cv->recv; sub handle { my($data)=@_; if($data->{change} eq "empty") { print "empty workspace!!\n"; $i3->command("workspace 1")->recv; } }
Any ideas?EV: error in callback (ignoring): AnyEvent::CondVar: recursive blockin +g wait attempted
Many thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: scripting i3 with Perl
by Corion (Patriarch) on Feb 02, 2019 at 07:29 UTC | |
by morgon (Priest) on Feb 02, 2019 at 07:38 UTC | |
by Corion (Patriarch) on Feb 02, 2019 at 08:31 UTC | |
by morgon (Priest) on Feb 02, 2019 at 10:32 UTC | |
by Corion (Patriarch) on Feb 02, 2019 at 13:01 UTC | |
|
Back to
Seekers of Perl Wisdom