From bf4de5a87379326a96bfc8b7ccf03140405e8811 Mon Sep 17 00:00:00 2001 From: think4web Date: Thu, 4 Jun 2020 09:33:44 +0300 Subject: [PATCH 1/2] Removed all unnecessary. --- TODO.md | 29 ---- change_color.sh | 338 ----------------------------------------------- install.sh | 242 --------------------------------- parse-sass.sh | 42 ------ render-assets.sh | 62 --------- test.sh | 131 ------------------ 6 files changed, 844 deletions(-) delete mode 100644 TODO.md delete mode 100755 change_color.sh delete mode 100755 install.sh delete mode 100755 parse-sass.sh delete mode 100755 render-assets.sh delete mode 100755 test.sh diff --git a/TODO.md b/TODO.md deleted file mode 100644 index bd1f0a64f..000000000 --- a/TODO.md +++ /dev/null @@ -1,29 +0,0 @@ -## General - -- Use `make` or `meson` for building? (`help wanted`) - -## Supports - -- GTK+ 4 -- Firefox theme ([#78](../../issues/78)) - - waiting for [the upstream to provide next-gen themes](https://blog.mozilla.org/addons/2017/02/24/improving-themes-in-firefox/) - - Or, is it unnecessary because the new interface is well integrated with this theme? -- Xfce theme ([#60](../../issues/60)) - - waiting for the upstream to complete `gtk3` port -- Pantheon theme ([#69](../../issues/69)) -- GtkSourceView theme ([#150](../../issues/150)) -- Color scheme for GNOME Terminal ([#157](../../issues/157)) -- Overlay scrollbars extension for Chrome/Chromium (`low priority`) -- Cursor theme like Material Design ([#156](../../issues/156), `low priority`) - -## UI changes - -- Make gtk2 check/radio buttons a bit smaller for Qt apps ([#78](../../issues/78)) -- Use `#757575` as check/radio buttons color for some web interfaces ([#123](../../issues/123), if possible) -- Make compact variant more compact ([#79](../../issues/79), WIP) -- Change gtk2 spinbutton to flat button style -- Rework the focus state styles (WIP) - -## Others - -- Polish Inkscape (using gtk3) styling diff --git a/change_color.sh b/change_color.sh deleted file mode 100755 index 03b1fd8aa..000000000 --- a/change_color.sh +++ /dev/null @@ -1,338 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1090 -#set -x -set -ueo pipefail - -SRC_PATH="$(readlink -f "$(dirname "$0")")" - -darker() { - "$SRC_PATH/scripts/darker.sh" "$@" -} -mix() { - "$SRC_PATH/scripts/mix.sh" "$@" -} -is_dark() { - 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 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-}" ]]; then - echo "unknown option $1" - print_usage - exit 2 - fi - THEME="$1" - ;; - esac - shift -done - -if [[ -z "${THEME:-}" ]]; then - print_usage -fi - -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' -) -if [[ ! -z "${CUSTOM_PATHLIST:-}" ]]; then - IFS=', ' read -r -a PATHLIST <<< "${CUSTOM_PATHLIST:-}" -fi - -EXPORT_QT5CT=0 -for FILEPATH in "${PATHLIST[@]}"; do - if [[ "$FILEPATH" == *qt5ct* ]]; then - EXPORT_QT5CT=1 - fi -done - -OPTION_GTK2_HIDPI=$(tr '[:upper:]' '[:lower:]' <<< "${OPTION_GTK2_HIDPI-False}") - - -if [[ "$THEME" == */* ]] || [[ "$THEME" == *.* ]]; then - source "$THEME" - THEME=$(basename "$THEME") -else - if [[ -f "$SRC_PATH/../colors/$THEME" ]]; then - source "$SRC_PATH/../colors/$THEME" - else - echo "Theme '$THEME' not found" - exit 1 - fi -fi -if [[ $(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=000000 -fi - -ACCENT_BG=${ACCENT_BG-$SEL_BG} -HDR_BTN_BG=${HDR_BTN_BG-$BTN_BG} -HDR_BTN_FG=${HDR_BTN_FG-$BTN_FG} -WM_BORDER_FOCUS=${WM_BORDER_FOCUS-$SEL_BG} -WM_BORDER_UNFOCUS=${WM_BORDER_UNFOCUS-$MENU_BG} - -MATERIA_STYLE_COMPACT=$(tr '[:upper:]' '[:lower:]' <<< "${MATERIA_STYLE_COMPACT-True}") -MATERIA_COLOR_VARIANT=$(tr '[:upper:]' '[:lower:]' <<< "${MATERIA_COLOR_VARIANT:-}") -UNITY_DEFAULT_LAUNCHER_STYLE=$(tr '[:upper:]' '[:lower:]' <<< "${UNITY_DEFAULT_LAUNCHER_STYLE-False}") - -SPACING=${SPACING-3} -GRADIENT=${GRADIENT-0} -ROUNDNESS=${ROUNDNESS-2} -# shellcheck disable=SC2034 # will this be used in the future? -ROUNDNESS_GTK2_HIDPI=$(( ROUNDNESS * 2 )) -GNOME_SHELL_PANEL_OPACITY=${GNOME_SHELL_PANEL_OPACITY-0.6} - -INACTIVE_FG=$(mix "$FG" "$BG" 0.75) -INACTIVE_MENU_FG=$(mix "$MENU_FG" "$MENU_BG" 0.75) -INACTIVE_MENU_BG=$(mix "$MENU_BG" "$MENU_FG" 0.75) -INACTIVE_TXT_FG=$(mix "$TXT_FG" "$TXT_BG" 0.75) -INACTIVE_TXT_BG=$(mix "$TXT_BG" "$BG" 0.60) - -TERMINAL_COLOR4=${TERMINAL_COLOR4:-1E88E5} -TERMINAL_COLOR5=${TERMINAL_COLOR5:-E040FB} -TERMINAL_COLOR9=${TERMINAL_COLOR9:-DD2C00} -TERMINAL_COLOR10=${TERMINAL_COLOR10:-00C853} -TERMINAL_COLOR11=${TERMINAL_COLOR11:-FF6D00} -TERMINAL_COLOR12=${TERMINAL_COLOR12:-66BB6A} - -# Are these intended to be used in the future? -# shellcheck disable=SC2034 -light_folder_base_fallback=$(darker "$SEL_BG" -10) -# shellcheck disable=SC2034 -medium_base_fallback=$(darker "$SEL_BG" 37) -# shellcheck disable=SC2034 -dark_stroke_fallback=$(darker "$SEL_BG" 50) - -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 -fi - - -tempdir=$(mktemp -d) -post_clean_up() { - rm -r "$tempdir" || : -} -trap post_clean_up EXIT SIGHUP SIGINT SIGTERM -cp -r "$SRC_PATH/"* "$tempdir/" -cd "$tempdir" - - -# autodetection which color variant to use -if [[ -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" - fi -fi - - -echo "== Converting theme into template..." - -for FILEPATH in "${PATHLIST[@]}"; do - if [[ "$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' \ - {} \; ; - fi -done - -#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/%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' \ - -sed -i -e 's/^$material_radius: .px/$material_radius: '"$ROUNDNESS"'px/g' ./src/_sass/gtk/_variables.scss - -if [[ "${DEBUG:-}" ]]; then - echo "You can debug TEMP DIR: $tempdir, press [Enter] when finished"; read -r -fi - -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/%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" ]]; then - COLOR_VARIANTS="," - COLOR_VARIANT="standard" -fi -if [[ "$MATERIA_COLOR_VARIANT" == "light" ]]; then - COLOR_VARIANTS="-light" - COLOR_VARIANT="light" -fi -if [[ "$MATERIA_COLOR_VARIANT" == "dark" ]]; then - COLOR_VARIANTS="-dark" - COLOR_VARIANT="dark" -fi -if [[ "$OPTION_GTK2_HIDPI" == "true" ]]; then - mv ./src/gtk-2.0/main.rc.hidpi ./src/gtk-2.0/main.rc -fi -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" ]]; then - rm ./src/unity/launcher*.svg -fi - -if [[ "$MATERIA_STYLE_COMPACT" == "true" ]]; then - SIZE_VARIANTS="-compact" - SIZE_VARIANT="compact" -else - 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" ]]; then - GTK2_HIDPI="$OPTION_GTK2_HIDPI" ./render-assets.sh gtk2-light -else - GTK2_HIDPI="$OPTION_GTK2_HIDPI" ./render-assets.sh gtk2-dark -fi - -echo "== Rendering GTK+3 assets..." -./render-assets.sh gtk - -./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" ]]; then - if [[ -d "$DEST_PATH" ]]; then - rm -r "$DEST_PATH" - fi - mv "$GENERATED_PATH" "$DEST_PATH" -fi - -echo -echo "== SUCCESS" -echo "== The theme was installed to '$DEST_PATH'" -exit 0 diff --git a/install.sh b/install.sh deleted file mode 100755 index 1c896a4b1..000000000 --- a/install.sh +++ /dev/null @@ -1,242 +0,0 @@ -#!/bin/bash -set -ueo pipefail -#set -x - -REPO_DIR="$(cd "$(dirname "$0")" && pwd)" -SRC_DIR="$REPO_DIR/src" - -DEST_DIR="/usr/share/themes" -THEME_NAME="Materia" -COLOR_VARIANTS=('' '-dark' '-light') -SIZE_VARIANTS=('' '-compact') - -GTK_VERSIONS=('3.0') -GS_VERSIONS=('3.18' '3.24' '3.26' '3.28' '3.30') -LATEST_GS_VERSION="${GS_VERSIONS[-1]}" - -# Set a proper gnome-shell theme version -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")" )); then - GS_VERSION="$version" - break - elif (( "$(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION")" )); then - GS_VERSION="$LATEST_GS_VERSION" - break - fi - done -else - GS_VERSION="$LATEST_GS_VERSION" -fi - -usage() { - cat << EOF -Usage: $0 [OPTION]... - -OPTIONS: - -d, --dest DIR Specify theme destination directory (Default: $DEST_DIR) - -n, --name NAME Specify theme name (Default: $THEME_NAME) - -c, --color VARIANT... Specify theme color variant(s) [standard|dark|light] (Default: All variants) - -s, --size VARIANT Specify theme size variant [standard|compact] (Default: All variants) - -g, --gdm Install GDM theme - -h, --help Show this help - -INSTALLATION EXAMPLES: -Install all theme variants into ~/.themes - $0 --dest ~/.themes -Install all theme variants including GDM theme - $0 --gdm -Install standard theme variant only - $0 --color standard --size standard -Install specific theme variants with different name into ~/.themes - $0 --dest ~/.themes --name MyTheme --color light dark --size compact -EOF -} - -install() { - local dest="$1" - local name="$2" - local color="$3" - local size="$4" - - [[ "$color" == '-dark' ]] && local ELSE_DARK="$color" - [[ "$color" == '-light' ]] && local ELSE_LIGHT="$color" - - local THEME_DIR="$dest/$name$color$size" - - # SC2115: Protect /. - [[ -d "$THEME_DIR" ]] && rm -rf "${THEME_DIR:?}" - - echo "Installing '$THEME_DIR'..." - - mkdir -p "$THEME_DIR" - cp -r "$REPO_DIR/COPYING" "$THEME_DIR" - cp -r "$SRC_DIR/index$color$size.theme" "$THEME_DIR/index.theme" - - mkdir -p "$THEME_DIR/chrome" - cp -r "$SRC_DIR/chrome/chrome-theme$color.crx" "$THEME_DIR/chrome/chrome-theme.crx" - cp -r "$SRC_DIR/chrome/chrome-scrollbar${ELSE_DARK:-}.crx" "$THEME_DIR/chrome/chrome-scrollbar.crx" - - mkdir -p "$THEME_DIR/cinnamon" - cp -r "$SRC_DIR/cinnamon/assets" "$THEME_DIR/cinnamon" - cp -r "$SRC_DIR/cinnamon/thumbnail.png" "$THEME_DIR/cinnamon" - cp -r "$SRC_DIR/cinnamon/cinnamon$color$size.css" "$THEME_DIR/cinnamon/cinnamon.css" - - mkdir -p "$THEME_DIR/gnome-shell" - cp -r "$SRC_DIR/gnome-shell/"{*.svg,extensions,noise-texture.png,pad-osd.css} "$THEME_DIR/gnome-shell" - cp -r "$SRC_DIR/gnome-shell/gnome-shell-theme.gresource.xml" "$THEME_DIR/gnome-shell" - cp -r "$SRC_DIR/gnome-shell/assets${ELSE_DARK:-}" "$THEME_DIR/gnome-shell/assets" - cp -r "$SRC_DIR/gnome-shell/$GS_VERSION/gnome-shell$color$size.css" "$THEME_DIR/gnome-shell/gnome-shell.css" - - mkdir -p "$THEME_DIR/gtk-2.0" - cp -r "$SRC_DIR/gtk-2.0/"{apps.rc,hacks.rc,main.rc} "$THEME_DIR/gtk-2.0" - cp -r "$SRC_DIR/gtk-2.0/assets${ELSE_DARK:-}" "$THEME_DIR/gtk-2.0/assets" - cp -r "$SRC_DIR/gtk-2.0/gtkrc$color" "$THEME_DIR/gtk-2.0/gtkrc" - - cp -r "$SRC_DIR/gtk/assets" "$THEME_DIR/gtk-assets" - - for version in "${GTK_VERSIONS[@]}"; do - mkdir -p "$THEME_DIR/gtk-$version" - ln -s ../gtk-assets "$THEME_DIR/gtk-$version/assets" - cp -r "$SRC_DIR/gtk/$version/gtk$color$size.css" "$THEME_DIR/gtk-$version/gtk.css" - [[ "$color" != '-dark' ]] && \ - cp -r "$SRC_DIR/gtk/$version/gtk-dark$size.css" "$THEME_DIR/gtk-$version/gtk-dark.css" - done - - mkdir -p "$THEME_DIR/metacity-1" - cp -r "$SRC_DIR/metacity-1/"{assets,metacity-theme-3.xml} "$THEME_DIR/metacity-1" - cp -r "$SRC_DIR/metacity-1/metacity-theme-2${ELSE_LIGHT:-}.xml" "$THEME_DIR/metacity-1/metacity-theme-2.xml" - - mkdir -p "$THEME_DIR/unity" - cp -r "$SRC_DIR/unity/"{*.svg,*.png,dash-widgets.json} "$THEME_DIR/unity" - cp -r "$SRC_DIR/unity/assets${ELSE_LIGHT:-}" "$THEME_DIR/unity/assets" - - mkdir -p "$THEME_DIR/xfwm4" - cp -r "$SRC_DIR/xfwm4/"{*.svg,themerc} "$THEME_DIR/xfwm4" - cp -r "$SRC_DIR/xfwm4/assets${ELSE_LIGHT:-}" "$THEME_DIR/xfwm4/assets" -} - -# Bakup and install files related to GDM theme -install_gdm() { - local 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'..." - cp -an "$GS_THEME_FILE" "$GS_THEME_FILE.bak" - glib-compile-resources \ - --sourcedir="$THEME_DIR/gnome-shell" \ - --target="$GS_THEME_FILE" \ - "$THEME_DIR/gnome-shell/gnome-shell-theme.gresource.xml" - else - echo - echo "ERROR: Failed to install '$GS_THEME_FILE'" - exit 1 - fi - - if [[ -f "$UBUNTU_THEME_FILE" ]]; then - echo "Installing '$UBUNTU_THEME_FILE'..." - cp -an "$UBUNTU_THEME_FILE" "$UBUNTU_THEME_FILE.bak" - cp -af "$THEME_DIR/gnome-shell/gnome-shell.css" "$UBUNTU_THEME_FILE" - fi -} - -while [[ "$#" -gt 0 ]]; do - case "${1:-}" in - -d|--dest) - dest="$2" - if [[ ! -d "$dest" ]]; then - echo "ERROR: Destination directory does not exist." - exit 1 - fi - shift 2 - ;; - -n|--name) - _name="$2" - shift 2 - ;; - -g|--gdm) - gdm='true' - shift 1 - ;; - -c|--color) - shift - for variant in "$@"; do - case "$variant" in - standard) - colors+=("${COLOR_VARIANTS[0]}") - shift - ;; - dark) - colors+=("${COLOR_VARIANTS[1]}") - shift - ;; - light) - colors+=("${COLOR_VARIANTS[2]}") - shift - ;; - -*) - break - ;; - *) - echo "ERROR: Unrecognized color variant '$1'." - echo "Try '$0 --help' for more information." - exit 1 - ;; - esac - done - ;; - -s|--size) - shift - for variant in "$@"; do - case "$variant" in - standard) - sizes+=("${SIZE_VARIANTS[0]}") - shift - ;; - compact) - sizes+=("${SIZE_VARIANTS[1]}") - shift - ;; - -*) - break - ;; - *) - echo "ERROR: Unrecognized size variant '${1:-}'." - echo "Try '$0 --help' for more information." - exit 1 - ;; - esac - done - ;; - -h|--help) - usage - exit 0 - ;; - *) - echo "ERROR: Unrecognized installation option '${1:-}'." - echo "Try '$0 --help' for more information." - exit 1 - ;; - esac -done - -if [[ ! -w "${dest:-$DEST_DIR}" ]]; then - echo "Please run as root." - exit 1 -fi - -for color in "${colors[@]:-${COLOR_VARIANTS[@]}}"; do - for size in "${sizes[@]:-${SIZE_VARIANTS[@]}}"; do - install "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size" - done -done - -if [[ "${gdm:-}" == 'true' ]]; then - install_gdm "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size" -fi - -echo -echo "Done." diff --git a/parse-sass.sh b/parse-sass.sh deleted file mode 100755 index f860d1c02..000000000 --- a/parse-sass.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -set -ueo pipefail - -if [[ ! "$(which sassc 2> /dev/null)" ]]; then - echo "'sassc' needs to be installed to generate the CSS." - exit 1 -fi - -SASSC_OPT=('-M' '-t' 'expanded') - -_COLOR_VARIANTS=('' '-dark' '-light') -_SIZE_VARIANTS=('' '-compact') - -GTK_VERSIONS=('3.0') -GS_VERSIONS=('3.18' '3.24' '3.26' '3.28' '3.30') - -if [[ ! -z "${COLOR_VARIANTS:-}" ]]; then - IFS=', ' read -r -a _COLOR_VARIANTS <<< "${COLOR_VARIANTS:-}" -fi - -if [[ ! -z "${SIZE_VARIANTS:-}" ]]; then - IFS=', ' read -r -a _SIZE_VARIANTS <<< "${SIZE_VARIANTS:-}" -fi - -echo "== Generating the CSS..." - -for color in "${_COLOR_VARIANTS[@]}"; do - for size in "${_SIZE_VARIANTS[@]}"; do - for version in "${GTK_VERSIONS[@]}"; do - sassc "${SASSC_OPT[@]}" "src/gtk/$version/gtk$color$size."{scss,css} - done - - for version in "${GS_VERSIONS[@]}"; do - sassc "${SASSC_OPT[@]}" "src/gnome-shell/$version/gnome-shell$color$size."{scss,css} - done - - sassc "${SASSC_OPT[@]}" "src/cinnamon/cinnamon$color$size."{scss,css} - done -done - -sassc "${SASSC_OPT[@]}" src/chrome/chrome-scrollbar/scrollbars.{scss,css} -sassc "${SASSC_OPT[@]}" src/chrome/chrome-scrollbar-dark/scrollbars.{scss,css} diff --git a/render-assets.sh b/render-assets.sh deleted file mode 100755 index b0098b901..000000000 --- a/render-assets.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -set -ueo pipefail - -if [[ ! "$(which inkscape 2> /dev/null)" ]]; then - echo "'inkscape' needs to be installed to generate the PNG." - exit 1 -fi - -if [[ ! "$(which optipng 2> /dev/null)" ]]; then - echo "'optipng' needs to be installed to generate the PNG." - exit 1 -fi - -chrome() ( - cd src/chrome - ./render-assets.sh -) - -gtk() ( - cd src/gtk - ./render-assets.sh -) - -gtk2_light() ( - cd src/gtk-2.0 - ./render-assets.sh light -) - -gtk2_dark() ( - cd src/gtk-2.0 - ./render-assets.sh dark -) - -case "${1:-}" in - "") - chrome - gtk - gtk2_light - gtk2_dark - ;; - chrome) - chrome - ;; - gtk) - gtk - ;; - gtk2) - gtk2_light - gtk2_dark - ;; - gtk2-light) - gtk2_light - ;; - gtk2-dark) - gtk2_dark - ;; - *) - echo "Unknown argument '$1'" - echo "Use 'chrome', 'gtk', 'gtk2', 'gtk2-light' or 'gtk2-dark' as an argument." - exit 1 - ;; -esac diff --git a/test.sh b/test.sh deleted file mode 100755 index 17ea78843..000000000 --- a/test.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -# -# Once run the script, no need to run ./install.sh for testing. ;) -# Without an argument, this will install only normal variant. -# Valid arguments are: -# -# compact dark dark-compact light light-compact all uninstall -# -# FIXME: `unity` and `xfwm4` are not fully supported for now since `*.svg` link incorrect locales (with '-light' variant). -# FIXME: Multiple arguments should be allowed. -set -ueo pipefail - -REPO_DIR="$(cd "$(dirname "$0")" && pwd)" -SRC_DIR="$REPO_DIR/src" - -DEST_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? -SIZE_VARIANTS=('' '-compact') - -GTK_VERSIONS=('3.0') -GS_VERSIONS=('3.18' '3.24' '3.26' '3.28' '3.30') -LATEST_GS_VERSION="${GS_VERSIONS[-1]}" - -# Set a proper gnome-shell theme version -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")" )); then - GS_VERSION="$version" - break - elif (( "$(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION")" )); then - GS_VERSION="$LATEST_GS_VERSION" - break - fi - done -else - GS_VERSION="$LATEST_GS_VERSION" -fi - -test() { - local color="$1" - local size="$2" - - [[ "$color" == '-dark' ]] && local ELSE_DARK="$color" - [[ "$color" == '-light' ]] && local ELSE_LIGHT="$color" - - local THEME_DIR="${DEST_DIR:?}/$THEME_NAME$color$size" - - # SC2115: Protect /. - [[ -d "$THEME_DIR" ]] && rm -rf "${THEME_DIR:?}" - - mkdir -p "$THEME_DIR" - ln -sT "$SRC_DIR/index$color$size.theme" "$THEME_DIR/index.theme" - - mkdir -p "$THEME_DIR/cinnamon" - ln -s "$SRC_DIR/cinnamon/assets" "$THEME_DIR/cinnamon" - ln -s "$SRC_DIR/cinnamon/thumbnail.png" "$THEME_DIR/cinnamon" - ln -sT "$SRC_DIR/cinnamon/cinnamon$color$size.css" "$THEME_DIR/cinnamon/cinnamon.css" - - mkdir -p "$THEME_DIR/gnome-shell" - ln -s "$SRC_DIR/gnome-shell/"{extensions,pad-osd.css,process-working.svg} "$THEME_DIR/gnome-shell" - ln -sT "$SRC_DIR/gnome-shell/assets${ELSE_DARK:-}" "$THEME_DIR/gnome-shell/assets" - ln -sT "$SRC_DIR/gnome-shell/$GS_VERSION/gnome-shell$color$size.css" "$THEME_DIR/gnome-shell/gnome-shell.css" - - mkdir -p "$THEME_DIR/gtk-2.0" - ln -s "$SRC_DIR/gtk-2.0/"{apps.rc,hacks.rc,main.rc} "$THEME_DIR/gtk-2.0" - ln -sT "$SRC_DIR/gtk-2.0/assets${ELSE_DARK:-}" "$THEME_DIR/gtk-2.0/assets" - ln -sT "$SRC_DIR/gtk-2.0/gtkrc$color" "$THEME_DIR/gtk-2.0/gtkrc" - - for version in "${GTK_VERSIONS[@]}"; do - mkdir -p "$THEME_DIR/gtk-$version" - ln -s "$SRC_DIR/gtk/assets" "$THEME_DIR/gtk-$version" - ln -sT "$SRC_DIR/gtk/$version/gtk$color$size.css" "$THEME_DIR/gtk-$version/gtk.css" - [[ "$color" != '-dark' ]] && \ - ln -sT "$SRC_DIR/gtk/$version/gtk-dark$size.css" "$THEME_DIR/gtk-$version/gtk-dark.css" - done - - mkdir -p "$THEME_DIR/metacity-1" - ln -s "$SRC_DIR/metacity-1/"{assets,metacity-theme-3.xml} "$THEME_DIR/metacity-1" - ln -sT "$SRC_DIR/metacity-1/metacity-theme-2${ELSE_LIGHT:-}.xml" "$THEME_DIR/metacity-1/metacity-theme-2.xml" - - mkdir -p "$THEME_DIR/unity" - ln -s "$SRC_DIR/unity/"{*.svg,*.png,dash-widgets.json} "$THEME_DIR/unity" - ln -sT "$SRC_DIR/unity/assets${ELSE_LIGHT:-}" "$THEME_DIR/unity/assets" - - mkdir -p "$THEME_DIR/xfwm4" - 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'" -} - -case "${1:-}" in - "") - test '' '' - ;; - compact) - test '' '-compact' - ;; - dark) - test '-dark' '' - ;; - dark-compact) - test '-dark' '-compact' - ;; - light) - test '-light' '' - ;; - light-compact) - test '-light' '-compact' - ;; - all) - test '' '' - test '' '-compact' - test '-dark' '' - test '-dark' '-compact' - test '-light' '' - test '-light' '-compact' - ;; - uninstall) - # SC2115: Protect /. - 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'" - ;; -esac From 7e9c1cd4ffa9c7dedb00392fed5034e205476985 Mon Sep 17 00:00:00 2001 From: think4web Date: Thu, 4 Jun 2020 09:38:27 +0300 Subject: [PATCH 2/2] Removed all unnecessary. --- scripts/darker.sh | 33 --------------------------------- scripts/mix.sh | 37 ------------------------------------- 2 files changed, 70 deletions(-) delete mode 100755 scripts/darker.sh delete mode 100755 scripts/mix.sh diff --git a/scripts/darker.sh b/scripts/darker.sh deleted file mode 100755 index b9514a401..000000000 --- a/scripts/darker.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -set -ueo pipefail -#set -x - -darker_channel() { - 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}" - - 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")" - - printf '%02x%02x%02x\n' "$r" "$g" "$b" -} - -darker "$@" diff --git a/scripts/mix.sh b/scripts/mix.sh deleted file mode 100755 index 73c1950c1..000000000 --- a/scripts/mix.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -set -ueo pipefail -#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 ]]; 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}" - - 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")" - - printf '%02x%02x%02x\n' "$r" "$g" "$b" -} - -mix "$@"