commit 3ae8a9a4f3fc675ad703553f3608d5e4b89908da Author: Arthur 'Grizzly' Grisel-Davy Date: Sun May 2 17:35:03 2021 +0200 Initial commit, script, params and template diff --git a/jumpstart.py b/jumpstart.py new file mode 100644 index 0000000..0b6ffc5 --- /dev/null +++ b/jumpstart.py @@ -0,0 +1,70 @@ +# coding: utf-8 +# Author: Arthur 'Grizzly' Grisel-Davy + +import subprocess +import json + +def get_command(options): + command = 'tilix' + + # Directory + if options['dir']: + command+=" -w {}".format(options['dir']) + + # Name + if options['name']: + command +=" -t {}".format(options['name']) + + # Dimension absolute + if 'dimensions_abs' in options.keys(): + command+=" --geometry={}x{}+{}+{}".format(options['dimensions_abs']['W'], + options['dimensions_abs']['H'], + options['dimensions_abs']['pos_W'], + options['dimensions_abs']['pos_H']) + # Dimension Relative + if 'dimensions_rel' in options.keys(): + + with open(params_path,'r') as f: + params = json.loads(f.read()) + + L,C,H,W = 0,0,0,0 + if 'bottom' in options['dimensions_rel']: + H = int(params["height"]/2) + if 'right' in options['dimensions_rel']: + W = int(params["width"]/2) + + if 'half_width' in options['dimensions_rel']: + C = int(params['colones']/2) + else: + C = params['colones'] + + if 'half_height' in options['dimensions_rel']: + L = int(params['lignes']/2) + else: + L = params['lignes'] + + command+=" --geometry={}x{}+{}+{}".format(C,L,W,H) + + # Command (must be last!) + if 'command' in options.keys(): + command += " -e {}".format(options['command']) + + + + return(command) + +if __name__ == "__main__": + templates_dir = './templates/' + params_path = './params.json' + + template = 'eet2.json' + + with open(templates_dir+template,'r') as f: + options = json.loads(f.read()) + + for fen in options['fenetres']: + print(fen) + print("Lancement de {}:".format(fen['name'])) + command = get_command(fen) + print("Using command: \n{}".format(command)) + subprocess.call(command.split(' ')) diff --git a/params_default.json b/params_default.json new file mode 100644 index 0000000..d24228a --- /dev/null +++ b/params_default.json @@ -0,0 +1,6 @@ +{ + "height":1080, + "width":1920, + "colones":240, + "lignes":55 +} diff --git a/templates/template_default.json b/templates/template_default.json new file mode 100644 index 0000000..eaf4fe3 --- /dev/null +++ b/templates/template_default.json @@ -0,0 +1,16 @@ +{ + "fenetres":[ + { + "name":"Code", + "dir":"~", + "dimensions_rel":"left half_width", + "command":"man ssh" + }, + { + "name":"Run", + "dir":"~", + "dimensions_rel":"right top half_width half_height", + "command":"make" + } + ] +}