Skip to content

Commit

Permalink
added terminator support
Browse files Browse the repository at this point in the history
  • Loading branch information
gabsbandeira committed Feb 13, 2024
1 parent eae7348 commit b833f00
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
46 changes: 45 additions & 1 deletion apply-colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1077,6 +1117,10 @@ case "${TERMINAL}" in
apply_alacritty
;;

terminator )
apply_terminator
;;

foot )
apply_foot
;;
Expand All @@ -1099,7 +1143,7 @@ case "${TERMINAL}" in

* )
printf '%s\n' \
"Unsupported terminal!" \
"Unsupported terminal! ${TERMINAL}" \
"" \
"Supported terminals:" \
" mintty and deriviates" \
Expand Down
24 changes: 24 additions & 0 deletions apply-terminator.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit b833f00

Please sign in to comment.