From ec6bff26f91b30344fd66e7d7da7891fe4dd262f Mon Sep 17 00:00:00 2001 From: m Date: Thu, 16 Dec 2021 17:38:39 +0100 Subject: [PATCH 1/4] Added skeleton code for Konsole support --- apply-colors.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apply-colors.sh b/apply-colors.sh index b908d2e..90960e8 100755 --- a/apply-colors.sh +++ b/apply-colors.sh @@ -540,6 +540,13 @@ apply_kitty() { echo "Done - please reopen your kitty terminal to see the changes" } +apply_konsole() { + # | + # | Applying values on Konsole + # | =========================================== + +} + apply_darwin() { # | # | Applying values on iTerm2 @@ -898,6 +905,10 @@ case "${TERMINAL}" in apply_kitty ;; + konsole ) + apply_konsole + ;; + * ) printf '%s\n' \ "Unsupported terminal!" \ From ff15f921a4970714a05798e0c2fed5db285ca914 Mon Sep 17 00:00:00 2001 From: m Date: Thu, 16 Dec 2021 18:52:06 +0100 Subject: [PATCH 2/4] Implemented support for Konsole; no profiles though --- apply-colors.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/apply-colors.sh b/apply-colors.sh index 90960e8..b11c84e 100755 --- a/apply-colors.sh +++ b/apply-colors.sh @@ -39,7 +39,7 @@ GLOBAL_VAR_CLEANUP() { unset PROFILE_NAME } -# Note: Since all scripts gets invoked in a subshell the traps from the parent shell +# Note: Since all scripts gets invoked in a subshell the traps from the parent shell # will not get inherited. Hence traps defined in gogh.sh and print-themes.sh will still trigger trap 'GLOBAL_VAR_CLEANUP; trap - EXIT' EXIT HUP INT QUIT PIPE TERM @@ -198,6 +198,26 @@ updateFootConfig () { sed -i -r -e "s/^${name}=.+/${name}=${color/\#/}/g" "${config}" } +createKonsoleEntry () { + local name="${1}" + local color="${2}" + set -- + set -- $(hexRGBtoDecRGB "${color}") + R=${1}; shift; G=${1}; shift; B=${1}; shift + + echo -e "[$name]\nColor=${R},${G},${B}\n" +} + +createKonsoleTriple () { + local name="${1}" + local colorn="${2}" # normal and faint + local colori="${3}" # intense + + createKonsoleEntry "${name}" "${colorn}" + createKonsoleEntry "${name}Faint" "${colorn}" + createKonsoleEntry "${name}Intense" "${colori}" +} + convertNameAndRGBtoITerm() { local name="${1}" local color="${2}" @@ -220,7 +240,7 @@ dlist_append() { local key="${1}"; shift local val="${1}"; shift local entries - + entries="$( { "${DCONF}" read "${key}" | tr -d "[]" | tr , "\n" | grep -F -v "${val}" @@ -544,7 +564,39 @@ apply_konsole() { # | # | Applying values on Konsole # | =========================================== - + + if [[ -z "${XDG_DATA_HOME:-}" ]]; then + KDIR="${HOME}/.local/share/konsole" + else + KDIR="${XDG_DATA_HOME}/konsole" + fi + + KPROFILE="${KDIR}/${PROFILE_NAME}.colorscheme" + echo "Updating color theme file (${KPROFILE}) with theme ..." + if [[ -f "${KPROFILE}" ]]; then + echo "Profile ${PROFILE_NAME} already exists in Konsole confiuration (${KONSOLE_DIR}); Skipping ..." + exit 0 + fi + + touch "${KPROFILE}" + createKonsoleTriple "Background" "${BACKGROUND_COLOR}" "${BACKGROUND_COLOR}" >> "${KPROFILE}" + createKonsoleTriple "Color0" "${COLOR_01}" "${COLOR_09}" >> "${KPROFILE}" + createKonsoleTriple "Color1" "${COLOR_02}" "${COLOR_10}" >> "${KPROFILE}" + createKonsoleTriple "Color2" "${COLOR_03}" "${COLOR_11}" >> "${KPROFILE}" + createKonsoleTriple "Color3" "${COLOR_04}" "${COLOR_12}" >> "${KPROFILE}" + createKonsoleTriple "Color4" "${COLOR_05}" "${COLOR_13}" >> "${KPROFILE}" + createKonsoleTriple "Color5" "${COLOR_06}" "${COLOR_14}" >> "${KPROFILE}" + createKonsoleTriple "Color6" "${COLOR_07}" "${COLOR_15}" >> "${KPROFILE}" + createKonsoleTriple "Color7" "${COLOR_08}" "${COLOR_16}" >> "${KPROFILE}" + createKonsoleTriple "Foreground" "${FOREGROUND_COLOR}" "${FOREGROUND_COLOR}" >> "${KPROFILE}" + echo "[General]" >> "${KPROFILE}" + echo "Blur=false" >> "${KPROFILE}" + echo "ColorRandomization=false" >> "${KPROFILE}" + echo "Description=${PROFILE_NAME}" >> "${KPROFILE}" + echo "Opacity=1" >> "${KPROFILE}" + echo "Wallpaper=" >> "${KPROFILE}" + + echo "Done - please change your profile by going to Settings > Manage Profiles... > Edit... > Appearance" } apply_darwin() { @@ -586,7 +638,7 @@ apply_gtk() { # | =========================================== local legacy="${1:-}" - + # This is to avoid doing the profile loop definition twice if [[ -z "${legacy}" ]]; then CONFTOOL="${DCONF} read" @@ -605,7 +657,7 @@ apply_gtk() { fi done - # Fallback if there is no default profile + # Fallback if there is no default profile set -- $(${CONFTOOL} ${PROFILE_LIST_KEY} | tr "[]'," " ") : ${DEFAULT_SLUG:="$1"} From 8f191c713e6e083d64b799fba7a5e174041294f6 Mon Sep 17 00:00:00 2001 From: m Date: Thu, 16 Dec 2021 19:22:57 +0100 Subject: [PATCH 3/4] added support for konsole --- apply-colors.sh | 58 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/apply-colors.sh b/apply-colors.sh index b11c84e..e596ab7 100755 --- a/apply-colors.sh +++ b/apply-colors.sh @@ -130,6 +130,14 @@ case "${TERMINAL}" in exit 1 fi ;; + + konsole ) + CFGFILE="${HOME}/.config/konsolerc" + if [[ ! -f "${CFGFILE}" ]]; then + printf '\n%s\n' "Error: Couldn't find an existing configuration file for Konsole." + exit 1 + fi + ;; esac @@ -565,38 +573,50 @@ apply_konsole() { # | Applying values on Konsole # | =========================================== + PARENT=$(grep -o "^DefaultProfile=.*$" ${CFGFILE} | cut -d '=' -f 2) + if [[ -z "${PARENT}" ]]; then + PARENT="FALLBACK/" + fi + if [[ -z "${XDG_DATA_HOME:-}" ]]; then KDIR="${HOME}/.local/share/konsole" else KDIR="${XDG_DATA_HOME}/konsole" fi - KPROFILE="${KDIR}/${PROFILE_NAME}.colorscheme" - echo "Updating color theme file (${KPROFILE}) with theme ..." + KPROFILE="${KDIR}/${PROFILE_NAME}.profile" if [[ -f "${KPROFILE}" ]]; then echo "Profile ${PROFILE_NAME} already exists in Konsole confiuration (${KONSOLE_DIR}); Skipping ..." exit 0 fi touch "${KPROFILE}" - createKonsoleTriple "Background" "${BACKGROUND_COLOR}" "${BACKGROUND_COLOR}" >> "${KPROFILE}" - createKonsoleTriple "Color0" "${COLOR_01}" "${COLOR_09}" >> "${KPROFILE}" - createKonsoleTriple "Color1" "${COLOR_02}" "${COLOR_10}" >> "${KPROFILE}" - createKonsoleTriple "Color2" "${COLOR_03}" "${COLOR_11}" >> "${KPROFILE}" - createKonsoleTriple "Color3" "${COLOR_04}" "${COLOR_12}" >> "${KPROFILE}" - createKonsoleTriple "Color4" "${COLOR_05}" "${COLOR_13}" >> "${KPROFILE}" - createKonsoleTriple "Color5" "${COLOR_06}" "${COLOR_14}" >> "${KPROFILE}" - createKonsoleTriple "Color6" "${COLOR_07}" "${COLOR_15}" >> "${KPROFILE}" - createKonsoleTriple "Color7" "${COLOR_08}" "${COLOR_16}" >> "${KPROFILE}" - createKonsoleTriple "Foreground" "${FOREGROUND_COLOR}" "${FOREGROUND_COLOR}" >> "${KPROFILE}" - echo "[General]" >> "${KPROFILE}" - echo "Blur=false" >> "${KPROFILE}" - echo "ColorRandomization=false" >> "${KPROFILE}" - echo "Description=${PROFILE_NAME}" >> "${KPROFILE}" - echo "Opacity=1" >> "${KPROFILE}" - echo "Wallpaper=" >> "${KPROFILE}" + echo -e "[Appearance]\nColorScheme=${PROFILE_NAME}\n" >> "${KPROFILE}" + echo -e "[General]\nName=${PROFILE_NAME}\nParent=$PARENT" >> "${KPROFILE}" - echo "Done - please change your profile by going to Settings > Manage Profiles... > Edit... > Appearance" + KCOLORSCHEME="${KDIR}/${PROFILE_NAME}.colorscheme" + if [[ -f "${KCOLORSCHEME}" ]]; then + echo "Color Scheme ${PROFILE_NAME} already exists in Konsole confiuration (${KONSOLE_DIR}); Skipping ..." + exit 0 + fi + + touch "${KCOLORSCHEME}" + createKonsoleTriple "Background" "${BACKGROUND_COLOR}" "${BACKGROUND_COLOR}" >> "${KCOLORSCHEME}" + createKonsoleTriple "Color0" "${COLOR_01}" "${COLOR_09}" >> "${KCOLORSCHEME}" + createKonsoleTriple "Color1" "${COLOR_02}" "${COLOR_10}" >> "${KCOLORSCHEME}" + createKonsoleTriple "Color2" "${COLOR_03}" "${COLOR_11}" >> "${KCOLORSCHEME}" + createKonsoleTriple "Color3" "${COLOR_04}" "${COLOR_12}" >> "${KCOLORSCHEME}" + createKonsoleTriple "Color4" "${COLOR_05}" "${COLOR_13}" >> "${KCOLORSCHEME}" + createKonsoleTriple "Color5" "${COLOR_06}" "${COLOR_14}" >> "${KCOLORSCHEME}" + createKonsoleTriple "Color6" "${COLOR_07}" "${COLOR_15}" >> "${KCOLORSCHEME}" + createKonsoleTriple "Color7" "${COLOR_08}" "${COLOR_16}" >> "${KCOLORSCHEME}" + createKonsoleTriple "Foreground" "${FOREGROUND_COLOR}" "${FOREGROUND_COLOR}" >> "${KCOLORSCHEME}" + echo "[General]" >> "${KCOLORSCHEME}" + echo "Blur=false" >> "${KCOLORSCHEME}" + echo "ColorRandomization=false" >> "${KCOLORSCHEME}" + echo "Description=${PROFILE_NAME}" >> "${KCOLORSCHEME}" + echo "Opacity=1" >> "${KCOLORSCHEME}" + echo "Wallpaper=" >> "${KCOLORSCHEME}" } apply_darwin() { From 0408e99b35eb320daf59602e7932bc5336f58da6 Mon Sep 17 00:00:00 2001 From: m Date: Fri, 17 Dec 2021 17:07:10 +0100 Subject: [PATCH 4/4] Added 'konsole' to the list of supported terminals --- apply-colors.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/apply-colors.sh b/apply-colors.sh index e596ab7..e5087e5 100755 --- a/apply-colors.sh +++ b/apply-colors.sh @@ -996,6 +996,7 @@ case "${TERMINAL}" in " xfce4-terminal" \ " foot" \ " kitty" \ + " konsole" \ "" \ "If you believe you have recieved this message in error," \ "try manually setting \`TERMINAL', hint: ps -h -o comm -p \$PPID"