2 # vim:ts=4:sw=4:expandtab
3 # © 2012 Michael Stapelberg
4 # Licensed under BSD license, see https://github.com/i3/i3/blob/next/LICENSE
6 # Append this line to your i3 config file:
7 # exec_always ~/per-workspace-layout.pl
9 # Then, change the %layouts hash like you want your workspaces to be set up.
10 # This script requires i3 >= v4.4 for the extended workspace event.
26 die "Could not connect to i3: $!" unless $i3->connect->recv();
28 die "Could not subscribe to the workspace event: $!" unless
32 return unless $msg->{change} eq 'focus';
33 die "Your version of i3 is too old. You need >= v4.4"
34 unless exists($msg->{current});
35 my $ws = $msg->{current};
37 # If the workspace already has children, don’t change the layout.
38 return unless scalar @{$ws->{nodes}} == 0;
40 my $name = $ws->{name};
41 my $con_id = $ws->{id};
43 return unless exists $layouts{$name};
45 $i3->command(qq|[con_id="$con_id"] layout | . $layouts{$name});
49 say "AnyEvent::I3 error: $msg";
56 AnyEvent->condvar->recv