Initial commit, script, params and template
This commit is contained in:
commit
3ae8a9a4f3
3 changed files with 92 additions and 0 deletions
70
jumpstart.py
Normal file
70
jumpstart.py
Normal file
|
@ -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(' '))
|
6
params_default.json
Normal file
6
params_default.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"height":1080,
|
||||
"width":1920,
|
||||
"colones":240,
|
||||
"lignes":55
|
||||
}
|
16
templates/template_default.json
Normal file
16
templates/template_default.json
Normal file
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue