#!/usr/bin/env python3
import os,sys,time,subprocess,pathlib
root=pathlib.Path(__file__).resolve().parent; side=sys.argv[1]
video=root/(side+'.mp4')
p=subprocess.Popen(['ffmpeg','-y','-loglevel','error','-f','x11grab','-video_size','1440x900','-framerate','12','-i',os.environ['DISPLAY'],'-c:v','libx264','-preset','ultrafast','-crf','20','-pix_fmt','yuv420p',str(video)],stdin=subprocess.PIPE)
try:
 subprocess.run(['gnome-terminal','--wait','--geometry=130x40+0+0','--hide-menubar','--zoom=1.2','--','bash',str(root/'terminal.sh'),side],check=True)
finally:
 p.communicate(b'q\n');
