Scripting rework for sanity and safety (#252)
Don't hardcode paths to inkscape and optipng.
Big scripting rework. Just makes all the bash usage a lot more sane and SAFE all across the board. Every script in the repo now passes Shellcheck!
Don't hardcode paths to inkscape and optipng.
Big scripting rework. Just makes all the bash usage a lot more sane and SAFE all across the board. Every script in the repo now passes Shellcheck!
by roundabout, Saturday, 19 May 2018, 08:46:40 (1526719600), pushed by roundabout, Sunday, 11 May 2025, 13:22:25 (1746969745)
Author identity: nana-4 <nana-4@users.noreply.github.com>
ba1fb469ff489c1e3e895226ad979ddbcb97d25d
#!/usr/bin/env bash
# shellcheck disable=SC1090
#set -x
set -ue
SRC_PATH=$(readlink -f $(dirname $0))
set -ueo pipefail
SRC_PATH=$(readlink -f "$(dirname "$0")")
darker () {
"${SRC_PATH}/scripts/darker.sh" $@
"$SRC_PATH/scripts/darker.sh" "$@"
}
mix () {
"${SRC_PATH}/scripts/mix.sh" $@
"$SRC_PATH/scripts/mix.sh" "$@"
}
is_dark() {
hexinput=$(echo $1 | tr '[:lower:]' '[:upper:]')
half_darker="$(darker ${hexinput} 88)"
if [[ "${half_darker}" = "000000" ]] ; then
true
else
return
fi
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:"
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")"
# 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 [[ $# > 0 ]]
while [[ "$#" -gt 0 ]]
do
case ${1} in
case "$1" in
-p|--path-list)
CUSTOM_PATHLIST="${2}"
CUSTOM_PATHLIST="$2"
shift
;;
-o|--output)
OUTPUT_THEME_NAME="${2}"
OUTPUT_THEME_NAME="$2"
shift
;;
-d|--hidpi)
OPTION_GTK2_HIDPI="${2}"
OPTION_GTK2_HIDPI="$2"
shift
;;
*)
if [[ "${1}" == -* ]] || [[ ${THEME-} ]]; then
echo "unknown option ${1}"
if [[ "$1" == -* ]] || [[ "${THEME-}" ]]; then
echo "unknown option $1"
print_usage
exit 2
fi
THEME="${1}"
THEME="$1"
;;
esac
shift
EXPORT_QT5CT=0
for FILEPATH in "${PATHLIST[@]}"; do
if [[ ${FILEPATH} == *qt5ct* ]] ;then
if [[ "$FILEPATH" == *qt5ct* ]] ;then
EXPORT_QT5CT=1
fi
done
OPTION_GTK2_HIDPI=$(echo ${OPTION_GTK2_HIDPI-False} | tr '[:upper:]' '[:lower:]')
OPTION_GTK2_HIDPI=$(tr '[:upper:]' '[:lower:]' <<< "${OPTION_GTK2_HIDPI-False}")
if [[ ${THEME} == */* ]] || [[ ${THEME} == *.* ]] ; then
if [[ "$THEME" == */* ]] || [[ "$THEME" == *.* ]] ; then
source "$THEME"
THEME=$(basename ${THEME})
THEME=$(basename "$THEME")
else
if [[ -f "$SRC_PATH/../colors/$THEME" ]] ; then
source "$SRC_PATH/../colors/$THEME"
else
echo "Theme '${THEME}' not found"
echo "Theme '$THEME' not found"
exit 1
fi
fi
if [[ $(date +"%m%d") = "0401" ]] && [[ ! $(echo "$@" | grep "no-jokes") ]] ; then
echo -e "\n\nError patching uxtheme.dll\n\n"
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
WM_BORDER_FOCUS=${WM_BORDER_FOCUS-$SEL_BG}
WM_BORDER_UNFOCUS=${WM_BORDER_UNFOCUS-$MENU_BG}
MATERIA_STYLE_COMPACT=$(echo ${MATERIA_STYLE_COMPACT-True} | tr '[:upper:]' '[:lower:]')
MATERIA_COLOR_VARIANT=$(echo ${MATERIA_COLOR_VARIANT:-} | tr '[:upper:]' '[:lower:]')
UNITY_DEFAULT_LAUNCHER_STYLE=$(echo ${UNITY_DEFAULT_LAUNCHER_STYLE-False} | tr '[:upper:]' '[:lower:]')
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}
ROUNDNESS_GTK2_HIDPI=$(( ${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)
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_COLOR11=${TERMINAL_COLOR11:-FF6D00}
TERMINAL_COLOR12=${TERMINAL_COLOR12:-66BB6A}
light_folder_base_fallback="$(darker ${SEL_BG} -10)"
medium_base_fallback="$(darker ${SEL_BG} 37)"
dark_stroke_fallback="$(darker ${SEL_BG} 50)"
# 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}"
OUTPUT_THEME_NAME=${OUTPUT_THEME_NAME-oomox-$THEME}
DEST_PATH="$HOME/.themes/${OUTPUT_THEME_NAME/\//-}"
test "$SRC_PATH" = "$DEST_PATH" && echo "can't do that" && exit 1
if [[ "$SRC_PATH" == "$DEST_PATH" ]]; then echo "can't do that"; exit 1; fi
tempdir=$(mktemp -d)
function post_clean_up {
rm -r "${tempdir}" || true
rm -r "$tempdir" || :
}
trap post_clean_up EXIT SIGHUP SIGINT SIGTERM
cp -r ${SRC_PATH}/* ${tempdir}/
cd ${tempdir}
cp -r "$SRC_PATH/"* "$tempdir/"
cd "$tempdir"
# autodetection which color variant to use
if [[ -z "${MATERIA_COLOR_VARIANT}" ]] ; then
if is_dark ${BG} ; then
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"
else
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'' \
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/Materia/%OUTPUT_THEME_NAME%/g' \
{} \; ;
else
find "${FILEPATH}" -type f -not -name '_color-palette.scss' -exec sed -i'' \
find "$FILEPATH" -type f -not -name '_color-palette.scss' -exec sed -i'' \
-e 's/#000000/%BG%/g' \
-e 's/#212121/%BG%/g' \
-e 's/#757575/%INACTIVE_FG%/g' \
#-e 's/%INACTIVE_TXT_FG%/'"$INACTIVE_TXT_FG"'/g' \
#-e 's/%INACTIVE_MENU_FG%/'"$INACTIVE_MENU_FG"'/g' \
if [[ ! -z "${DEBUG:-}" ]] ; then
echo "You can debug TEMP DIR: ${tempdir}, press [Enter] when finish" && read
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'' \
find "$FILEPATH" -type f -exec sed -i'' \
-e 's/%BG%/#'"$BG"'/g' \
-e 's/%BG2%/#'"$(darker $BG)"'/g' \
-e 's/%FG%/#'"$FG"'/g' \
done
rm ./src/gtk/3.{18,20,22}/*.css
if [[ ${MATERIA_COLOR_VARIANT} == "standard" ]] ; then
if [[ "$MATERIA_COLOR_VARIANT" == "standard" ]] ; then
rm ./src/gtk/3.{18,20,22}/gtk-light*.scss
rm ./src/gtk/3.{18,20,22}/gtk-dark*.scss
COLOR_VARIANTS=","
COLOR_VARIANT="standard"
fi
if [[ ${MATERIA_COLOR_VARIANT} == "light" ]] ; then
if [[ "$MATERIA_COLOR_VARIANT" == "light" ]] ; then
rm ./src/gtk/3.{18,20,22}/gtk-dark*.scss
rm ./src/gtk/3.{18,20,22}/gtk{,-compact}.scss || true
COLOR_VARIANTS="-light"
COLOR_VARIANT="light"
fi
if [[ ${MATERIA_COLOR_VARIANT} == "dark" ]] ; then
if [[ "$MATERIA_COLOR_VARIANT" == "dark" ]] ; then
rm ./src/gtk/3.{18,20,22}/gtk-light*.scss
rm ./src/gtk/3.{18,20,22}/gtk{,-compact}.scss || true
COLOR_VARIANTS="-dark"
COLOR_VARIANT="dark"
fi
if [[ ${OPTION_GTK2_HIDPI} == "true" ]] ; then
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:-}
if [[ -z "${config_home}" ]] ; then
config_home="${HOME}/.config"
fi
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" ]] ; then
if [[ "$UNITY_DEFAULT_LAUNCHER_STYLE" == "true" ]] ; then
rm ./src/unity/launcher*.svg
fi
if [[ ${MATERIA_STYLE_COMPACT} == "true" ]] ; then
if [[ "$MATERIA_STYLE_COMPACT" == "true" ]] ; then
SIZE_VARIANTS="-compact"
SIZE_VARIANT="compact"
else
SIZE_VARIANT="standard"
fi
SIZE_VARIANTS="${SIZE_VARIANTS}" COLOR_VARIANTS="${COLOR_VARIANTS}" THEME_DIR_BASE=${DEST_PATH} ./parse-sass.sh
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
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
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}"
./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}"
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}"
mv "$GENERATED_PATH" "$DEST_PATH"
fi
echo
echo "== SUCCESS"
echo "== The theme was installed to '${DEST_PATH}'"
echo "== The theme was installed to '$DEST_PATH'"
exit 0
#!/bin/bash
#set -ueo pipefail
set -ueo pipefail
#set -x
REPO_DIR=$(cd $(dirname $0) && pwd)
SRC_DIR=${REPO_DIR}/src
REPO_DIR=$(cd "$(dirname "$0")" && pwd)
SRC_DIR=$REPO_DIR/src
DEST_DIR=/usr/share/themes
THEME_NAME=Materia
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) ]]; then
CURRENT_GS_VERSION=$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)
for version in "${GS_VERSIONS[@]}"; do
if (( $(echo "$CURRENT_GS_VERSION <= $version" | bc) )); then
GS_VERSION=${version}
if (( $(bc <<< "$CURRENT_GS_VERSION <= $version") )); then
GS_VERSION=$version
break
elif (( $(echo "$CURRENT_GS_VERSION > $LATEST_GS_VERSION" | bc) )); then
GS_VERSION=${LATEST_GS_VERSION}
elif (( $(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION") )); then
GS_VERSION=$LATEST_GS_VERSION
break
fi
done
else
GS_VERSION=${LATEST_GS_VERSION}
GS_VERSION=$LATEST_GS_VERSION
fi
usage() {
printf "%s\n" "Usage: $0 [OPTIONS...]"
printf "\n%s\n" "OPTIONS:"
printf " %-25s%s\n" "-d, --dest DIR" "Specify theme destination directory (Default: ${DEST_DIR})"
printf " %-25s%s\n" "-n, --name NAME" "Specify theme name (Default: ${THEME_NAME})"
printf " %-25s%s\n" "-c, --color VARIANTS..." "Specify theme color variant(s) [standard|dark|light] (Default: All variants)"
printf " %-25s%s\n" "-s, --size VARIANT" "Specify theme size variant [standard|compact] (Default: All variants)"
printf " %-25s%s\n" "-g, --gdm" "Install GDM theme"
printf " %-25s%s\n" "-h, --help" "Show this help"
printf "\n%s\n" "INSTALLATION EXAMPLES:"
printf "%s\n" "Install all theme variants into ~/.themes"
printf " %s\n" "$0 --dest ~/.themes"
printf "%s\n" "Install all theme variants into ~/.themes including GDM theme"
printf " %s\n" "$0 --dest ~/.themes --gdm"
printf "%s\n" "Install standard theme variant only"
printf " %s\n" "$0 --color standard --size standard"
printf "%s\n" "Install specific theme variants with different name into ~/.themes"
printf " %s\n" "$0 --dest ~/.themes --name MyTheme --color light dark --size compact"
printf "%s\\n" "Usage: $0 [OPTIONS...]"
printf "\\n%s\\n" "OPTIONS:"
printf " %-25s%s\\n" "-d, --dest DIR" "Specify theme destination directory (Default: $DEST_DIR)"
printf " %-25s%s\\n" "-n, --name NAME" "Specify theme name (Default: $THEME_NAME)"
printf " %-25s%s\\n" "-c, --color VARIANTS..." "Specify theme color variant(s) [standard|dark|light] (Default: All variants)"
printf " %-25s%s\\n" "-s, --size VARIANT" "Specify theme size variant [standard|compact] (Default: All variants)"
printf " %-25s%s\\n" "-g, --gdm" "Install GDM theme"
printf " %-25s%s\\n" "-h, --help" "Show this help"
printf "\\n%s\\n" "INSTALLATION EXAMPLES:"
printf "%s\\n" "Install all theme variants into ~/.themes"
printf " %s\\n" "$0 --dest ~/.themes"
printf "%s\\n" "Install all theme variants into ~/.themes including GDM theme"
printf " %s\\n" "$0 --dest ~/.themes --gdm"
printf "%s\\n" "Install standard theme variant only"
printf " %s\\n" "$0 --color standard --size standard"
printf "%s\\n" "Install specific theme variants with different name into ~/.themes"
printf " %s\\n" "$0 --dest ~/.themes --name MyTheme --color light dark --size compact"
}
install() {
local dest=${1}
local name=${2}
local color=${3}
local size=${4}
local 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}${size}
local THEME_DIR=$dest/$name$color$size
[[ -d ${THEME_DIR} ]] && rm -rf ${THEME_DIR}
# SC2115: Protect /.
[[ -d "$THEME_DIR" ]] && rm -rf "${THEME_DIR:?}"
echo "Installing '${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"
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/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/cinnamon${color}${size}.css ${THEME_DIR}/cinnamon/cinnamon.css
cp -r ${SRC_DIR}/cinnamon/thumbnail.png ${THEME_DIR}/cinnamon/thumbnail.png
cp -r ${SRC_DIR}/cinnamon/assets ${THEME_DIR}/cinnamon/assets
mkdir -p "$THEME_DIR/cinnamon"
cp -r "$SRC_DIR/cinnamon/cinnamon$color$size.css" "$THEME_DIR/cinnamon/cinnamon.css"
cp -r "$SRC_DIR/cinnamon/thumbnail.png" "$THEME_DIR/cinnamon/thumbnail.png"
cp -r "$SRC_DIR/cinnamon/assets" "$THEME_DIR/cinnamon/assets"
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/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
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
cp -r "$SRC_DIR/gtk/assets" "$THEME_DIR/gtk-assets"
for version in "${GTK_VERSIONS[@]}"; do
if [[ ${version} == '3.18' ]]; then
mkdir -p ${THEME_DIR}/gtk-3.0
ln -s ../gtk-assets ${THEME_DIR}/gtk-3.0/assets
cp -r ${SRC_DIR}/gtk/${version}/gtk${color}.css ${THEME_DIR}/gtk-3.0/gtk.css
[[ ${color} != '-dark' ]] && \
cp -r ${SRC_DIR}/gtk/${version}/gtk-dark.css ${THEME_DIR}/gtk-3.0/gtk-dark.css
if [[ $version == '3.18' ]]; then
mkdir -p "$THEME_DIR/gtk-3.0"
ln -s ../gtk-assets "$THEME_DIR/gtk-3.0/assets"
cp -r "$SRC_DIR/gtk/$version/gtk$color.css" "$THEME_DIR/gtk-3.0/gtk.css"
[[ "$color" != '-dark' ]] && \
cp -r "$SRC_DIR/gtk/$version/gtk-dark.css" "$THEME_DIR/gtk-3.0/gtk-dark.css"
else
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
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"
fi
done
mkdir -p ${THEME_DIR}/metacity-1
cp -r ${SRC_DIR}/metacity-1/assets ${THEME_DIR}/metacity-1
cp -r ${SRC_DIR}/metacity-1/metacity-theme-2${ELSE_LIGHT}.xml ${THEME_DIR}/metacity-1/metacity-theme-2.xml
cp -r ${SRC_DIR}/metacity-1/metacity-theme-3${ELSE_LIGHT}.xml ${THEME_DIR}/metacity-1/metacity-theme-3.xml
mkdir -p "$THEME_DIR/metacity-1"
cp -r "$SRC_DIR/metacity-1/assets" "$THEME_DIR/metacity-1"
cp -r "$SRC_DIR/metacity-1/metacity-theme-2${ELSE_LIGHT:-}.xml" "$THEME_DIR/metacity-1/metacity-theme-2.xml"
cp -r "$SRC_DIR/metacity-1/metacity-theme-3${ELSE_LIGHT:-}.xml" "$THEME_DIR/metacity-1/metacity-theme-3.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/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
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"
}
install_gdm() {
local THEME_DIR=${1}/${2}${3}${4}
local THEME_DIR=$1/$2$3$4
# bakup and install files related to gdm theme
if [[ ! -f /usr/share/gnome-shell/gnome-shell-theme.gresource.bak ]]; then
mv -f /usr/share/gnome-shell/gnome-shell-theme.gresource \
mv -f /usr/share/gnome-shell/theme/ubuntu.css \
/usr/share/gnome-shell/theme/ubuntu.css.bak
fi
cp -af ${THEME_DIR}/gnome-shell/gnome-shell.css \
cp -af "$THEME_DIR/gnome-shell/gnome-shell.css" \
/usr/share/gnome-shell/theme/ubuntu.css
fi
glib-compile-resources \
--sourcedir=${THEME_DIR}/gnome-shell \
--sourcedir="$THEME_DIR/gnome-shell" \
--target=/usr/share/gnome-shell/gnome-shell-theme.gresource \
${THEME_DIR}/gnome-shell/gnome-shell-theme.gresource.xml
"$THEME_DIR/gnome-shell/gnome-shell-theme.gresource.xml"
echo "Installing 'gnome-shell-theme.gresource'..."
}
while [[ $# -gt 0 ]]; do
case "${1}" in
while [[ "$#" -gt 0 ]]; do
case "${1:-}" in
-d|--dest)
dest="${2}"
if [[ ! -d "${dest}" ]]; then
dest="$2"
if [[ ! -d "$dest" ]]; then
echo "ERROR: Destination directory does not exist."
exit 1
fi
shift 2
;;
-n|--name)
name="${2}"
name="$2"
shift 2
;;
-g|--gdm)
;;
-c|--color)
shift
for variant in "${@}"; do
case "${variant}" in
for variant in "$@"; do
case "$variant" in
standard)
colors+=("${COLOR_VARIANTS[0]}")
shift
colors+=("${COLOR_VARIANTS[2]}")
shift
;;
-*|--*)
-*)
break
;;
*)
;;
-s|--size)
shift
for variant in "${@}"; do
case "${variant}" in
for variant in "$@"; do
case "$variant" in
standard)
sizes+=("${SIZE_VARIANTS[0]}")
shift
sizes+=("${SIZE_VARIANTS[1]}")
shift
;;
-*|--*)
-*)
break
;;
*)
echo "ERROR: Unrecognized size variant '$1'."
echo "ERROR: Unrecognized size variant '${1:-}'."
echo "Try '$0 --help' for more information."
exit 1
;;
exit 0
;;
*)
echo "ERROR: Unrecognized installation option '$1'."
echo "ERROR: Unrecognized installation option '${1:-}'."
echo "Try '$0 --help' for more information."
exit 1
;;
esac
done
if [[ ! -w "${dest:-${DEST_DIR}}" ]]; then
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}"
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}"
if [[ "${gdm:-}" == true ]]; then
install_gdm "${dest:-$DEST_DIR}" "${name:-$THEME_NAME}" "$color" "$size"
fi
echo
#!/bin/bash
set -ueo pipefail
if [ ! "$(which sassc 2> /dev/null)" ]; then
if [[ ! "$(which sassc 2> /dev/null)" ]]; then
echo sassc needs to be installed to generate the css.
exit 1
fi
_COLOR_VARIANTS=('' '-dark' '-light')
if [ ! -z "${COLOR_VARIANTS:-}" ]; then
if [[ ! -z "${COLOR_VARIANTS:-}" ]]; then
IFS=', ' read -r -a _COLOR_VARIANTS <<< "${COLOR_VARIANTS:-}"
fi
_SIZE_VARIANTS=('' '-compact')
if [ ! -z "${SIZE_VARIANTS:-}" ]; then
if [[ ! -z "${SIZE_VARIANTS:-}" ]]; then
IFS=', ' read -r -a _SIZE_VARIANTS <<< "${SIZE_VARIANTS:-}"
fi
SASSC_OPT="-M -t expanded"
SASSC_OPT=('-M' '-t' 'expanded')
echo "== Generating the CSS..."
for color in "${_COLOR_VARIANTS[@]}"; do
# The '-compact' variant is not supported for gtk '3.18'
sassc $SASSC_OPT src/gtk/3.18/gtk${color}.{scss,css}
sassc "${SASSC_OPT[@]}" "src/gtk/3.18/gtk$color."{scss,css}
for size in "${_SIZE_VARIANTS[@]}"; do
sassc $SASSC_OPT src/cinnamon/cinnamon${color}${size}.{scss,css}
sassc "${SASSC_OPT[@]}" "src/cinnamon/cinnamon$color$size."{scss,css}
for version in '3.20' '3.22'; do
sassc $SASSC_OPT src/gtk/${version}/gtk${color}${size}.{scss,css}
sassc "${SASSC_OPT[@]}" "src/gtk/$version/gtk$color$size."{scss,css}
done
# This gnome-shell theme can skip versions '3.20' & '2.22'
for version in '3.18' '3.24' '3.26' '3.28'; do
sassc $SASSC_OPT src/gnome-shell/${version}/gnome-shell${color}${size}.{scss,css}
sassc "${SASSC_OPT[@]}" "src/gnome-shell/$version/gnome-shell$color$size."{scss,css}
done
done
done
sassc $SASSC_OPT src/chrome/chrome-scrollbar/scrollbars.{scss,css}
sassc $SASSC_OPT src/chrome/chrome-scrollbar-dark/scrollbars.{scss,css}
sassc "${SASSC_OPT[@]}" src/chrome/chrome-scrollbar/scrollbars.{scss,css}
sassc "${SASSC_OPT[@]}" src/chrome/chrome-scrollbar-dark/scrollbars.{scss,css}
#!/bin/bash
set -ueo pipefail
if [ ! "$(which inkscape 2> /dev/null)" ]; then
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
if [[ ! "$(which optipng 2> /dev/null)" ]]; then
echo optipng needs to be installed to generate the png.
exit 1
fi
gtk() (
cd src/gtk
rm assets/*.png
rm assets/*.png || :
./render-assets.sh
)
gtk2_light() (
cd src/gtk-2.0
rm assets/*.png
./render-assets.sh
rm assets/*.png || :
./render-assets.sh light
)
gtk2_dark() (
cd src/gtk-2.0
rm assets-dark/*.png
./render-assets-dark.sh
rm assets-dark/*.png || :
./render-assets.sh dark
)
case "${1}" in
case "${1:-}" in
"")
gtk
gtk2_light
gtk2_dark
;;
*)
echo "Unknown argument: '${1}'"
echo "Unknown argument: '$1'"
echo "Use 'gtk', 'gtk2', 'gtk2-light' or 'gtk2-dark' as an argument."
;;
esac
#!/usr/bin/env bash
set -ueo pipefail
#set -x
darker_channel() {
value=${1}
light_delta=${2}
result=$(echo "ibase=16; ${value} - ${light_delta}" | bc)
if [[ ${result} -lt 0 ]] ; then
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
if [[ "$result" -gt 255 ]] ; then
result=255
fi
echo "${result}"
echo "$result"
}
darker() {
hexinput=$(echo $1 | tr '[:lower:]' '[:upper:]')
light_delta=${2-10}
hexinput=$(tr '[:lower:]' '[:upper:]' <<< "$1")
light_delta="${2-10}"
a=`echo $hexinput | cut -c-2`
b=`echo $hexinput | cut -c3-4`
c=`echo $hexinput | cut -c5-6`
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 $@
darker "$@"
#!/usr/bin/env bash
set -ueo pipefail
#set -x
mix_channel() {
value1=$(printf '%03d' 0x${1})
value2=$(printf '%03d' 0x${2})
ratio=${3}
result=$(echo "scale=0; (${value1} * 100 * ${ratio} + ${value2} * 100 * (1 - ${ratio}))/100" | bc)
if [[ ${result} -lt 0 ]] ; then
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
elif [[ "$result" -gt 255 ]] ; then
result=255
fi
echo "${result}"
echo "$result"
}
mix() {
hexinput1=$(echo $1 | tr '[:lower:]' '[:upper:]')
hexinput2=$(echo $2 | tr '[:lower:]' '[:upper:]')
ratio=${3-0.5}
hexinput1=$(tr '[:lower:]' '[:upper:]' <<< "$1")
hexinput2=$(tr '[:lower:]' '[:upper:]' <<< "$2")
ratio="${3-0.5}"
a=$(echo $hexinput1 | cut -c-2)
b=$(echo $hexinput1 | cut -c3-4)
c=$(echo $hexinput1 | cut -c5-6)
d=$(echo $hexinput2 | cut -c-2)
e=$(echo $hexinput2 | cut -c3-4)
f=$(echo $hexinput2 | cut -c5-6)
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 $@
mix "$@"
#! /bin/bash
set -ueo pipefail
INKSCAPE="/usr/bin/inkscape"
OPTIPNG="/usr/bin/optipng"
SRC_FILE="assets-dark.svg"
ASSETS_DIR="assets-dark"
i=${1}
GTK2_HIDPI=$(echo ${GTK2_HIDPI-False} | tr '[:upper:]' '[:lower:]')
if [[ ${GTK2_HIDPI} == "true" ]] ; then
EXTRA_OPTIONS="--export-dpi=192"
else
EXTRA_OPTIONS=""
fi
if [ -f $ASSETS_DIR/$i.png ]; then
echo $ASSETS_DIR/$i.png exists.
else
echo Rendering $ASSETS_DIR/$i.png
$INKSCAPE --export-id=$i \
--export-id-only \
--export-background-opacity=0 \
$EXTRA_OPTIONS \
--export-png=$ASSETS_DIR/$i.png $SRC_FILE >/dev/null \
&& $OPTIPNG -o7 --quiet $ASSETS_DIR/$i.png
fi
exit 0
#! /bin/bash
set -ueo pipefail
INKSCAPE="/usr/bin/inkscape"
OPTIPNG="/usr/bin/optipng"
INKSCAPE="$(which inkscape)"
OPTIPNG="$(which optipng)"
SRC_FILE="assets.svg"
ASSETS_DIR="assets"
if [[ "$1" == "dark" ]]; then
SRC_FILE="assets-dark.svg"
ASSETS_DIR="assets-dark"
else
SRC_FILE="assets.svg"
ASSETS_DIR="assets"
fi
i=${1}
i="$2"
GTK2_HIDPI=$(echo ${GTK2_HIDPI-False} | tr '[:upper:]' '[:lower:]')
if [[ ${GTK2_HIDPI} == "true" ]] ; then
EXTRA_OPTIONS="--export-dpi=192"
GTK2_HIDPI=$(echo "${GTK2_HIDPI-False}" | tr '[:upper:]' '[:lower:]')
if [[ "${GTK2_HIDPI}" == "true" ]] ; then
EXTRA_OPTIONS=("--export-dpi=192")
else
EXTRA_OPTIONS=""
EXTRA_OPTIONS=()
fi
if [ -f $ASSETS_DIR/$i.png ]; then
echo $ASSETS_DIR/$i.png exists.
if [ -f "$ASSETS_DIR/$i.png" ]; then
echo "$ASSETS_DIR/$i.png" exists.
else
echo Rendering $ASSETS_DIR/$i.png
$INKSCAPE --export-id=$i \
echo Rendering "$ASSETS_DIR/$i.png"
"$INKSCAPE" --export-id="$i" \
--export-id-only \
--export-background-opacity=0 \
$EXTRA_OPTIONS \
--export-png=$ASSETS_DIR/$i.png $SRC_FILE >/dev/null \
&& $OPTIPNG -o7 --quiet $ASSETS_DIR/$i.png
${EXTRA_OPTIONS+"${EXTRA_OPTIONS[@]}"} \
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null \
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
fi
exit 0
#! /bin/bash
set -ueo pipefail
INDEX="assets.txt"
_parallel() {
which parallel && parallel $@ || (
while read i; do
$1 $i
done
)
}
cat $INDEX | _parallel ./render-asset-dark.sh
exit 0
#! /bin/bash
set -ueo pipefail
INDEX="assets.txt"
# Make sure that parallel is GNU parallel and not moreutils.
# Otherwise, it fails silently. There's no smooth way to detect this.
if which parallel > /dev/null; then cmd=(parallel)
else cmd=(xargs -n1); fi
_parallel() {
which parallel && parallel $@ || (
while read i; do
$1 $i
done
)
}
cat $INDEX | _parallel ./render-asset.sh
exit 0
"${cmd[@]}" ./render-asset.sh "$1" < assets.txt
#! /bin/bash
set -ueo pipefail
INKSCAPE="/usr/bin/inkscape"
OPTIPNG="/usr/bin/optipng"
INKSCAPE="$(which inkscape)"
OPTIPNG="$(which optipng)"
SRC_FILE="assets.svg"
ASSETS_DIR="assets"
i=${1}
i="$1"
if [ -f $ASSETS_DIR/$i.png ]; then
echo $ASSETS_DIR/$i.png exists.
if [ -f "$ASSETS_DIR/$i.png" ]; then
echo "$ASSETS_DIR/$i.png" exists.
else
echo Rendering $ASSETS_DIR/$i.png
$INKSCAPE --export-id=$i \
echo Rendering "$ASSETS_DIR/$i.png"
"$INKSCAPE" --export-id="$i" \
--export-id-only \
--export-png=$ASSETS_DIR/$i.png $SRC_FILE >/dev/null \
&& $OPTIPNG -o7 --quiet $ASSETS_DIR/$i.png
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null \
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
fi
if [ -f $ASSETS_DIR/$i@2.png ]; then
echo $ASSETS_DIR/$i@2.png exists.
if [ -f "$ASSETS_DIR/$i@2.png" ]; then
echo "$ASSETS_DIR/$i@2.png" exists.
else
echo Rendering $ASSETS_DIR/$i@2.png
$INKSCAPE --export-id=$i \
echo Rendering "$ASSETS_DIR/$i@2.png"
"$INKSCAPE" --export-id="$i" \
--export-dpi=192 \
--export-id-only \
--export-png=$ASSETS_DIR/$i@2.png $SRC_FILE >/dev/null \
&& $OPTIPNG -o7 --quiet $ASSETS_DIR/$i@2.png
--export-png="$ASSETS_DIR/$i@2.png" "$SRC_FILE" >/dev/null \
&& "$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i@2.png"
fi
exit 0
#! /bin/bash
set -ueo pipefail
INDEX="assets.txt"
# Make sure that parallel is GNU parallel and not moreutils.
# Otherwise, it fails silently. There's no smooth way to detect this.
if which parallel > /dev/null; then cmd=(parallel)
else cmd=(xargs -n1); fi
_parallel() {
which parallel && parallel $@ || (
while read i; do
$1 $i
done
)
}
cat $INDEX | _parallel ./render-asset.sh
exit 0
"${cmd[@]}" ./render-asset.sh < assets.txt
#
# 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
REPO_DIR=$(cd "$(dirname "$0")" && pwd)
SRC_DIR=$REPO_DIR/src
DEST_DIR=~/.themes
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.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) ]]; then
CURRENT_GS_VERSION=$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)
for version in "${GS_VERSIONS[@]}"; do
if (( $(echo "$CURRENT_GS_VERSION <= $version" | bc) )); then
GS_VERSION=${version}
if (( $(bc <<< "$CURRENT_GS_VERSION <= $version") )); then
GS_VERSION=$version
break
elif (( $(echo "$CURRENT_GS_VERSION > $LATEST_GS_VERSION" | bc) )); then
GS_VERSION=${LATEST_GS_VERSION}
elif (( $(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION") )); then
GS_VERSION=$LATEST_GS_VERSION
break
fi
done
else
GS_VERSION=${LATEST_GS_VERSION}
GS_VERSION=$LATEST_GS_VERSION
fi
test() {
local color=${1}
local size=${2}
local 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}
local THEME_DIR="${DEST_DIR:?}/$THEME_NAME$color$size"
[[ -d ${THEME_DIR} ]] && rm -rf ${THEME_DIR}
# 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"
ln -sT "$SRC_DIR/index$color$size.theme" "$THEME_DIR/index.theme"
mkdir -p ${THEME_DIR}/gnome-shell
ln -s ${SRC_DIR}/gnome-shell/{extensions,pad-osd.css} ${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/gnome-shell"
ln -s "$SRC_DIR/gnome-shell/"{extensions,pad-osd.css} "$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
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
if [[ ${version} == '3.18' ]]; then
mkdir -p ${THEME_DIR}/gtk-3.0
ln -s ${SRC_DIR}/gtk/assets ${THEME_DIR}/gtk-3.0
ln -sT ${SRC_DIR}/gtk/${version}/gtk${color}.css ${THEME_DIR}/gtk-3.0/gtk.css
[[ ${color} != '-dark' ]] && \
ln -sT ${SRC_DIR}/gtk/${version}/gtk-dark.css ${THEME_DIR}/gtk-3.0/gtk-dark.css
if [[ "$version" == '3.18' ]]; then
mkdir -p "$THEME_DIR/gtk-3.0"
ln -s "$SRC_DIR/gtk/assets" "$THEME_DIR/gtk-3.0"
ln -sT "$SRC_DIR/gtk/$version/gtk$color.css" "$THEME_DIR/gtk-3.0/gtk.css"
[[ "$color" != '-dark' ]] && \
ln -sT "$SRC_DIR/gtk/$version/gtk-dark.css" "$THEME_DIR/gtk-3.0/gtk-dark.css"
else
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
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"
fi
done
mkdir -p ${THEME_DIR}/metacity-1
ln -s ${SRC_DIR}/metacity-1/assets ${THEME_DIR}/metacity-1
ln -sT ${SRC_DIR}/metacity-1/metacity-theme-2${ELSE_LIGHT}.xml ${THEME_DIR}/metacity-1/metacity-theme-2.xml
ln -sT ${SRC_DIR}/metacity-1/metacity-theme-3${ELSE_LIGHT}.xml ${THEME_DIR}/metacity-1/metacity-theme-3.xml
mkdir -p "$THEME_DIR/metacity-1"
ln -s "$SRC_DIR/metacity-1/assets" "$THEME_DIR/metacity-1"
ln -sT "$SRC_DIR/metacity-1/metacity-theme-2${ELSE_LIGHT:-}.xml" "$THEME_DIR/metacity-1/metacity-theme-2.xml"
ln -sT "$SRC_DIR/metacity-1/metacity-theme-3${ELSE_LIGHT:-}.xml" "$THEME_DIR/metacity-1/metacity-theme-3.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/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
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}
echo Installed to "$THEME_DIR"
}
case "${1}" in
case "${1:-}" in
"")
test '' ''
;;
test '-light' '-compact'
;;
uninstall)
rm -rf ${DEST_DIR}/${THEME_NAME}{,-compact,-dark,-dark-compact,-light,-light-compact}
# SC2115: Protect /.
rm -rf "${DEST_DIR:?}/$THEME_NAME"{,-compact,-dark,-dark-compact,-light,-light-compact}
;;
*)
echo "Invalid argument: ${1}"
echo "Invalid argument: ${1:-}"
echo "Valid arguments are: compact dark dark-compact light light-compact all uninstall"
;;
esac