From 11cbbf04e74a99c1730155fca2cbc405529e26c0 Mon Sep 17 00:00:00 2001 From: Gabis Bandeira Date: Tue, 13 Feb 2024 17:30:44 -0300 Subject: [PATCH] fixed to choose profile --- README.md | 1 + apply-colors.sh | 3 ++- apply-terminator.py | 48 ++++++++++++++++++++++++++++++++++++--------- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b81f6845..996bda68 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ cd installs - Pantheon / Elementary - [Web](https://github.com/elementary/terminal) - Tilix - [Web](https://gnunn1.github.io/tilix-web/) - XFCE4 - [Web](https://docs.xfce.org/apps/terminal/start) +- Terminator - [Web](https://github.com/gnome-terminator/terminator)
diff --git a/apply-colors.sh b/apply-colors.sh index 1f4e0f4a..2d540922 100755 --- a/apply-colors.sh +++ b/apply-colors.sh @@ -1143,7 +1143,7 @@ case "${TERMINAL}" in * ) printf '%s\n' \ - "Unsupported terminal! ${TERMINAL}" \ + "Unsupported terminal!" \ "" \ "Supported terminals:" \ " mintty and deriviates" \ @@ -1159,6 +1159,7 @@ case "${TERMINAL}" in " kmscon" \ " konsole" \ " linux" \ + " terminator" \ "" \ "If you believe you have received this message in error," \ "try manually setting \`TERMINAL', hint: ps -h -o comm -p \$PPID" diff --git a/apply-terminator.py b/apply-terminator.py index e812fef7..857222e9 100755 --- a/apply-terminator.py +++ b/apply-terminator.py @@ -4,21 +4,51 @@ from configobj import ConfigObj -def get_conf_path(): +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')) -# end -conf_path = get_conf_path() +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} -js = json.loads(sys.argv[1]) -config = ConfigObj(conf_path) -config['profiles']['default']['foreground_color'] = js['colors']['primary']['foreground'] -config['profiles']['default']['background_color'] = js['colors']['primary']['background'] -config['profiles']['default']['palette'] = js['colors']['pallete'] -config.write() +main(sys.argv[1]) \ No newline at end of file