70 lines
2 KiB
Python
70 lines
2 KiB
Python
# 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(' '))
|