-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmux.py
More file actions
executable file
·41 lines (33 loc) · 1.24 KB
/
tmux.py
File metadata and controls
executable file
·41 lines (33 loc) · 1.24 KB
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
#!python
import os
import sys
cluster=[
[101, 102, 103, 104],
[105, 106, 107, 108],
[109, 110, 111, 112],
[113, 114, 115, 116]
]
if "--test" in sys.argv:
command = lambda system: "\"uptime && sleep 5\""
if "--hostname" in sys.argv:
command = lambda system: f"\"scp htoprc {sys.argv[sys.argv.index('--hostname')+1]}:~/.config/htop/htoprc && ssh {sys.argv[sys.argv.index('--hostname')+1]} -t 'htop'\""
else:
command = lambda system: f"\"scp htoprc dietpi@192.168.0.{system}:/home/dietpi/.config/htop/htoprc && ssh dietpi@192.168.0.{system} -t 'htop'\""
# create the initial tmux vertical frames
for stack in cluster:
if stack[0] == cluster[0][0]:
print("creating session")
os.system(f"tmux new-session -s cluster -d {command(stack[0])}")
else:
print("splitting section")
os.system(f"tmux split-window {command(stack[0])}")
for i, stack in enumerate(cluster):
print(f"switching to {i*4}")
os.system(f"tmux select-pane -t {i*4}")
for system in stack[1:]:
print("creating new section")
os.system(f"tmux split-window -h {command(system)}")
print("setting layout")
os.system("tmux select-layout tiled")
if not "--dont-attach" in sys.argv:
os.system("tmux attach")