scripts: Add cosmetic fixes
Unify indentation in 2 spaces
Quote more variables and values
By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.
Unify indentation in 2 spaces
Quote more variables and values
roundabout,
created on Saturday, 16 June 2018, 06:35:24 (1529130924),
received on Sunday, 11 May 2025, 13:22:26 (1746969746)
Author identity: nana-4 <hnmaigo@gmail.com>
9b8c2b27e4663e407d1a6bc17a890bfb602a440b
# shellcheck disable=SC1090 #set -x set -ueo pipefail SRC_PATH=$(readlink -f "$(dirname "$0")")SRC_PATH="$(readlink -f "$(dirname "$0")")"darker () {"$SRC_PATH/scripts/darker.sh" "$@"darker() { "$SRC_PATH/scripts/darker.sh" "$@"} mix () {"$SRC_PATH/scripts/mix.sh" "$@"mix() { "$SRC_PATH/scripts/mix.sh" "$@"} is_dark() { hexinput=$(tr '[:lower:]' '[:upper:]' <<< "$1")half_darker="$(darker "$hexinput" 88)"[[ "$half_darker" == "000000" ]]hexinput="$(tr '[:lower:]' '[:upper:]' <<< "$1")" half_darker="$(darker "$hexinput" 88)" [[ "$half_darker" == "000000" ]]} print_usage() { echo "usage: $0 [-o OUTPUT_THEME_NAME] [-p PATH_LIST] PATH_TO_PRESET"echo "examples:"# shellcheck disable=SC2028 # This is meant to be usage text.echo " $0 -o my-theme-name <(echo -e \"BG=d8d8d8\\nFG=101010\\nMENU_BG=3c3c3c\\nMENU_FG=e6e6e6\\nSEL_BG=ad7fa8\\nSEL_FG=ffffff\\nTXT_BG=ffffff\\nTXT_FG=1a1a1a\\nBTN_BG=f5f5f5\\nBTN_FG=111111\\n\")"echo " $0 ../colors/retro/twg"echo " $0 --hidpi True ../colors/retro/clearlooks"exit 1echo "usage: $0 [-o OUTPUT_THEME_NAME] [-p PATH_LIST] PATH_TO_PRESET" echo "examples:" # shellcheck disable=SC2028 # This is meant to be usage text. echo " $0 -o my-theme-name <(echo -e \"BG=d8d8d8\\nFG=101010\\nMENU_BG=3c3c3c\\nMENU_FG=e6e6e6\\nSEL_BG=ad7fa8\\nSEL_FG=ffffff\\nTXT_BG=ffffff\\nTXT_FG=1a1a1a\\nBTN_BG=f5f5f5\\nBTN_FG=111111\\n\")" echo " $0 ../colors/retro/twg" echo " $0 --hidpi True ../colors/retro/clearlooks" exit 1} while [[ "$#" -gt 0 ]] do case "$1" in-p|--path-list)CUSTOM_PATHLIST="$2"shift;;-o|--output)OUTPUT_THEME_NAME="$2"shift;;-d|--hidpi)OPTION_GTK2_HIDPI="$2"shift;;*)if [[ "$1" == -* ]] || [[ "${THEME-}" ]]; thenecho "unknown option $1"print_usageexit 2fiTHEME="$1";;esacshiftcase "$1" in -p|--path-list) CUSTOM_PATHLIST="$2" shift ;; -o|--output) OUTPUT_THEME_NAME="$2" shift ;; -d|--hidpi) OPTION_GTK2_HIDPI="$2" shift ;; *) if [[ "$1" == -* ]] || [[ "${THEME-}" ]]; then echo "unknown option $1" print_usage exit 2 fi THEME="$1" ;; esac shiftdone if [[ -z "${THEME:-}" ]] ; thenprint_usageif [[ -z "${THEME:-}" ]]; then print_usagefi PATHLIST=( './src/chrome''./src/cinnamon''./src/cinnamon/assets''./src/gnome-shell''./src/gtk-2.0/gtkrc''./src/gtk-2.0/gtkrc-dark''./src/gtk-2.0/gtkrc-light''./src/_sass/_colors.scss''./src/gtk-2.0/assets.svg''./src/gtk-2.0/assets-dark.svg''./src/gtk/assets.svg''./src/metacity-1''./src/unity''./src/xfwm4''./src/chrome' './src/cinnamon' './src/cinnamon/assets' './src/gnome-shell' './src/gtk-2.0/gtkrc' './src/gtk-2.0/gtkrc-dark' './src/gtk-2.0/gtkrc-light' './src/_sass/_colors.scss' './src/gtk-2.0/assets.svg' './src/gtk-2.0/assets-dark.svg' './src/gtk/assets.svg' './src/metacity-1' './src/unity' './src/xfwm4') if [ ! -z "${CUSTOM_PATHLIST:-}" ] ; thenIFS=', ' read -r -a PATHLIST <<< "${CUSTOM_PATHLIST:-}"if [[ ! -z "${CUSTOM_PATHLIST:-}" ]]; then IFS=', ' read -r -a PATHLIST <<< "${CUSTOM_PATHLIST:-}"fi EXPORT_QT5CT=0 for FILEPATH in "${PATHLIST[@]}"; do if [[ "$FILEPATH" == *qt5ct* ]] ;thenEXPORT_QT5CT=1fiif [[ "$FILEPATH" == *qt5ct* ]]; then EXPORT_QT5CT=1 fidone OPTION_GTK2_HIDPI=$(tr '[:upper:]' '[:lower:]' <<< "${OPTION_GTK2_HIDPI-False}") if [[ "$THEME" == */* ]] || [[ "$THEME" == *.* ]] ; thensource "$THEME"THEME=$(basename "$THEME")if [[ "$THEME" == */* ]] || [[ "$THEME" == *.* ]]; then source "$THEME" THEME=$(basename "$THEME")else if [[ -f "$SRC_PATH/../colors/$THEME" ]] ; thensource "$SRC_PATH/../colors/$THEME"elseecho "Theme '$THEME' not found"exit 1fiif [[ -f "$SRC_PATH/../colors/$THEME" ]]; then source "$SRC_PATH/../colors/$THEME" else echo "Theme '$THEME' not found" exit 1 fifi if [[ $(date +"%m%d") = "0401" ]] && grep -q "no-jokes" <<< "$*" ; thenecho -e "\\n\\nError patching uxtheme.dll\\n\\n"ACCENT_BG=000000 BG=C0C0C0 BTN_BG=C0C0C0 BTN_FG=000000 FG=000000GNOME_SHELL_PANEL_OPACITY=1 HDR_BTN_BG=C0C0C0 HDR_BTN_FG=000000 MENU_BG=C0C0C0MENU_FG=000000 SEL_BG=000080 SEL_FG=FFFFFF TXT_BG=FFFFFF TXT_FG=000000if [[ $(date +"%m%d") = "0401" ]] && grep -q "no-jokes" <<< "$*"; then echo -e "\\n\\nError patching uxtheme.dll\\n\\n" ACCENT_BG=000000 BG=C0C0C0 BTN_BG=C0C0C0 BTN_FG=000000 FG=000000 GNOME_SHELL_PANEL_OPACITY=1 HDR_BTN_BG=C0C0C0 HDR_BTN_FG=000000 MENU_BG=C0C0C0 MENU_FG=000000 SEL_BG=000080 SEL_FG=FFFFFF TXT_BG=FFFFFF TXT_FG=000000fi ACCENT_BG=${ACCENT_BG-$SEL_BG}
OUTPUT_THEME_NAME=${OUTPUT_THEME_NAME-oomox-$THEME} DEST_PATH="$HOME/.themes/${OUTPUT_THEME_NAME/\//-}" if [[ "$SRC_PATH" == "$DEST_PATH" ]]; then echo "can't do that"; exit 1; fiif [[ "$SRC_PATH" == "$DEST_PATH" ]]; then echo "can't do that" exit 1 fitempdir=$(mktemp -d) function post_clean_up {rm -r "$tempdir" || :post_clean_up() { rm -r "$tempdir" || :} trap post_clean_up EXIT SIGHUP SIGINT SIGTERM cp -r "$SRC_PATH/"* "$tempdir/"
# autodetection which color variant to use if [[ -z "$MATERIA_COLOR_VARIANT" ]] ; thenif is_dark "$BG" ; thenecho "== Dark background color detected. Setting color variant to dark."MATERIA_COLOR_VARIANT="dark"elif is_dark "$MENU_BG" ; thenecho "== Dark headerbar background color detected. Setting color variant to standard."MATERIA_COLOR_VARIANT="standard"elseecho "== Light background color detected. Setting color variant to light."MATERIA_COLOR_VARIANT="light"fiif [[ -z "$MATERIA_COLOR_VARIANT" ]]; then if is_dark "$BG"; then echo "== Dark background color detected. Setting color variant to dark." MATERIA_COLOR_VARIANT="dark" elif is_dark "$MENU_BG"; then echo "== Dark headerbar background color detected. Setting color variant to standard." MATERIA_COLOR_VARIANT="standard" else echo "== Light background color detected. Setting color variant to light." MATERIA_COLOR_VARIANT="light" fifi echo "== Converting theme into template..." for FILEPATH in "${PATHLIST[@]}"; do if [[ "$MATERIA_COLOR_VARIANT" != "dark" ]] ; thenfind "$FILEPATH" -type f -not -name '_color-palette.scss' -exec sed -i'' \-e 's/#000000/%FG%/g' \-e 's/#212121/%FG%/g' \-e 's/#757575/%INACTIVE_FG%/g' \-e 's/#BDBDBD/%INACTIVE_FG%/g' \-e 's/#FAFAFA/%INACTIVE_TXT_BG%/g' \-e 's/#F2F2F2/%BG%/g' \-e 's/#FAFAFA/%BTN_BG%/g' \-e 's/#01A299/%ACCENT_BG%/g' \-e 's/#4285F4/%SEL_BG%/g' \-e 's/#FFFFFF/%TXT_BG%/g' \-e 's/#383838/%MENU_BG%/g' \-e 's/#E0E0E0/%MENU_BG%/g' \-e 's/#212121/%MENU_BG2%/g' \-e 's/Materia/%OUTPUT_THEME_NAME%/g' \{} \; ;elsefind "$FILEPATH" -type f -not -name '_color-palette.scss' -exec sed -i'' \-e 's/#000000/%BG%/g' \-e 's/#282828/%BG%/g' \-e 's/#757575/%INACTIVE_FG%/g' \-e 's/#BDBDBD/%INACTIVE_FG%/g' \-e 's/#2C2C2C/%INACTIVE_TXT_BG%/g' \-e 's/#FFFFFF/%FG%/g' \-e 's/#FAFAFA/%BTN_FG%/g' \-e 's/#424242/%BTN_BG%/g' \-e 's/#01A299/%ACCENT_BG%/g' \-e 's/#4285F4/%SEL_BG%/g' \-e 's/#FFFFFF/%TXT_FG%/g' \-e 's/#303030/%TXT_BG%/g' \-e 's/#383838/%MENU_BG%/g' \-e 's/#212121/%MENU_BG2%/g' \-e 's/Materia/%OUTPUT_THEME_NAME%/g' \{} \; ;fiif [[ "$MATERIA_COLOR_VARIANT" != "dark" ]]; then find "$FILEPATH" -type f -not -name '_color-palette.scss' -exec sed -i'' \ -e 's/#000000/%FG%/g' \ -e 's/#212121/%FG%/g' \ -e 's/#757575/%INACTIVE_FG%/g' \ -e 's/#BDBDBD/%INACTIVE_FG%/g' \ -e 's/#FAFAFA/%INACTIVE_TXT_BG%/g' \ -e 's/#F2F2F2/%BG%/g' \ -e 's/#FAFAFA/%BTN_BG%/g' \ -e 's/#01A299/%ACCENT_BG%/g' \ -e 's/#4285F4/%SEL_BG%/g' \ -e 's/#FFFFFF/%TXT_BG%/g' \ -e 's/#383838/%MENU_BG%/g' \ -e 's/#E0E0E0/%MENU_BG%/g' \ -e 's/#212121/%MENU_BG2%/g' \ -e 's/Materia/%OUTPUT_THEME_NAME%/g' \ {} \; ; else find "$FILEPATH" -type f -not -name '_color-palette.scss' -exec sed -i'' \ -e 's/#000000/%BG%/g' \ -e 's/#282828/%BG%/g' \ -e 's/#757575/%INACTIVE_FG%/g' \ -e 's/#BDBDBD/%INACTIVE_FG%/g' \ -e 's/#2C2C2C/%INACTIVE_TXT_BG%/g' \ -e 's/#FFFFFF/%FG%/g' \ -e 's/#FAFAFA/%BTN_FG%/g' \ -e 's/#424242/%BTN_BG%/g' \ -e 's/#01A299/%ACCENT_BG%/g' \ -e 's/#4285F4/%SEL_BG%/g' \ -e 's/#FFFFFF/%TXT_FG%/g' \ -e 's/#303030/%TXT_BG%/g' \ -e 's/#383838/%MENU_BG%/g' \ -e 's/#212121/%MENU_BG2%/g' \ -e 's/Materia/%OUTPUT_THEME_NAME%/g' \ {} \; ; fidone #Not implemented yet: #-e 's/%HDR_BTN_BG%/'"$HDR_BTN_BG"'/g' \#-e 's/%HDR_BTN_FG%/'"$HDR_BTN_FG"'/g' \#-e 's/%WM_BORDER_FOCUS%/'"$WM_BORDER_FOCUS"'/g' \#-e 's/%WM_BORDER_UNFOCUS%/'"$WM_BORDER_UNFOCUS"'/g' \#-e 's/%ROUNDNESS%/'"$ROUNDNESS"'/g' \#-e 's/%SPACING%/'"$SPACING"'/g' \#-e 's/%INACTIVE_FG%/'"$INACTIVE_FG"'/g' \#-e 's/%INACTIVE_TXT_FG%/'"$INACTIVE_TXT_FG"'/g' \#-e 's/%INACTIVE_MENU_FG%/'"$INACTIVE_MENU_FG"'/g' \if [[ "${DEBUG:-}" ]] ; thenecho "You can debug TEMP DIR: $tempdir, press [Enter] when finished"; read -r#-e 's/%HDR_BTN_BG%/'"$HDR_BTN_BG"'/g' \ #-e 's/%HDR_BTN_FG%/'"$HDR_BTN_FG"'/g' \ #-e 's/%WM_BORDER_FOCUS%/'"$WM_BORDER_FOCUS"'/g' \ #-e 's/%WM_BORDER_UNFOCUS%/'"$WM_BORDER_UNFOCUS"'/g' \ #-e 's/%ROUNDNESS%/'"$ROUNDNESS"'/g' \ #-e 's/%SPACING%/'"$SPACING"'/g' \ #-e 's/%INACTIVE_FG%/'"$INACTIVE_FG"'/g' \ #-e 's/%INACTIVE_TXT_FG%/'"$INACTIVE_TXT_FG"'/g' \ #-e 's/%INACTIVE_MENU_FG%/'"$INACTIVE_MENU_FG"'/g' \ if [[ "${DEBUG:-}" ]]; then echo "You can debug TEMP DIR: $tempdir, press [Enter] when finished"; read -rfi mv ./src/_sass/_colors.scss.template ./src/_sass/_colors.scss echo "== Filling the template with the new colorscheme..." for FILEPATH in "${PATHLIST[@]}"; do find "$FILEPATH" -type f -exec sed -i'' \-e 's/%BG%/#'"$BG"'/g' \-e 's/%BG2%/#'"$(darker $BG)"'/g' \-e 's/%FG%/#'"$FG"'/g' \-e 's/%ACCENT_BG%/#'"$ACCENT_BG"'/g' \-e 's/%SEL_BG%/#'"$SEL_BG"'/g' \-e 's/%SEL_BG2%/#'"$(darker $SEL_BG -20)"'/g' \-e 's/%SEL_FG%/#'"$SEL_FG"'/g' \-e 's/%TXT_BG%/#'"$TXT_BG"'/g' \-e 's/%TXT_FG%/#'"$TXT_FG"'/g' \-e 's/%MENU_BG%/#'"$MENU_BG"'/g' \-e 's/%MENU_BG2%/#'"$(darker $MENU_BG 10)"'/g' \-e 's/%MENU_BG3%/#'"$(darker $MENU_BG 20)"'/g' \-e 's/%MENU_FG%/#'"$MENU_FG"'/g' \-e 's/%BTN_BG%/#'"$BTN_BG"'/g' \-e 's/%BTN_FG%/#'"$BTN_FG"'/g' \-e 's/%HDR_BTN_BG%/#'"$HDR_BTN_BG"'/g' \-e 's/%HDR_BTN_FG%/#'"$HDR_BTN_FG"'/g' \-e 's/%WM_BORDER_FOCUS%/#'"$WM_BORDER_FOCUS"'/g' \-e 's/%WM_BORDER_UNFOCUS%/#'"$WM_BORDER_UNFOCUS"'/g' \-e 's/%ROUNDNESS%/'"$ROUNDNESS"'/g' \-e 's/%SPACING%/'"$SPACING"'/g' \-e 's/%INACTIVE_FG%/#'"$INACTIVE_FG"'/g' \-e 's/%INACTIVE_TXT_FG%/#'"$INACTIVE_TXT_FG"'/g' \-e 's/%INACTIVE_TXT_BG%/#'"$INACTIVE_TXT_BG"'/g' \-e 's/%INACTIVE_MENU_FG%/#'"$INACTIVE_MENU_FG"'/g' \-e 's/%INACTIVE_MENU_BG%/#'"$INACTIVE_MENU_BG"'/g' \-e 's/%TERMINAL_COLOR4%/#'"$TERMINAL_COLOR4"'/g' \-e 's/%TERMINAL_COLOR5%/#'"$TERMINAL_COLOR5"'/g' \-e 's/%TERMINAL_COLOR9%/#'"$TERMINAL_COLOR9"'/g' \-e 's/%TERMINAL_COLOR10%/#'"$TERMINAL_COLOR10"'/g' \-e 's/%TERMINAL_COLOR11%/#'"$TERMINAL_COLOR11"'/g' \-e 's/%TERMINAL_COLOR12%/#'"$TERMINAL_COLOR12"'/g' \-e 's/%GNOME_SHELL_PANEL_OPACITY%/'"$GNOME_SHELL_PANEL_OPACITY"'/g' \-e 's/%OUTPUT_THEME_NAME%/'"$OUTPUT_THEME_NAME"'/g' \{} \; ;find "$FILEPATH" -type f -exec sed -i'' \ -e 's/%BG%/#'"$BG"'/g' \ -e 's/%BG2%/#'"$(darker $BG)"'/g' \ -e 's/%FG%/#'"$FG"'/g' \ -e 's/%ACCENT_BG%/#'"$ACCENT_BG"'/g' \ -e 's/%SEL_BG%/#'"$SEL_BG"'/g' \ -e 's/%SEL_BG2%/#'"$(darker $SEL_BG -20)"'/g' \ -e 's/%SEL_FG%/#'"$SEL_FG"'/g' \ -e 's/%TXT_BG%/#'"$TXT_BG"'/g' \ -e 's/%TXT_FG%/#'"$TXT_FG"'/g' \ -e 's/%MENU_BG%/#'"$MENU_BG"'/g' \ -e 's/%MENU_BG2%/#'"$(darker $MENU_BG 10)"'/g' \ -e 's/%MENU_BG3%/#'"$(darker $MENU_BG 20)"'/g' \ -e 's/%MENU_FG%/#'"$MENU_FG"'/g' \ -e 's/%BTN_BG%/#'"$BTN_BG"'/g' \ -e 's/%BTN_FG%/#'"$BTN_FG"'/g' \ -e 's/%HDR_BTN_BG%/#'"$HDR_BTN_BG"'/g' \ -e 's/%HDR_BTN_FG%/#'"$HDR_BTN_FG"'/g' \ -e 's/%WM_BORDER_FOCUS%/#'"$WM_BORDER_FOCUS"'/g' \ -e 's/%WM_BORDER_UNFOCUS%/#'"$WM_BORDER_UNFOCUS"'/g' \ -e 's/%ROUNDNESS%/'"$ROUNDNESS"'/g' \ -e 's/%SPACING%/'"$SPACING"'/g' \ -e 's/%INACTIVE_FG%/#'"$INACTIVE_FG"'/g' \ -e 's/%INACTIVE_TXT_FG%/#'"$INACTIVE_TXT_FG"'/g' \ -e 's/%INACTIVE_TXT_BG%/#'"$INACTIVE_TXT_BG"'/g' \ -e 's/%INACTIVE_MENU_FG%/#'"$INACTIVE_MENU_FG"'/g' \ -e 's/%INACTIVE_MENU_BG%/#'"$INACTIVE_MENU_BG"'/g' \ -e 's/%TERMINAL_COLOR4%/#'"$TERMINAL_COLOR4"'/g' \ -e 's/%TERMINAL_COLOR5%/#'"$TERMINAL_COLOR5"'/g' \ -e 's/%TERMINAL_COLOR9%/#'"$TERMINAL_COLOR9"'/g' \ -e 's/%TERMINAL_COLOR10%/#'"$TERMINAL_COLOR10"'/g' \ -e 's/%TERMINAL_COLOR11%/#'"$TERMINAL_COLOR11"'/g' \ -e 's/%TERMINAL_COLOR12%/#'"$TERMINAL_COLOR12"'/g' \ -e 's/%GNOME_SHELL_PANEL_OPACITY%/'"$GNOME_SHELL_PANEL_OPACITY"'/g' \ -e 's/%OUTPUT_THEME_NAME%/'"$OUTPUT_THEME_NAME"'/g' \ {} \; ;done if [[ "$MATERIA_COLOR_VARIANT" == "standard" ]] ; thenCOLOR_VARIANTS=","COLOR_VARIANT="standard"if [[ "$MATERIA_COLOR_VARIANT" == "standard" ]]; then COLOR_VARIANTS="," COLOR_VARIANT="standard"fi if [[ "$MATERIA_COLOR_VARIANT" == "light" ]] ; thenCOLOR_VARIANTS="-light"COLOR_VARIANT="light"if [[ "$MATERIA_COLOR_VARIANT" == "light" ]]; then COLOR_VARIANTS="-light" COLOR_VARIANT="light"fi if [[ "$MATERIA_COLOR_VARIANT" == "dark" ]] ; thenCOLOR_VARIANTS="-dark"COLOR_VARIANT="dark"if [[ "$MATERIA_COLOR_VARIANT" == "dark" ]]; then COLOR_VARIANTS="-dark" COLOR_VARIANT="dark"fi if [[ "$OPTION_GTK2_HIDPI" == "true" ]] ; thenmv ./src/gtk-2.0/main.rc.hidpi ./src/gtk-2.0/main.rcif [[ "$OPTION_GTK2_HIDPI" == "true" ]]; then mv ./src/gtk-2.0/main.rc.hidpi ./src/gtk-2.0/main.rcfi if [[ "$EXPORT_QT5CT" = 1 ]] ; thenconfig_home=${XDG_CONFIG_HOME:-"$HOME/.config"}qt5ct_colors_dir="$config_home/qt5ct/colors/"test -d "$qt5ct_colors_dir" || mkdir -p "$qt5ct_colors_dir"mv ./src/qt5ct_palette.conf "$qt5ct_colors_dir/$OUTPUT_THEME_NAME.conf"if [[ "$EXPORT_QT5CT" = 1 ]]; then config_home=${XDG_CONFIG_HOME:-"$HOME/.config"} qt5ct_colors_dir="$config_home/qt5ct/colors/" test -d "$qt5ct_colors_dir" || mkdir -p "$qt5ct_colors_dir" mv ./src/qt5ct_palette.conf "$qt5ct_colors_dir/$OUTPUT_THEME_NAME.conf"fi if [[ "$UNITY_DEFAULT_LAUNCHER_STYLE" == "true" ]] ; thenrm ./src/unity/launcher*.svgif [[ "$UNITY_DEFAULT_LAUNCHER_STYLE" == "true" ]]; then rm ./src/unity/launcher*.svgfi if [[ "$MATERIA_STYLE_COMPACT" == "true" ]] ; thenSIZE_VARIANTS="-compact"SIZE_VARIANT="compact"if [[ "$MATERIA_STYLE_COMPACT" == "true" ]]; then SIZE_VARIANTS="-compact" SIZE_VARIANT="compact"else SIZE_VARIANTS=","SIZE_VARIANT="standard"SIZE_VARIANTS="," SIZE_VARIANT="standard"fi SIZE_VARIANTS="$SIZE_VARIANTS" COLOR_VARIANTS="$COLOR_VARIANTS" THEME_DIR_BASE="$DEST_PATH" ./parse-sass.sh # NOTE we use the functions we already have in render-assets.sh echo "== Rendering GTK+2 assets..." if [[ "$MATERIA_COLOR_VARIANT" != "dark" ]] ; thenGTK2_HIDPI="$OPTION_GTK2_HIDPI" ./render-assets.sh gtk2-lightif [[ "$MATERIA_COLOR_VARIANT" != "dark" ]]; then GTK2_HIDPI="$OPTION_GTK2_HIDPI" ./render-assets.sh gtk2-lightelse GTK2_HIDPI="$OPTION_GTK2_HIDPI" ./render-assets.sh gtk2-darkGTK2_HIDPI="$OPTION_GTK2_HIDPI" ./render-assets.sh gtk2-darkfi echo "== Rendering GTK+3 assets..."
./install.sh --dest "$HOME/.themes" --name "${OUTPUT_THEME_NAME/\//-}" --color "$COLOR_VARIANT" --size "$SIZE_VARIANT" GENERATED_PATH="$DEST_PATH$(tr -d ',' <<< "$COLOR_VARIANTS")$(tr -d ',' <<< "$SIZE_VARIANTS")" if [[ "$GENERATED_PATH" != "$DEST_PATH" ]] ; thenif [[ -d "$DEST_PATH" ]] ; thenrm -r "$DEST_PATH"fimv "$GENERATED_PATH" "$DEST_PATH"if [[ "$GENERATED_PATH" != "$DEST_PATH" ]]; then if [[ -d "$DEST_PATH" ]]; then rm -r "$DEST_PATH" fi mv "$GENERATED_PATH" "$DEST_PATH"fi echo
set -ueo pipefail #set -x REPO_DIR=$(cd "$(dirname "$0")" && pwd)SRC_DIR=$REPO_DIR/srcREPO_DIR="$(cd "$(dirname "$0")" && pwd)" SRC_DIR="$REPO_DIR/src"DEST_DIR=/usr/share/themesTHEME_NAME=MateriaDEST_DIR="/usr/share/themes" THEME_NAME="Materia"COLOR_VARIANTS=('' '-dark' '-light') SIZE_VARIANTS=('' '-compact') GTK_VERSIONS=('3.18' '3.20' '3.22') GS_VERSIONS=('3.18' '3.24' '3.26' '3.28') LATEST_GS_VERSION=${GS_VERSIONS[-1]}LATEST_GS_VERSION="${GS_VERSIONS[-1]}"# Set a proper gnome-shell theme version if [[ $(which gnome-shell 2> /dev/null) ]]; thenCURRENT_GS_VERSION=$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)if [[ "$(which gnome-shell 2> /dev/null)" ]]; then CURRENT_GS_VERSION="$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)"for version in "${GS_VERSIONS[@]}"; do if (( $(bc <<< "$CURRENT_GS_VERSION <= $version") )); thenGS_VERSION=$versionif (( "$(bc <<< "$CURRENT_GS_VERSION <= $version")" )); then GS_VERSION="$version"break elif (( $(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION") )); thenGS_VERSION=$LATEST_GS_VERSIONelif (( "$(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION")" )); then GS_VERSION="$LATEST_GS_VERSION"break fi done else GS_VERSION=$LATEST_GS_VERSIONGS_VERSION="$LATEST_GS_VERSION"fi usage() {
} install() { local dest=$1local name=$2local color=$3local size=$4local dest="$1" local name="$2" local color="$3" local size="$4"[[ "$color" == '-dark' ]] && local ELSE_DARK=$color[[ "$color" == '-light' ]] && local ELSE_LIGHT=$color[[ "$color" == '-dark' ]] && local ELSE_DARK="$color" [[ "$color" == '-light' ]] && local ELSE_LIGHT="$color"local THEME_DIR=$dest/$name$color$sizelocal THEME_DIR="$dest/$name$color$size"# SC2115: Protect /. [[ -d "$THEME_DIR" ]] && rm -rf "${THEME_DIR:?}"
# Bakup and install files related to GDM theme install_gdm() { local THEME_DIR=$1/$2$3$4local GS_THEME_FILE=/usr/share/gnome-shell/gnome-shell-theme.gresourcelocal UBUNTU_THEME_FILE=/usr/share/gnome-shell/theme/ubuntu.csslocal THEME_DIR="$1/$2$3$4" local GS_THEME_FILE="/usr/share/gnome-shell/gnome-shell-theme.gresource" local UBUNTU_THEME_FILE="/usr/share/gnome-shell/theme/ubuntu.css"if [[ -f "$GS_THEME_FILE" ]] && [[ "$(which glib-compile-resources 2> /dev/null)" ]]; then echo "Installing '$GS_THEME_FILE'..."
shift 2 ;; -g|--gdm) gdm=truegdm='true'shift 1 ;; -c|--color)
done done if [[ "${gdm:-}" == true ]]; thenif [[ "${gdm:-}" == 'true' ]]; theninstall_gdm "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size" fi
gtk2_dark ;; *) echo "Unknown argument: '$1'"echo "Unknown argument '$1'"echo "Use 'chrome', 'gtk', 'gtk2', 'gtk2-light' or 'gtk2-dark' as an argument." exit 1 ;;
#set -x darker_channel() { value="$1"light_delta="$2"result=$(bc <<< "ibase=16; $value - $light_delta")if [[ "$result" -lt 0 ]] ; thenresult=0fiif [[ "$result" -gt 255 ]] ; thenresult=255fiecho "$result"value="$1" light_delta="$2" result="$(bc <<< "ibase=16; $value - $light_delta")" if [[ "$result" -lt 0 ]]; then result=0 fi if [[ "$result" -gt 255 ]]; then result=255 fi echo "$result"} darker() { hexinput=$(tr '[:lower:]' '[:upper:]' <<< "$1")light_delta="${2-10}"hexinput="$(tr '[:lower:]' '[:upper:]' <<< "$1")" light_delta="${2-10}"a="$(cut -c-2 <<< "$hexinput")"b="$(cut -c3-4 <<< "$hexinput")"c="$(cut -c5-6 <<< "$hexinput")"a="$(cut -c-2 <<< "$hexinput")" b="$(cut -c3-4 <<< "$hexinput")" c="$(cut -c5-6 <<< "$hexinput")"r="$(darker_channel "$a" "$light_delta")"g="$(darker_channel "$b" "$light_delta")"b="$(darker_channel "$c" "$light_delta")"r="$(darker_channel "$a" "$light_delta")" g="$(darker_channel "$b" "$light_delta")" b="$(darker_channel "$c" "$light_delta")"printf '%02x%02x%02x\n' "$r" "$g" "$b"printf '%02x%02x%02x\n' "$r" "$g" "$b"} darker "$@"
#set -x mix_channel() { value1="$(printf '%03d' "0x$1")"value2="$(printf '%03d' "0x$2")"ratio="$3"result=$(bc <<< "scale=0; ($value1 * 100 * $ratio + $value2 * 100 * (1 - $ratio))/100")if [[ "$result" -lt 0 ]] ; thenresult=0elif [[ "$result" -gt 255 ]] ; thenresult=255fiecho "$result"value1="$(printf '%03d' "0x$1")" value2="$(printf '%03d' "0x$2")" ratio="$3" result="$(bc <<< "scale=0; ($value1 * 100 * $ratio + $value2 * 100 * (1 - $ratio)) / 100")" if [[ "$result" -lt 0 ]]; then result=0 elif [[ "$result" -gt 255 ]]; then result=255 fi echo "$result"} mix() { hexinput1=$(tr '[:lower:]' '[:upper:]' <<< "$1")hexinput2=$(tr '[:lower:]' '[:upper:]' <<< "$2")ratio="${3-0.5}"hexinput1="$(tr '[:lower:]' '[:upper:]' <<< "$1")" hexinput2="$(tr '[:lower:]' '[:upper:]' <<< "$2")" ratio="${3-0.5}"a="$(cut -c-2 <<< "$hexinput1")"b="$(cut -c3-4 <<< "$hexinput1")"c="$(cut -c5-6 <<< "$hexinput1")"d="$(cut -c-2 <<< "$hexinput2")"e="$(cut -c3-4 <<< "$hexinput2")"f="$(cut -c5-6 <<< "$hexinput2")"a="$(cut -c-2 <<< "$hexinput1")" b="$(cut -c3-4 <<< "$hexinput1")" c="$(cut -c5-6 <<< "$hexinput1")" d="$(cut -c-2 <<< "$hexinput2")" e="$(cut -c3-4 <<< "$hexinput2")" f="$(cut -c5-6 <<< "$hexinput2")"r="$(mix_channel "$a" "$d" "$ratio")"g="$(mix_channel "$b" "$e" "$ratio")"b="$(mix_channel "$c" "$f" "$ratio")"r="$(mix_channel "$a" "$d" "$ratio")" g="$(mix_channel "$b" "$e" "$ratio")" b="$(mix_channel "$c" "$f" "$ratio")"printf '%02x%02x%02x\n' "$r" "$g" "$b"printf '%02x%02x%02x\n' "$r" "$g" "$b"} mix "$@"
i="$2" GTK2_HIDPI=$(echo "${GTK2_HIDPI-False}" | tr '[:upper:]' '[:lower:]')GTK2_HIDPI="$(echo "${GTK2_HIDPI-False}" | tr '[:upper:]' '[:lower:]')"if [[ "${GTK2_HIDPI}" == "true" ]] ; then EXTRA_OPTIONS=("--export-dpi=192") else
echo "Rendering '$ASSETS_DIR/$i.png'" "$INKSCAPE" --export-id="$i" \ --export-id-only \ ${EXTRA_OPTIONS+"${EXTRA_OPTIONS[@]}"} \"${EXTRA_OPTIONS+"${EXTRA_OPTIONS[@]}"}" \--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null \ && "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
# FIXME: Multiple arguments should be allowed. set -ueo pipefail REPO_DIR=$(cd "$(dirname "$0")" && pwd)SRC_DIR=$REPO_DIR/srcREPO_DIR="$(cd "$(dirname "$0")" && pwd)" SRC_DIR="$REPO_DIR/src"DEST_DIR=$HOME/.themesTHEME_NAME=Materia.devDEST_DIR="$HOME/.themes" THEME_NAME="Materia.dev"# shellcheck disable=SC2034 # will this be used later? COLOR_VARIANTS=('' '-dark' '-light') # shellcheck disable=SC2034 # will this be used later?
GTK_VERSIONS=('3.18' '3.20' '3.22') GS_VERSIONS=('3.18' '3.24' '3.26' '3.28') LATEST_GS_VERSION=${GS_VERSIONS[-1]}LATEST_GS_VERSION="${GS_VERSIONS[-1]}"# Set a proper gnome-shell theme version if [[ $(which gnome-shell 2> /dev/null) ]]; thenCURRENT_GS_VERSION=$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)if [[ "$(which gnome-shell 2> /dev/null)" ]]; then CURRENT_GS_VERSION="$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)"for version in "${GS_VERSIONS[@]}"; do if (( $(bc <<< "$CURRENT_GS_VERSION <= $version") )); thenGS_VERSION=$versionif (( "$(bc <<< "$CURRENT_GS_VERSION <= $version")" )); then GS_VERSION="$version"break elif (( $(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION") )); thenGS_VERSION=$LATEST_GS_VERSIONelif (( "$(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION")" )); then GS_VERSION="$LATEST_GS_VERSION"break fi done else GS_VERSION=$LATEST_GS_VERSIONGS_VERSION="$LATEST_GS_VERSION"fi test() { local color=$1local size=$2local color="$1" local size="$2"[[ "$color" == '-dark' ]] && local ELSE_DARK=$color[[ "$color" == '-light' ]] && local ELSE_LIGHT=$color[[ "$color" == '-dark' ]] && local ELSE_DARK="$color" [[ "$color" == '-light' ]] && local ELSE_LIGHT="$color"local THEME_DIR="${DEST_DIR:?}/$THEME_NAME$color$size"
ln -s "$SRC_DIR/xfwm4/"{*.svg,themerc} "$THEME_DIR/xfwm4" ln -sT "$SRC_DIR/xfwm4/assets${ELSE_LIGHT:-}" "$THEME_DIR/xfwm4/assets" echo Installed to "$THEME_DIR"echo "Installed to '$THEME_DIR'"} case "${1:-}" in
rm -rf "${DEST_DIR:?}/$THEME_NAME"{,-compact,-dark,-dark-compact,-light,-light-compact} ;; *) echo "Invalid argument: ${1:-}"echo "Valid arguments are: compact dark dark-compact light light-compact all uninstall"echo "Invalid argument: '${1:-}'" echo "Valid arguments are: 'compact' 'dark' 'dark-compact' 'light' 'light-compact' 'all' 'uninstall'";; esac