Skip to content

Instantly share code, notes, and snippets.

@devdsp
Created January 4, 2016 04:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdsp/fe0ed3a63e4511461aed to your computer and use it in GitHub Desktop.
Save devdsp/fe0ed3a63e4511461aed to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use AnyEvent::I3 qw(:all);
my $i3 = i3();
$i3->connect->recv or die "Error connecting to i3";
my $output = undef;
sub proc {
my ($self) = @_;
if( $self->{'type'} eq 'output' ) { $output = $self->{'name'}; }
if( $self->{'focused'} == 1 ) {
system( "xsetwacom set 'Wacom Intuos4 6x9 Pen stylus' MapToOutput $output");
} else {
map {proc( $_ )} @{$self->{'nodes'}};
}
}
$i3->subscribe({ workspace => sub { $i3->get_tree->cb( sub { map {proc($_)} @{$_[0]->{'_ae_sent'}}; }); }
})->recv->{success} or die "Error subscrubing to events";
AE::cv->recv;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment