From b7739b8ee812cb3ac22ec328b11a9d32441a02ba Mon Sep 17 00:00:00 2001 From: pfuender Date: Thu, 5 Aug 2021 22:02:31 +0200 Subject: [PATCH] adding support for foot terminal (https://codeberg.org/dnkl/foot) --- apply-colors.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/apply-colors.sh b/apply-colors.sh index 8f6127a..134e89e 100755 --- a/apply-colors.sh +++ b/apply-colors.sh @@ -110,6 +110,14 @@ case "${TERMINAL}" in fi ;; + foot ) + CFGFILE="${HOME}/.config/foot/foot.ini" + if [[ ! -f "${CFGFILE}" ]]; then + printf '\n%s\n' "Error: Couldn't find an existing configuration file." + exit 1 + fi + ;; + esac @@ -170,6 +178,14 @@ updateMinttyConfig () { sed -i -r -e "s/^${name}=.+/$(createMinttyEntry "${name}" "${color}")/g" "${config}" } +updateFootConfig () { + local config="${1}" + local color="${2}" + local name="${3}" + + sed -i -r -e "s/^${name}=.+/${name}=${color/\#/}/g" "${config}" +} + convertNameAndRGBtoITerm() { local name="${1}" local color="${2}" @@ -428,11 +444,43 @@ apply_alacritty() { } +apply_foot() { + # | + # | Applying values on foot + # | =========================================== + + echo "Patching foot configuration file (${CFGFILE}) with new colors..." + + updateFootConfig "$CFGFILE" "$COLOR_01" "regular0" + updateFootConfig "$CFGFILE" "$COLOR_02" "regular1" + updateFootConfig "$CFGFILE" "$COLOR_03" "regular2" + updateFootConfig "$CFGFILE" "$COLOR_04" "regular3" + updateFootConfig "$CFGFILE" "$COLOR_05" "regular4" + updateFootConfig "$CFGFILE" "$COLOR_06" "regular5" + updateFootConfig "$CFGFILE" "$COLOR_07" "regular6" + updateFootConfig "$CFGFILE" "$COLOR_08" "regular7" + + updateFootConfig "$CFGFILE" "$COLOR_09" "bright0" + updateFootConfig "$CFGFILE" "$COLOR_10" "bright1" + updateFootConfig "$CFGFILE" "$COLOR_11" "bright2" + updateFootConfig "$CFGFILE" "$COLOR_12" "bright3" + updateFootConfig "$CFGFILE" "$COLOR_13" "bright4" + updateFootConfig "$CFGFILE" "$COLOR_14" "bright5" + updateFootConfig "$CFGFILE" "$COLOR_15" "bright6" + updateFootConfig "$CFGFILE" "$COLOR_16" "bright7" + + updateFootConfig "$CFGFILE" "$BACKGROUND_COLOR" "background" + updateFootConfig "$CFGFILE" "$FOREGROUND_COLOR" "foreground" + + echo "Done - please reopen your foot terminal to see the changes" + +} + apply_darwin() { # | # | Applying values on iTerm2 # | =========================================== - + BACKGROUND_COLOR=$(convertNameAndRGBtoITerm "Background Color" "$BACKGROUND_COLOR") FOREGROUND_COLOR=$(convertNameAndRGBtoITerm "Foreground Color" "$FOREGROUND_COLOR") COLOR_01=$(convertNameAndRGBtoITerm "Ansi 0 Color" "$COLOR_01") @@ -778,6 +826,10 @@ case "${TERMINAL}" in apply_alacritty ;; + foot ) + apply_foot + ;; + * ) printf '%s\n' \ "Unsupported terminal!" \ @@ -791,6 +843,7 @@ case "${TERMINAL}" in " gnome-terminal" \ " tilix" \ " xfce4-terminal" \ + " foot" \ "" \ "If you believe you have recieved this message in error," \ "try manually setting \`TERMINAL', hint: ps -h -o comm -p \$PPID"