-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_i3layout.py
executable file
·57 lines (46 loc) · 1.75 KB
/
print_i3layout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/env python3
# Print a semi-formatted layout of your i3 workspaces (including scratchpad,
# etc)
import i3ipc
def find_nodes(init_node, depth=1):
for node in init_node.nodes:
try:
if depth ==1:
print(" |-"*depth + node.name )
#print("id: " + node.window)
else:
print(" "*depth + "|-" + node.name)
#print("id: " + node.window)
except:
if depth ==1:
print(" |-"*depth + node.layout)
else:
print(" "*depth + "|-" + node.layout)
find_nodes(node, depth+1)
for node in init_node.floating_nodes:
try:
if depth ==1:
print(" |-"*depth + node.name + " [floating]")
#print("id: " + node.window)
else:
print(" "*depth + "|-" + node.name + " [floating]")
#print("id: " + node.window)
except:
if depth ==1:
print(" |-"*depth + node.layout + " [floating]")
else:
print(" "*depth + "|-" + node.layout + " [floating]")
find_nodes(node, depth+1)
i3 = i3ipc.Connection()
tree = i3.get_tree()
itertree = iter(tree.nodes)
for monitor in itertree:
print("Monitor:", monitor.name, monitor.rect.x, monitor.rect.y, monitor.rect.width, monitor.rect.height)
if monitor.name == '__i3':
for workspace in monitor.nodes[0].nodes:
print(" |-workspace:", workspace.name, "layout:", workspace.layout)
find_nodes(workspace)
else:
for workspace in monitor.nodes[1].nodes:
print(" |-workspace:", workspace.name, "layout:", workspace.layout)
find_nodes(workspace)