From b833f00b7ef27b291f5d2dfddfd1daeaf49268ec Mon Sep 17 00:00:00 2001 From: Gabis Bandeira Date: Tue, 13 Feb 2024 13:12:14 -0300 Subject: [PATCH] added terminator support --- apply-colors.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++- apply-terminator.py | 24 +++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100755 apply-terminator.py diff --git a/apply-colors.sh b/apply-colors.sh index f95d3c12..1f4e0f4a 100755 --- a/apply-colors.sh +++ b/apply-colors.sh @@ -530,6 +530,46 @@ apply_alacritty() { } +apply_terminator() { + # | + # | Applying values on Alacritty + # | =========================================== + + json_str="\ + { \ + \"colors\": \ + {\ + \"primary\":\ + {\ + \"background\": \"$BACKGROUND_COLOR\",\ + \"foreground\": \"$FOREGROUND_COLOR\"\ + },\ + \"pallete\":\"${COLOR_01}:${COLOR_02}:${COLOR_03}:${COLOR_04}:${COLOR_05}:${COLOR_06}:${COLOR_07}:${COLOR_08}:${COLOR_09}:${COLOR_10}:${COLOR_11}:${COLOR_12}:${COLOR_13}:${COLOR_14}:${COLOR_15}:${COLOR_16}\" + }\ + }" + + SCRIPT_PATH="${SCRIPT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}" + PARENT_PATH="$(dirname "${SCRIPT_PATH}")" + + # Allow developer to change url to forked url for easier testing + # IMPORTANT: Make sure you export this variable if your main shell is not bash + BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/Gogh-Co/Gogh/master"} + + + if [[ -e "${SCRIPT_PATH}/apply-terminator.py" ]]; then + python3 "${SCRIPT_PATH}/apply-terminator.py" "$json_str" + else + if [[ "$(uname)" = "Darwin" ]]; then + # OSX ships with curl and ancient bash + python3 -c "$(curl -so- "${BASE_URL}/apply-terminator.py")" "$json_str" + else + # Linux ships with wget + python3 -c "$(wget -qO- "${BASE_URL}/apply-terminator.py")" "$json_str" + fi + fi + +} + apply_foot() { # | # | Applying values on foot @@ -1077,6 +1117,10 @@ case "${TERMINAL}" in apply_alacritty ;; + terminator ) + apply_terminator + ;; + foot ) apply_foot ;; @@ -1099,7 +1143,7 @@ case "${TERMINAL}" in * ) printf '%s\n' \ - "Unsupported terminal!" \ + "Unsupported terminal! ${TERMINAL}" \ "" \ "Supported terminals:" \ " mintty and deriviates" \ diff --git a/apply-terminator.py b/apply-terminator.py new file mode 100755 index 00000000..e812fef7 --- /dev/null +++ b/apply-terminator.py @@ -0,0 +1,24 @@ +import json +import os +import sys + +from configobj import ConfigObj + +def get_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() + +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()