forked from sciurus/i3tree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4083822
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## OVERVIEW | ||
i3tree is a program I wrote to help myself adjust to version 4 of the i3 tiling window manager. It displays the containers your windows are children of and what layout those containers are using. | ||
|
||
## INSTALLATION | ||
wwwaiter requires an installation of the i3 window manager, perl, and the following two perl modules. | ||
|
||
* AnyEvent::I3 | ||
* X11::Protocol | ||
|
||
## USAGE | ||
Just run it. | ||
|
||
## EXAMPLES | ||
|
||
$ i3tree | ||
Workspace 1 (horizontal) | ||
Window foo@bar: ~ | ||
Split (vertical) | ||
Window foo@bar: ~ | ||
Window foo@bar: ~ | ||
Workspace 2 (vertical) | ||
Window foo@bar: ~ | ||
Window foo@bar: ~ | ||
|
||
## LIMITATIONS | ||
You have to start i3tree from a running terminal. It would be neat if i3tree could be invoked from a keyboard shortcut and draw to a floating window. | ||
|
||
i3tree shows containers from all workspaces. It could be useful to optionally limit this to only the current workspace. | ||
|
||
## THANKS | ||
Thanks to everyone who has contributed to i3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use AnyEvent::I3; | ||
use X11::Protocol; | ||
|
||
# get path to i3 socket by reading property of X11 root window | ||
my $x = X11::Protocol->new(); | ||
my ( $value, $mtype, $format, $bytes_after ) = | ||
$x->GetProperty( $x->root, $x->atom('I3_SOCKET_PATH'), | ||
'AnyPropertyType', 0, -1, 0 ); | ||
|
||
my $i3 = i3($value); | ||
$i3->connect->recv or die "Error connecting"; | ||
|
||
# use number rather than constant to support older versions of anyevent::i3 | ||
my $tree = $i3->message(4)->recv; | ||
|
||
sub display_node { | ||
my ( $description, $depth ) = @_; | ||
my $margin = "\t" x $depth; | ||
print $margin . $description . "\n"; | ||
return $depth + 1; | ||
} | ||
|
||
sub walk_tree { | ||
my ( $node, $depth ) = @_; | ||
|
||
my $type = $node->{'type'}; | ||
my $orientation = $node->{'orientation'}; | ||
my $name = $node->{'name'}; | ||
|
||
if ( $type == 4 ) { | ||
$depth = display_node( "Workspace $name ($orientation)", $depth ); | ||
} | ||
|
||
if ( $type == 2 ) { | ||
if ( $orientation eq "none" ) { | ||
unless ( $name eq "content" or $name =~ "^i3bar" ) { | ||
$depth = display_node( "Window $name", $depth ); | ||
} | ||
} | ||
else { | ||
$depth = display_node( "Split ($orientation)", $depth ); | ||
} | ||
} | ||
|
||
foreach ( @{ $node->{'nodes'} } ) { | ||
walk_tree( $_, $depth ); | ||
} | ||
} | ||
|
||
walk_tree( $tree, 0 ); | ||
|