AnyEvent-I3X-Workspace-OnDemand
view release on metacpan or search on metacpan
161718192021222324252627282930313233343536
bindsym 8
exec
i3-msg -t send_tick group:baz; mode
default
bindsym Return mode
"default"
bindsym Escape mode
"default"
}
# SYNOPSIS
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
858687888990919293949596979899100101102103104105106107108109110## $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.
## $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
) {
"Yay processed foo tick"
;
}
12131415161718192021222324252627282930313233343536373839404142use
EV;
use
Getopt::Long;
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
131415161718192021222324252627282930313233use
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
373839404142434445464748495051525354555657field
@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
305306307308309310311312313314315316317318319320321322323324325326327328329330331
$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
463464465466467468469470471472473474475476477478479480481482483=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
553554555556557558559560561562563564565566567568569570571572573574575576577578=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.644 second using v1.01-cache-2.11-cpan-26ccb49234f )