3

I am new to terminator, where I need to launch 4 terminal. I have a script run1.sh which I want to run on first two terminal simultaneously and script run2.sh in other two terminal simultaneously.

enter image description here

But I want to launch the above four terminal by some script let say by script start.sh so that it itself start the terminator and split the terminator in four window and run the script run1.sh in first two window and run2.sh in other two window. Please suggest me relevant approach (it could be any python/bash/perl), as I could able to start the four window of terminator by manually and executing the command separately, which I want to do by some script. Thanks in advance!!

0
2

The following shellscript works for me in Ubuntu 18.04 LTS. If you have another desktop environment, you should edit the script's wcorr and hcorr values in order to match the screen.

I suggest the name l4t for the shellscript,

#!/bin/bash

wcorr=68  # manual fix for vertical panels
hcorr=26  # manual fix for horizontal panels


tmps=$(LANG=C xrandr|grep -om1 'current.*,')
tmps=${tmps/,}
tmps=${tmps/current }
echo "screen resolution = $tmps pixels"
wscr=${tmps/ x*}
hscr=${tmps/*x }
wter=$(( (wscr-wcorr)/2 ))
hter=$(( (hscr-hcorr)/2 ))
echo "terminal width  = $wter pixels"
echo "terminal height = $hter pixels"

terminator --borderless --geometry="${wter}x${hter}+0+0" -x run1.sh &
terminator --borderless --geometry="${wter}x${hter}+0-0" -x run1.sh &
terminator --borderless --geometry="${wter}x${hter}-0+0" -x run2.sh &
terminator --borderless --geometry="${wter}x${hter}-0-0" -x run2.sh &

I have tested the function with the following scripts run1.sh and run1.sh

run1.sh:

#!/bin/bash

cnt=0
while [ $cnt -lt 10 ]
do
 echo -n "$cnt"
 sleep 1
 cnt=$((cnt+1))
done
echo ""
bash

run1.sh:

#!/bin/bash

cnt=9
while [ $cnt -ge 0 ]
do
 echo -n "$cnt"
 sleep 1
 cnt=$((cnt-1))
done
echo ""
bash

I put a bash command at the end of these scripts. Otherwise the terminal windows would be closed after the scripts have finished. You may want to do something else.

Make the three shellscripts executable

chmod +x l4t run1.sh run2.sh

and move them to a directory in PATH,

mv l4t run1.sh run2.sh /usr/local/bin/

Now you can run them just with the name like any other command.

l4t
3
  • Thanks for your quick reply. But you did not mentioned how to start run1.sh and run2.sh from the above script ?
    – Ratnesh
    Mar 17 '19 at 15:08
  • 1
    @Arya, I have modified my answer to include running those scripts. Does it work as you want it to work?
    – sudodus
    Mar 17 '19 at 17:26
  • @Arya, I added the option --borderless and modified hcorr, which means that the [outer] title bar of the window is removed and there is more space for lines in each terminator window.
    – sudodus
    Mar 17 '19 at 20:37
1

Perhaps you could give a try to tmux with tmuxinator

sudo apt install tmux tmuxinator

https://github.com/tmux/tmux/

https://tmuxcheatsheet.com/

https://github.com/tmuxinator/tmuxinator

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.