]> git.sev.monster Git - dotfiles.git/blame - bin/i3subscribe
head all which, fix dmenu recursion, fix syncthing
[dotfiles.git] / bin / i3subscribe
CommitLineData
1390d028 1#!/usr/bin/env perl
2
3BEGIN { $| = 1 } # flush \n
4
5use strict;
6use warnings;
7use Data::Dumper;
8use AnyEvent::I3;
9use v5.10;
10
11my $i3 = i3();
12$i3->connect->recv or die "Error connecting to i3";
13
14sub subscribe {
15 my $ev = $_[0];
16 my $dump = $_[1];
17 if($i3->subscribe({
18 $ev => sub {
19 my ($msg) = @_;
20 say "$ev:$msg->{'change'}";
21 if($dump) {
22 print Dumper($msg);
23 }
24 }
25 })->recv->{success}) {
ff1a2414 26 say "Successfully subscribed to $ev event";
1390d028 27 }
28}
29
30my $nextArg = shift;
31if(!$nextArg) {
ff1a2414 32 say "Subscribe to i3 events";
1390d028 33 say "Usage: $0 workspace|output|mode|window|barconfig_update|binding [dump]";
34 say "Example: $0 workspace dump window binding dump";
35 exit 1;
36}
37while($nextArg) {
38 my $arg = $nextArg;
39 $nextArg = shift;
40 my $dump = 0;
41 if($nextArg and $nextArg eq "dump") {
42 $dump = 1;
43 $nextArg = shift;
44 }
45 subscribe("$arg", $dump);
46}
47AE::cv->recv;
48
49# vim: et:ts=4:sts=4
This page took 0.038977 seconds and 4 git commands to generate.