-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartAuto.py
More file actions
30 lines (24 loc) · 1 KB
/
startAuto.py
File metadata and controls
30 lines (24 loc) · 1 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
import libtmux
import os
import sys
def run_tmux_auto_control():
try:
# Connect to the tmux server or create a new one
server = libtmux.Server()
# Create a new session named 'auto_control'
session_name = 'auto_control'
if server.has_session(session_name):
print("Session '{}' already exists. Killing it and creating a new one.".format(session_name))
server.kill_session(session_name)
session = server.new_session(session_name)
# Run 'auto_control.py' in the 'auto_control' session
window = session.attached_window
pane = window.attached_pane
pane.send_keys('python {0}'.format(os.path.abspath("auto_control.py")))
print("auto_control.py is running in tmux session: '{}'.".format(session_name))
print("View session using tmux a -t auto_control")
except Exception as e:
sys.stderr.write("Error: {}\n".format(e))
sys.exit(1)
if __name__ == "__main__":
run_tmux_auto_control()