-
Notifications
You must be signed in to change notification settings - Fork 606
/
apply-terminator.py
executable file
·54 lines (40 loc) · 1.93 KB
/
apply-terminator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import json
import os
import sys
from configobj import ConfigObj
def main(gogh_conf_theme):
terminator_conf_file_path = get_terminator_conf_path()
profile_options = choose_profile()
update_terminator_conf(terminator_conf_file_path, gogh_conf_theme, profile_options)
def get_terminator_conf_path():
try:
configdir = os.environ['XDG_CONFIG_HOME']
except KeyError:
configdir = os.path.join(os.path.expanduser('~'), '.config')
return(os.path.join(configdir, 'terminator/config'))
def update_terminator_conf(terminator_conf_file_path,gogh_conf_theme,profile_options):
js = json.loads(gogh_conf_theme)
config = ConfigObj(terminator_conf_file_path)
if profile_options["copy_default_config"] == 'yes':
config['profiles'][profile_options["profile"]] = config['profiles']['default']
elif profile_options["copy_default_config"] == 'no':
config['profiles'][profile_options["profile"]] = {}
use_theme_colors = False
config['profiles'][profile_options["profile"]]['foreground_color'] = js['colors']['primary']['foreground']
config['profiles'][profile_options["profile"]]['background_color'] = js['colors']['primary']['background']
config['profiles'][profile_options["profile"]]['palette'] = js['colors']['pallete']
config.write()
def choose_profile():
profile_answer = ''
copy_default_config_answer = ''
profile_answer = input("Enter profile to update/create [default]: ")
if profile_answer.lower() in ['', 'default']:
profile_answer = 'default'
else:
copy_default_config_answer = input("Do you want to copy your config from default profile? [Y]: (Y/N) ")
if copy_default_config_answer.lower() in ['', 'yes', 'y']:
copy_default_config_answer = 'yes'
else:
copy_default_config_answer = 'no'
return {"profile": profile_answer, "copy_default_config": copy_default_config_answer}
main(sys.argv[1])