Skip to content
Snippets Groups Projects
Commit 7a493c18 authored by jkerdreu's avatar jkerdreu
Browse files

Missing for running xAAL in tmux

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@2262 b32b6428-25c9-4566-ad07-03861ab6144f
parent 2331e0a0
No related branches found
No related tags found
No related merge requests found
import os
LAYOUT="tiled"
class Tmux(object):
def __init__(self,session_name,sync='off'):
self.start = False
self.sync = sync
self.name = session_name
def exec(self,tmux_cmd):
cmd = "tmux %s" % tmux_cmd
#print(cmd)
os.system(cmd)
def add_pane(self,cmd):
if self.start == False:
self.exec('new-session -d -s "%s" -n "%s" "%s" -T' % (self.name,self.name,cmd,cmd))
#self.exec('select-pane -T "%s"' % cmd)
self.start = True
else:
self.exec('split-window -t "%s" "%s" && tmux select-layout -t "%s" "%s"' % (self.name,cmd,self.name,LAYOUT))
self.exec('select-pane -T "%s"' % cmd)
def add_window(self,title,path,cmd):
if self.start == False:
self.exec('new-session -d -s "%s" -n "%s" -c "%s" "%s"' % (self.name,title,path,cmd))
self.start = True
else:
self.exec('new-window -t "%s" -n "%s" -c "%s" "%s"' % (self.name,title,path,cmd))
def run(self):
self.exec('set-window-option -t "%s" synchronize-panes %s' % (self.name,self.sync))
self.exec('set-option -g mouse on')
#self.exec('attach-session -t "%s"' % self.name)
if __name__ == '__main__':
s = Tmux('Foobar',sync='on')
hosts = ['dns','mail-01','munin','proxy','web-01']
for h in hosts:
s.add_pane('sudo lxc-attach -n %s' %h)
s.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment