AnyEvent-I3X-Workspace-OnDemand
view release on metacpan or search on metacpan
bindsym 8 exec i3-msg -t send_tick group:baz; mode default
bindsym Return mode "default"
bindsym Escape mode "default"
}
# SYNOPSIS
use AnyEvent::I3X::Workspace::OnDemand;
my $i3 = AnyEvent::I3X::Workspace::OnDemand->new(
debug => 0,
layout_path => "$ENV{HOME}/.config/i3",
workspaces => {
foo => {
layout => 'foo.json',
},
bar => {
layout => 'bar.json',
groups => {
foo => undef,
# Override the layout for group bar
## $self->get\_i3
Get the [AnyEvent::I3](https://metacpan.org/pod/AnyEvent%3A%3AI3) instance
## $self->command(@args)
Execute a command, the command can be in scalar or list context.
See also ["command" in AnyEvent::I3](https://metacpan.org/pod/AnyEvent%3A%3AI3#command).
## $self->debug(1)
Enable or disable debug
## $self->log($msg)
Print warns when debug is enabled
## $self->on\_tick($payload, $sub)
Subscribe to a tick event with `$payload` and perform the action. Your sub
needs to support the following prototype:
sub foo($self, $i3, $event) {
print "Yay processed foo tick";
}
use EV;
use Getopt::Long;
use File::Spec::Functions qw(catfile);
use Pod::Usage qw(pod2usage);
my %options = (
logfile => catfile($ENV{HOME}, qw(.config i3 i3-ipc-events.log)),
);
GetOptions(\%options, qw(debug help man logfile=s socket=s));
if ($options{help}) {
pod2usage(-verbose => 1);
}
if ($options{man}) {
pod2usage(-verbose => 2);
}
my $i3 = AnyEvent::I3X::Workspace::OnDemand->new(
debug => $options{debug} // 0,
socket => $options{socket},
log_all_events => $options{logfile},
);
EV::loop;
AE::cv->recv;
exit 0;
__END__
lib/AnyEvent/I3X/Workspace/OnDemand.pm view on Meta::CPAN
use File::Spec::Functions qw(catfile);
use Data::Compare;
use Data::Dumper;
field $i3;
field $layout_path : param = catfile($ENV{HOME}, qw(.config i3));
field @groups;
field $starting_group :param = undef;
field $starting_workspace :param = undef;
field $debug :param = 0;
field $log_all_events :param = undef;
field $socket :param = undef;
field %workspace;
field %output;
field %mode;
field %window;
field %barconfig_update;
lib/AnyEvent/I3X/Workspace/OnDemand.pm view on Meta::CPAN
field @swallows;
field $c;
field $current_group;
field $current_workspace;
ADJUSTPARAMS {
my $args = shift;
$debug = 1 if $log_all_events;
# i3
%workspace = %{ delete $args->{workspace} }
if ref $args->{workspace} eq 'HASH';
%barconfig_update = %{ delete $args->{barconfig_update} }
if ref $args->{barconfig_update} eq 'HASH';
%tick = %{ delete $args->{tick} } if ref $args->{tick} eq 'HASH';
%shutdown = %{ delete $args->{shutdown} } if ref $args->{shutdown} eq 'HASH';
%output = %{ delete $args->{output} } if ref $args->{output} eq 'HASH';
lib/AnyEvent/I3X/Workspace/OnDemand.pm view on Meta::CPAN
$current_group = $group;
$self->workspace($cur);
}
);
}
method log ($msg) {
return unless $debug;
warn $msg, $/;
return;
}
method debug ($d = undef) {
return $debug unless defined $d;
$debug = $d;
}
my @any = qw(any *);
method on_workspace ($name, $type, $sub) {
if (ref $sub ne 'CODE') {
croak("Please supply a code ref!");
}
lib/AnyEvent/I3X/Workspace/OnDemand.pm view on Meta::CPAN
=head1 VERSION
version 0.004
=head1 SYNOPSIS
use AnyEvent::I3X::Workspace::OnDemand;
my $i3 = AnyEvent::I3X::Workspace::OnDemand->new(
debug => 0,
layout_path => "$ENV{HOME}/.config/i3",
workspaces => {
foo => {
layout => 'foo.json',
},
bar => {
layout => 'bar.json',
groups => {
foo => undef,
# Override the layout for group bar
lib/AnyEvent/I3X/Workspace/OnDemand.pm view on Meta::CPAN
=head2 $self->get_i3
Get the L<AnyEvent::I3> instance
=head2 $self->command(@args)
Execute a command, the command can be in scalar or list context.
See also L<AnyEvent::I3/command>.
=head2 $self->debug(1)
Enable or disable debug
=head2 $self->log($msg)
Print warns when debug is enabled
=head2 $self->on_tick($payload, $sub)
Subscribe to a tick event with C<< $payload >> and perform the action. Your sub
needs to support the following prototype:
sub foo($self, $i3, $event) {
print "Yay processed foo tick";
}
( run in 0.343 second using v1.01-cache-2.11-cpan-26ccb49234f )