/
focus.py
executable file
·46 lines (37 loc) · 1009 Bytes
/
focus.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
#!/bin/python
import i3
def find_tmp():
tmps = i3.filter(nodes=[], window=None, name=None)
if len(tmps) != 1:
return None
return tmps[0]['id']
def create_tmp(current_id):
i3.focus(con_id=current_id)
i3.split('vertical')
i3.open()
def destroy_tmp(tmp_id):
i3.kill(con_id=tmp_id)
def make_float(current_id):
i3.focus(con_id=current_id)
i3.floating('enable')
i3.resize('set 1000 1000')
i3.move('position center')
def make_unfloat(current_id):
i3.focus(con_id=current_id)
i3.floating('disable')
def main():
current = i3.filter(nodes=[], focused=True)[0]
current_id = current['id']
if "on" in current['floating']:
tmp_id = find_tmp()
if tmp_id != None:
i3.focus(con_id=tmp_id)
make_unfloat(current_id)
destroy_tmp(tmp_id)
else:
make_unfloat()
else:
if find_tmp() == None:
create_tmp(current_id)
make_float(current_id)
main()