2 # vim:ts=4:sw=4:expandtab
3 # © 2012 Michael Stapelberg
4 # Licensed under BSD license, see http://code.i3wm.org/i3/tree/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.
25 die "Could not connect to i3: $!" unless $i3->connect->recv();
27 die "Could not subscribe to the workspace event: $!" unless
31 return unless $msg->{change} eq 'focus';
32 die "Your version of i3 is too old. You need >= v4.4"
33 unless exists($msg->{current});
34 my $ws = $msg->{current};
36 # If the workspace already has children, don’t change the layout.
37 return unless scalar @{$ws->{nodes}} == 0;
39 my $name = $ws->{name};
40 my $con_id = $ws->{id};
42 return unless exists $layouts{$name};
44 $i3->command(qq|[con_id="$con_id"] layout | . $layouts{$name});
48 say "AnyEvent::I3 error: $msg";
55 AnyEvent->condvar->recv