WhiteSur-gtk-theme/lib-install.sh

701 lines
32 KiB
Bash
Raw Normal View History

2021-04-08 02:09:27 +02:00
# WARNING: Please make this shell not working-directory dependant, for example
# instead of using 'cd blabla', use 'cd "${REPO_DIR}/blabla"'
#
# WARNING: Don't use "cd" in this shell, use it in a subshell instead,
# for example ( cd blabla && do_blabla ) or $( cd .. && do_blabla )
#
# WARNING: Please don't use sudo directly here since it steals our EXIT trap
#
# WARNING: Please set REPO_DIR variable before using this lib
###############################################################################
# VARIABLES #
###############################################################################
source "${REPO_DIR}/lib-core.sh"
###############################################################################
# DEPENDENCIES #
###############################################################################
install_theme_deps() {
if ! has_command glib-compile-resources || ! has_command sassc || \
! has_command xmllint || [[ ! -r "/usr/share/gtk-engines/murrine.xml" ]]; then
2021-05-23 15:04:01 +02:00
echo; prompt -w "'glib2.0', 'sassc', 'xmllint', and 'libmurrine' are required for theme installation."
2021-04-08 02:09:27 +02:00
if has_command zypper; then
2021-04-10 09:09:46 +02:00
rootify zypper in -y sassc glib2-devel gtk2-engine-murrine libxml2-tools
2021-04-08 02:09:27 +02:00
elif has_command apt; then
2021-04-10 09:09:46 +02:00
rootify apt install -y sassc libglib2.0-dev-bin gtk2-engines-murrine libxml2-utils
2021-04-08 02:09:27 +02:00
elif has_command dnf; then
2021-04-10 09:09:46 +02:00
rootify dnf install -y sassc glib2-devel gtk-murrine-engine libxml2
2021-04-08 02:09:27 +02:00
elif has_command yum; then
2021-04-10 09:09:46 +02:00
rootify yum install -y sassc glib2-devel gtk-murrine-engine libxml2
2021-04-08 02:09:27 +02:00
elif has_command pacman; then
2021-04-10 09:09:46 +02:00
rootify pacman -S --noconfirm --needed sassc glib2 gtk-engine-murrine libxml2
2021-04-08 02:09:27 +02:00
else
prompt -w "WARNING: We're sorry, your distro isn't officially supported yet."
prompt -w "INSTRUCTION: Please make sure you have installed all of the required dependencies. We'll continue the installation in 15 seconds"
prompt -w "INSTRUCTION: Press 'ctrl'+'c' to cancel the installation if you haven't install them yet"
start_animation; sleep 15; stop_animation
fi
fi
}
2021-04-20 13:17:18 +02:00
install_gdm_deps() {
2021-05-23 15:04:01 +02:00
#TODO: @vince, do we also need "sassc" here?
if ! has_command glib-compile-resources || ! has_command xmllint || \
! has_command sassc; then
echo; prompt -w "'glib2.0', 'xmllint', and 'sassc' are required for theme installation."
2021-04-20 13:17:18 +02:00
if has_command zypper; then
2021-05-23 15:04:01 +02:00
rootify zypper in -y glib2-devel libxml2-tools sassc
2021-04-20 13:17:18 +02:00
elif has_command apt; then
2021-05-23 15:04:01 +02:00
rootify apt install -y libglib2.0-dev-bin libxml2-utils sassc
2021-04-20 13:17:18 +02:00
elif has_command dnf; then
2021-05-23 15:04:01 +02:00
rootify dnf install -y glib2-devel libxml2 sassc
2021-04-20 13:17:18 +02:00
elif has_command yum; then
2021-05-23 15:04:01 +02:00
rootify yum install -y glib2-devel libxml2 sassc
2021-04-20 13:17:18 +02:00
elif has_command pacman; then
2021-05-23 15:04:01 +02:00
rootify pacman -S --noconfirm --needed glib2 libxml2 sassc
2021-04-20 13:17:18 +02:00
else
2021-05-23 09:46:03 +02:00
prompt -w "WARNING: We're sorry, your distro isn't officially supported yet."
prompt -w "INSTRUCTION: Please make sure you have installed all of the required dependencies. We'll continue the installation in 15 seconds"
prompt -w "INSTRUCTION: Press 'ctrl'+'c' to cancel the installation if you haven't install them yet"
start_animation; sleep 15; stop_animation
2021-04-20 13:17:18 +02:00
fi
fi
}
2021-04-10 09:09:46 +02:00
install_beggy_deps() {
if ! has_command convert; then
2021-05-23 15:04:01 +02:00
echo; prompt -w "'imagemagick' are required for background editing."
2021-04-10 09:09:46 +02:00
if has_command zypper; then
rootify zypper in -y ImageMagick
elif has_command apt; then
2021-05-12 08:01:57 +02:00
rootify apt install -y imagemagick
2021-04-10 09:09:46 +02:00
elif has_command dnf; then
2021-05-12 08:01:57 +02:00
rootify dnf install -y ImageMagick
2021-04-10 09:09:46 +02:00
elif has_command yum; then
2021-05-12 08:01:57 +02:00
rootify yum install -y ImageMagick
2021-04-10 09:09:46 +02:00
elif has_command pacman; then
2021-05-12 08:01:57 +02:00
rootify pacman -S --noconfirm --needed imagemagick
2021-04-10 09:09:46 +02:00
else
2021-05-23 09:46:03 +02:00
prompt -w "WARNING: We're sorry, your distro isn't officially supported yet."
prompt -w "INSTRUCTION: Please make sure you have installed all of the required dependencies. We'll continue the installation in 15 seconds"
prompt -w "INSTRUCTION: Press 'ctrl'+'c' to cancel the installation if you haven't install them yet"
start_animation; sleep 15; stop_animation
2021-04-10 09:09:46 +02:00
fi
fi
}
install_dialog_deps() {
if ! has_command dialog; then
2021-04-10 09:09:46 +02:00
echo; prompt -w "'dialog' are required for this option."
if has_command zypper; then
rootify zypper in -y dialog
elif has_command apt; then
rootify apt install -y dialog
elif has_command dnf; then
rootify dnf install -y dialog
elif has_command yum; then
rootify yum install -y dialog
elif has_command pacman; then
rootify pacman -S --noconfirm --needed dialog
else
2021-05-23 09:46:03 +02:00
prompt -w "WARNING: We're sorry, your distro isn't officially supported yet."
prompt -w "INSTRUCTION: Please make sure you have installed all of the required dependencies. We'll continue the installation in 15 seconds"
prompt -w "INSTRUCTION: Press 'ctrl'+'c' to cancel the installation if you haven't install them yet"
start_animation; sleep 15; stop_animation
2021-04-10 09:09:46 +02:00
fi
fi
}
2021-04-08 02:09:27 +02:00
###############################################################################
# THEME MODULES #
###############################################################################
install_beggy() {
local CONVERT_OPT=""
2021-04-29 04:54:34 +02:00
[[ "${no_blur}" == "false" ]] && CONVERT_OPT+=" -scale 1280x -blur 0x50 "
2021-05-24 07:18:19 +02:00
[[ "${no_darken}" == "false" ]] && CONVERT_OPT+=" -fill black -colorize 45% "
2021-04-08 02:09:27 +02:00
case "${background}" in
blank)
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-blank.png" "${WHITESUR_TMP_DIR}/beggy.png" ;;
default)
2021-05-24 07:18:19 +02:00
if [[ "${no_blur}" == "false" && "${no_darken}" == "true" ]]; then
2021-05-23 09:46:03 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-blur.png" "${WHITESUR_TMP_DIR}/beggy.png"
2021-05-24 07:18:19 +02:00
elif [[ "${no_blur}" == "false" && "${no_darken}" == "false" ]]; then
2021-05-23 09:46:03 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-blur-darken.png" "${WHITESUR_TMP_DIR}/beggy.png"
2021-05-24 07:18:19 +02:00
elif [[ "${no_blur}" == "true" && "${no_darken}" == "true" ]]; then
2021-05-23 09:46:03 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-default.png" "${WHITESUR_TMP_DIR}/beggy.png"
2021-04-29 04:58:54 +02:00
else
2021-05-23 09:46:03 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-darken.png" "${WHITESUR_TMP_DIR}/beggy.png"
2021-04-29 04:58:54 +02:00
fi
2021-04-29 05:24:03 +02:00
;;
2021-04-08 02:09:27 +02:00
*)
2021-05-09 05:05:51 +02:00
if [[ "${no_blur}" == "false" || "${darken}" == "true" ]]; then
install_beggy_deps && convert "${background}" ${CONVERT_OPT} "${WHITESUR_TMP_DIR}/beggy.png"
else
cp -r "${background}" "${WHITESUR_TMP_DIR}/beggy.png"
fi
;;
2021-04-08 02:09:27 +02:00
esac
}
install_darky() {
local opacity="$(destify ${1})"
local theme="$(destify ${2})"
2021-05-14 10:19:14 +02:00
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-3.0/gtk-dark.scss" "${WHITESUR_TMP_DIR}/darky-3.css"
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-4.0/gtk-dark.scss" "${WHITESUR_TMP_DIR}/darky-4.css"
2021-04-08 02:09:27 +02:00
}
2021-04-19 13:35:20 +02:00
install_xfwmy() {
local color="$(destify ${1})"
2021-04-21 10:39:47 +02:00
local TARGET_DIR="${dest}/${name}${color}"
2021-04-19 13:35:20 +02:00
local HDPI_TARGET_DIR="${dest}/${name}${color}-hdpi"
local XHDPI_TARGET_DIR="${dest}/${name}${color}-xhdpi"
mkdir -p "${TARGET_DIR}/xfwm4"
cp -r "${THEME_SRC_DIR}/assets/xfwm4/assets${color}/"*".png" "${TARGET_DIR}/xfwm4"
cp -r "${THEME_SRC_DIR}/main/xfwm4/themerc${color}" "${TARGET_DIR}/xfwm4/themerc"
mkdir -p "${HDPI_TARGET_DIR}/xfwm4"
cp -r "${THEME_SRC_DIR}/assets/xfwm4/assets${color}-hdpi/"*".png" "${HDPI_TARGET_DIR}/xfwm4"
cp -r "${THEME_SRC_DIR}/main/xfwm4/themerc${color}" "${HDPI_TARGET_DIR}/xfwm4/themerc"
mkdir -p "${XHDPI_TARGET_DIR}/xfwm4"
cp -r "${THEME_SRC_DIR}/assets/xfwm4/assets${color}-xhdpi/"*".png" "${XHDPI_TARGET_DIR}/xfwm4"
cp -r "${THEME_SRC_DIR}/main/xfwm4/themerc${color}" "${XHDPI_TARGET_DIR}/xfwm4/themerc"
}
2021-04-08 02:09:27 +02:00
install_shelly() {
local color="$(destify ${1})"
local opacity="$(destify ${2})"
local alt="$(destify ${3})"
local theme="$(destify ${4})"
local icon="$(destify ${5})"
local TARGET_DIR=
if [[ -z "${6}" ]]; then
TARGET_DIR="${dest}/${name}${color}${opacity}${alt}${theme}/gnome-shell"
else TARGET_DIR="${6}"; fi
mkdir -p "${TARGET_DIR}"
mkdir -p "${TARGET_DIR}/assets"
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/icons" "${TARGET_DIR}"
cp -r "${THEME_SRC_DIR}/main/gnome-shell/pad-osd.css" "${TARGET_DIR}"
2021-04-08 16:59:05 +02:00
if [[ "${GNOME_VERSION}" == 'new' ]]; then
2021-05-12 08:01:57 +02:00
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gnome-shell/shell-40-0/gnome-shell${color}.scss" "${TARGET_DIR}/gnome-shell.css"
2021-04-08 16:59:05 +02:00
else
2021-05-12 08:01:57 +02:00
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gnome-shell/shell-3-28/gnome-shell${color}.scss" "${TARGET_DIR}/gnome-shell.css"
2021-04-08 16:59:05 +02:00
fi
2021-04-08 02:09:27 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/"*".svg" "${TARGET_DIR}/assets"
if [[ "${theme}" != '' ]]; then
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets${theme}/"*".svg" "${TARGET_DIR}/assets"
fi
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/assets${color}/"*".svg" "${TARGET_DIR}/assets"
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/activities/activities${icon}.svg" "${TARGET_DIR}/assets/activities.svg"
2021-05-09 05:05:51 +02:00
cp -r "${WHITESUR_TMP_DIR}/beggy.png" "${TARGET_DIR}/assets/background.png"
2021-04-08 02:09:27 +02:00
(
cd "${TARGET_DIR}"
mv -f "assets/no-events.svg" "no-events.svg"
mv -f "assets/process-working.svg" "process-working.svg"
mv -f "assets/no-notifications.svg" "no-notifications.svg"
)
if [[ "${alt}" == '-alt' || "${opacity}" == '-solid' ]] && [[ "${color}" == '-light' ]]; then
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/activities-black/activities${icon}.svg" "${TARGET_DIR}/assets/activities.svg"
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/activities/activities${icon}.svg" "${TARGET_DIR}/assets/activities-white.svg"
fi
}
install_theemy() {
local color="$(destify ${1})"
local opacity="$(destify ${2})"
local alt="$(destify ${3})"
local theme="$(destify ${4})"
local icon="$(destify ${5})"
local TARGET_DIR="${dest}/${name}${color}${opacity}${alt}${theme}"
2021-04-09 14:03:06 +02:00
local TMP_DIR_T="${WHITESUR_TMP_DIR}/gtk-3.0${color}${opacity}${alt}${theme}"
local TMP_DIR_F="${WHITESUR_TMP_DIR}/gtk-4.0${color}${opacity}${alt}${theme}"
2021-04-08 02:09:27 +02:00
mkdir -p "${TARGET_DIR}"
local desktop_entry="
[Desktop Entry]
Type=X-GNOME-Metatheme
Name=${name}${color}${opacity}${alt}${theme}
Comment=A MacOS BigSur like Gtk+ theme based on Elegant Design
Encoding=UTF-8
[X-GNOME-Metatheme]
GtkTheme=${name}${color}${opacity}${alt}${theme}
MetacityTheme=${name}${color}${opacity}${alt}${theme}
IconTheme=${name}${color}
CursorTheme=${name}${color}
ButtonLayout=close,minimize,maximize:menu"
echo "${desktop_entry}" > "${TARGET_DIR}/index.theme"
2021-04-09 14:03:06 +02:00
#--------------------GTK-3.0--------------------#
2021-04-08 02:09:27 +02:00
2021-04-09 14:03:06 +02:00
mkdir -p "${TMP_DIR_T}"
cp -r "${THEME_SRC_DIR}/assets/gtk/common-assets/assets" "${TMP_DIR_T}"
cp -r "${THEME_SRC_DIR}/assets/gtk/common-assets/sidebar-assets/"*".png" "${TMP_DIR_T}/assets"
cp -r "${THEME_SRC_DIR}/assets/gtk/windows-assets/titlebutton${alt}" "${TMP_DIR_T}/windows-assets"
2021-04-08 02:09:27 +02:00
if [[ "${theme}" != '' ]]; then
2021-04-09 14:03:06 +02:00
cp -r "${THEME_SRC_DIR}/assets/gtk/common-assets/assets${theme}/"*".png" "${TMP_DIR_T}/assets"
2021-04-08 02:09:27 +02:00
fi
2021-05-12 08:01:57 +02:00
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-3.0/gtk${color}.scss" "${TMP_DIR_T}/gtk.css"
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-3.0/gtk-dark.scss" "${TMP_DIR_T}/gtk-dark.css"
2021-04-08 02:09:27 +02:00
mkdir -p "${TARGET_DIR}/gtk-3.0"
2021-04-09 14:03:06 +02:00
cp -r "${THEME_SRC_DIR}/assets/gtk/thumbnails/thumbnail${color}${theme}.png" "${TARGET_DIR}/gtk-3.0/thumbnail.png"
2021-04-08 02:09:27 +02:00
echo '@import url("resource:///org/gnome/theme/gtk.css");' > "${TARGET_DIR}/gtk-3.0/gtk.css"
echo '@import url("resource:///org/gnome/theme/gtk-dark.css");' > "${TARGET_DIR}/gtk-3.0/gtk-dark.css"
2021-04-09 14:03:06 +02:00
glib-compile-resources --sourcedir="${TMP_DIR_T}" --target="${TARGET_DIR}/gtk-3.0/gtk.gresource" "${THEME_SRC_DIR}/main/gtk-3.0/gtk.gresource.xml"
#--------------------GTK-4.0--------------------#
mkdir -p "${TMP_DIR_F}"
cp -r "${TMP_DIR_T}/assets" "${TMP_DIR_F}"
cp -r "${TMP_DIR_T}/windows-assets" "${TMP_DIR_F}"
2021-05-12 08:01:57 +02:00
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-4.0/gtk${color}.scss" "${TMP_DIR_F}/gtk.css"
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-4.0/gtk-dark.scss" "${TMP_DIR_F}/gtk-dark.css"
2021-04-09 14:03:06 +02:00
mkdir -p "${TARGET_DIR}/gtk-4.0"
cp -r "${THEME_SRC_DIR}/assets/gtk/thumbnails/thumbnail${color}${theme}.png" "${TARGET_DIR}/gtk-4.0/thumbnail.png"
echo '@import url("resource:///org/gnome/theme/gtk.css");' > "${TARGET_DIR}/gtk-4.0/gtk.css"
echo '@import url("resource:///org/gnome/theme/gtk-dark.css");' > "${TARGET_DIR}/gtk-4.0/gtk-dark.css"
glib-compile-resources --sourcedir="${TMP_DIR_F}" --target="${TARGET_DIR}/gtk-4.0/gtk.gresource" "${THEME_SRC_DIR}/main/gtk-4.0/gtk.gresource.xml"
2021-04-08 02:09:27 +02:00
#----------------Cinnamon-----------------#
mkdir -p "${TARGET_DIR}/cinnamon"
2021-05-12 08:01:57 +02:00
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/cinnamon/cinnamon${color}.scss" "${TARGET_DIR}/cinnamon/cinnamon.css"
2021-04-08 02:09:27 +02:00
cp -r "${THEME_SRC_DIR}/assets/cinnamon/common-assets" "${TARGET_DIR}/cinnamon/assets"
if [[ ${theme} != '' ]]; then
cp -r "${THEME_SRC_DIR}/assets/cinnamon/common-assets${theme}/"*".svg" "${TARGET_DIR}/cinnamon/assets"
fi
cp -r "${THEME_SRC_DIR}/assets/cinnamon/assets${color}/"*".svg" "${TARGET_DIR}/cinnamon/assets"
cp -r "${THEME_SRC_DIR}/assets/cinnamon/thumbnails/thumbnail${color}${theme}.png" "${TARGET_DIR}/cinnamon/thumbnail.png"
#----------------Misc------------------#
mkdir -p "${TARGET_DIR}/gtk-2.0"
cp -r "${THEME_SRC_DIR}/main/gtk-2.0/gtkrc${color}${theme}" "${TARGET_DIR}/gtk-2.0/gtkrc"
cp -r "${THEME_SRC_DIR}/main/gtk-2.0/menubar-toolbar${color}.rc" "${TARGET_DIR}/gtk-2.0/menubar-toolbar.rc"
cp -r "${THEME_SRC_DIR}/main/gtk-2.0/common/"*".rc" "${TARGET_DIR}/gtk-2.0"
cp -r "${THEME_SRC_DIR}/assets/gtk-2.0/assets${color}" "${TARGET_DIR}/gtk-2.0/assets"
if [[ "${theme}" != '' ]]; then
cp -r "${THEME_SRC_DIR}/assets/gtk-2.0/assets${color}${theme}/"*".png" "${TARGET_DIR}/gtk-2.0/assets"
fi
mkdir -p "${TARGET_DIR}/metacity-1"
cp -r "${THEME_SRC_DIR}/main/metacity-1/metacity-theme${color}.xml" "${TARGET_DIR}/metacity-1/metacity-theme-1.xml"
cp -r "${THEME_SRC_DIR}/main/metacity-1/metacity-theme-3.xml" "${TARGET_DIR}/metacity-1"
cp -r "${THEME_SRC_DIR}/assets/metacity-1/assets/"*".png" "${TARGET_DIR}/metacity-1"
cp -r "${THEME_SRC_DIR}/assets/metacity-1/thumbnail${color}.png" "${TARGET_DIR}/metacity-1/thumbnail.png"
( cd "${TARGET_DIR}/metacity-1" && ln -s "metacity-theme-1.xml" "metacity-theme-2.xml" )
mkdir -p "${TARGET_DIR}/plank"
cp -r "${THEME_SRC_DIR}/other/plank/theme${color}/"*".theme" "${TARGET_DIR}/plank"
}
remove_packy() {
rm -rf "${dest}/${name}$(destify ${1})$(destify ${2})$(destify ${3})$(destify ${4})"
rm -rf "${dest}/${name}$(destify ${1})"
2021-04-13 05:07:53 +02:00
rm -rf "${dest}/${name}$(destify ${1})-hdpi"
rm -rf "${dest}/${name}$(destify ${1})-xhdpi"
# Backward compatibility
rm -rf "${dest}/${name}$(destify ${1})-mdpi"
2021-04-08 02:09:27 +02:00
}
###############################################################################
# THEMES #
###############################################################################
install_themes() {
2021-05-23 15:04:01 +02:00
# "install_theemy" and "install_shelly" require "gtk_base", so multithreading
# isn't possible
2021-05-23 09:46:03 +02:00
start_animation; install_beggy
2021-04-08 02:09:27 +02:00
for opacity in "${opacities[@]}"; do
for alt in "${alts[@]}"; do
for theme in "${themes[@]}"; do
2021-05-12 08:01:57 +02:00
install_xfwmy "${color}"
2021-04-08 02:09:27 +02:00
for color in "${colors[@]}"; do
2021-05-23 09:46:03 +02:00
gtk_base "${color}" "${opacity}" "${theme}" "${compact}"
install_theemy "${color}" "${opacity}" "${alt}" "${theme}" "${icon}"
install_shelly "${color}" "${opacity}" "${alt}" "${theme}" "${icon}"
2021-04-08 02:09:27 +02:00
done
done
done
done
stop_animation
}
remove_themes() {
process_ids=()
for color in "${COLOR_VARIANTS[@]}"; do
for opacity in "${OPACITY_VARIANTS[@]}"; do
for alt in "${ALT_VARIANTS[@]}"; do
for theme in "${THEME_VARIANTS[@]}"; do
remove_packy "${color}" "${opacity}" "${alt}" "${theme}" &
process_ids+=("${!}")
done
done
done
done
2021-04-21 10:39:47 +02:00
wait ${process_ids[*]} &> /dev/null
2021-04-08 02:09:27 +02:00
}
install_gdm_theme() {
start_animation
local TARGET=
# Let's go!
2021-05-23 09:46:03 +02:00
rm -rf "${WHITESUR_GS_DIR}"; install_beggy
gtk_base "${colors[0]}" "${opacities[0]}" "${themes[0]}"
2021-04-08 02:09:27 +02:00
if check_theme_file "${COMMON_CSS_FILE}"; then # CSS-based theme
2021-05-16 03:31:41 +02:00
install_shelly "${colors[0]}" "${opacities[0]}" "${alts[0]}" "${themes[0]}" "${icon}" "${WHITESUR_GS_DIR}"
2021-05-13 13:36:29 +02:00
sed $SED_OPT "s|assets|${WHITESUR_GS_DIR}/assets|" "${WHITESUR_GS_DIR}/gnome-shell.css"
2021-04-08 02:09:27 +02:00
if check_theme_file "${UBUNTU_CSS_FILE}"; then
TARGET="${UBUNTU_CSS_FILE}"
elif check_theme_file "${ZORIN_CSS_FILE}"; then
TARGET="${ZORIN_CSS_FILE}"
fi
backup_file "${COMMON_CSS_FILE}"; backup_file "${TARGET}"
ln -sf "${WHITESUR_GS_DIR}/gnome-shell.css" "${COMMON_CSS_FILE}"
ln -sf "${WHITESUR_GS_DIR}/gnome-shell.css" "${TARGET}"
# Fix previously installed WhiteSur
restore_file "${ETC_CSS_FILE}"
else # GR-based theme
2021-05-16 03:31:41 +02:00
install_shelly "${colors[0]}" "${opacities[0]}" "${alts[0]}" "${themes[0]}" "${icon}" "${WHITESUR_TMP_DIR}/shelly"
2021-05-13 13:36:29 +02:00
sed $SED_OPT "s|assets|resource:///org/gnome/shell/theme/assets|" "${WHITESUR_TMP_DIR}/shelly/gnome-shell.css"
2021-04-08 02:09:27 +02:00
2021-05-23 09:46:03 +02:00
if check_theme_file "$POP_OS_GR_FILE"; then
2021-04-08 02:09:27 +02:00
TARGET="${POP_OS_GR_FILE}"
elif check_theme_file "$YARU_GR_FILE"; then
TARGET="${YARU_GR_FILE}"
elif check_theme_file "$MISC_GR_FILE"; then
TARGET="${MISC_GR_FILE}"
fi
backup_file "${TARGET}"
glib-compile-resources --sourcedir="${WHITESUR_TMP_DIR}/shelly" --target="${TARGET}" "${GS_GR_XML_FILE}"
# Fix previously installed WhiteSur
restore_file "${ETC_GR_FILE}"
fi
stop_animation
}
revert_gdm_theme() {
rm -rf "${WHITESUR_GS_DIR}"
restore_file "${COMMON_CSS_FILE}"; restore_file "${UBUNTU_CSS_FILE}"
restore_file "${ZORIN_CSS_FILE}"; restore_file "${ETC_CSS_FILE}"
restore_file "${POP_OS_GR_FILE}"; restore_file "${YARU_GR_FILE}"
restore_file "${MISC_GR_FILE}"; restore_file "${ETC_GR_FILE}"
}
###############################################################################
# FIREFOX #
###############################################################################
install_firefox_theme() {
#TODO: add support for Snap
if has_flatpak_app org.mozilla.firefox; then
local TARGET_DIR="${FIREFOX_FLATPAK_THEME_DIR}"
else
local TARGET_DIR="${FIREFOX_THEME_DIR}"
fi
2021-04-08 02:09:27 +02:00
remove_firefox_theme
userify mkdir -p "${TARGET_DIR}"
userify cp -rf "${FIREFOX_SRC_DIR}"/* "${TARGET_DIR}"
2021-04-08 02:09:27 +02:00
config_firefox
}
config_firefox() {
if has_flatpak_app org.mozilla.firefox; then
local TARGET_DIR="${FIREFOX_FLATPAK_THEME_DIR}"
local FIREFOX_DIR="${FIREFOX_FLATPAK_DIR_HOME}"
else
local TARGET_DIR="${FIREFOX_THEME_DIR}"
local FIREFOX_DIR="${FIREFOX_DIR_HOME}"
fi
2021-04-08 02:09:27 +02:00
killall "firefox" "firefox-bin" &> /dev/null || true
for d in "${FIREFOX_DIR}/"*"default"*; do
2021-05-27 18:23:57 +02:00
if [[ -f "${d}/prefs.js" ]]; then
rm -rf "${d}/chrome"
userify ln -sf "${TARGET_DIR}" "${d}/chrome"
2021-05-27 18:23:57 +02:00
userify_file "${d}/prefs.js"
echo "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", true);" >> "${d}/prefs.js"
echo "user_pref(\"browser.tabs.drawInTitlebar\", true);" >> "${d}/prefs.js"
echo "user_pref(\"browser.uidensity\", 0);" >> "${d}/prefs.js"
echo "user_pref(\"layers.acceleration.force-enabled\", true);" >> "${d}/prefs.js"
echo "user_pref(\"mozilla.widget.use-argb-visuals\", true);" >> "${d}/prefs.js"
fi
2021-04-08 02:09:27 +02:00
done
}
edit_firefox_theme_prefs() {
if has_flatpak_app org.mozilla.firefox; then
local TARGET_DIR="${FIREFOX_FLATPAK_THEME_DIR}"
else
local TARGET_DIR="${FIREFOX_THEME_DIR}"
fi
[[ ! -d "${TARGET_DIR}" ]] && install_firefox_theme ; config_firefox
userify ${EDITOR:-nano} "${TARGET_DIR}/userChrome.css"
userify ${EDITOR:-nano} "${TARGET_DIR}/customChrome.css"
2021-04-08 02:09:27 +02:00
}
remove_firefox_theme() {
# We need to remove this linked folder to avoid unwanted file overriding in
# the next installation
2021-04-08 02:09:27 +02:00
rm -rf "${FIREFOX_DIR_HOME}/"*"default"*"/chrome"
rm -rf "${FIREFOX_THEME_DIR}" # Sorry, we need to remove ".../WhiteSur" to keep anything clean
# This too
rm -rf "${FIREFOX_FLATPAK_DIR_HOME}/"*"default"*"/chrome"
rm -rf "${FIREFOX_FLATPAK_THEME_DIR}"
2021-04-08 02:09:27 +02:00
}
###############################################################################
# DASH TO DOCK #
###############################################################################
install_dash_to_dock_theme() {
2021-05-23 09:46:03 +02:00
gtk_base "${colors[0]}" "${opacities[0]}" "${themes[0]}"
2021-04-08 02:09:27 +02:00
if [[ -d "${DASH_TO_DOCK_DIR_HOME}" ]]; then
backup_file "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css" "userify"
2021-05-27 14:58:12 +02:00
userify_file "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
2021-04-08 02:09:27 +02:00
userify sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet$(destify ${colors[0]}).scss" "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
elif [[ -d "${DASH_TO_DOCK_DIR_ROOT}" ]]; then
backup_file "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css" "rootify"
rootify sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet$(destify ${colors[0]}).scss" "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css"
fi
userify dbus-launch dconf write /org/gnome/shell/extensions/dash-to-dock/apply-custom-theme true
2021-04-08 02:09:27 +02:00
}
revert_dash_to_dock_theme() {
if [[ -d "${DASH_TO_DOCK_DIR_HOME}" ]]; then
restore_file "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css" "userify"
elif [[ -d "${DASH_TO_DOCK_DIR_ROOT}" ]]; then
restore_file "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css" "rootify"
fi
}
###############################################################################
# FLATPAK & SNAP #
###############################################################################
connect_flatpak() {
rootify flatpak override --filesystem=~/.themes
}
disconnect_flatpak() {
rootify flatpak override --nofilesystem=~/.themes
}
connect_snap() {
rootify snap install whitesur-gtk-theme
for i in $(snap connections | grep gtk-common-themes | awk '{print $2}' | cut -f1 -d: | sort -u); do
rootify snap connect "${i}:gtk-3-themes" "whitesur-gtk-theme:gtk-3-themes"
rootify snap connect "${i}:icon-themes" "whitesur-gtk-theme:icon-themes"
done
}
disconnect_snap() {
for i in $(snap connections | grep gtk-common-themes | awk '{print $2}' | cut -f1 -d: | sort -u); do
rootify snap disconnect "${i}:gtk-3-themes" "whitesur-gtk-theme:gtk-3-themes"
rootify snap disconnect "${i}:icon-themes" "whitesur-gtk-theme:icon-themes"
done
}
2021-05-12 08:01:57 +02:00
#########################################################################
# GTK BASE #
#########################################################################
gtk_base() {
2021-05-13 13:44:00 +02:00
cp -rf "${THEME_SRC_DIR}/sass/_gtk-base"{".scss","-temp.scss"}
2021-05-12 08:01:57 +02:00
# Theme base options
2021-05-15 02:14:04 +02:00
sed $SED_OPT "/\$laptop/s/false/${compact}/" "${THEME_SRC_DIR}/sass/_gtk-base-temp.scss"
2021-05-12 08:01:57 +02:00
if [[ "${opacity}" == 'solid' ]]; then
2021-05-15 02:14:04 +02:00
sed $SED_OPT "/\$trans/s/true/false/" "${THEME_SRC_DIR}/sass/_gtk-base-temp.scss"
2021-05-12 08:01:57 +02:00
fi
if [[ "${color}" == 'light' && ${opacity} == 'solid' ]]; then
2021-05-15 02:14:04 +02:00
sed $SED_OPT "/\$black/s/false/true/" "${THEME_SRC_DIR}/sass/_gtk-base-temp.scss"
2021-05-12 08:01:57 +02:00
fi
if [[ "${theme}" != '' ]]; then
2021-05-15 02:14:04 +02:00
sed $SED_OPT "/\$theme/s/default/${theme}/" "${THEME_SRC_DIR}/sass/_gtk-base-temp.scss"
2021-05-12 08:01:57 +02:00
fi
}
2021-04-08 02:09:27 +02:00
###############################################################################
# CUSTOMIZATIONS #
###############################################################################
customize_theme() {
cp -rf "${THEME_SRC_DIR}/sass/_theme-options"{".scss","-temp.scss"}
# Change gnome-shell panel transparency
if [[ "${panel_opacity}" != 'default' ]]; then
2021-05-15 02:14:04 +02:00
prompt -s "Changing panel transparency ..."
sed $SED_OPT "/\$panel_opacity/s/0.15/0.${panel_opacity}/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
2021-04-08 02:09:27 +02:00
fi
2021-04-21 12:40:03 +02:00
# Change gnome-shell show apps button style
if [[ "${showapps_normal}" == 'true' ]]; then
2021-05-15 02:14:04 +02:00
prompt -s "Changing gnome-shell show apps button style ..."
sed $SED_OPT "/\$showapps_button/s/bigsur/normal/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
2021-04-21 12:40:03 +02:00
fi
2021-04-08 02:09:27 +02:00
# Change Nautilus sidarbar size
if [[ "${sidebar_size}" != 'default' ]]; then
2021-05-15 02:14:04 +02:00
prompt -s "Changing Nautilus sidebar size ..."
sed $SED_OPT "/\$sidebar_size/s/200px/${sidebar_size}px/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
2021-04-08 02:09:27 +02:00
fi
# Change Nautilus style
2021-04-10 17:18:34 +02:00
if [[ "${nautilus_style}" != 'stable' ]]; then
2021-05-15 02:14:04 +02:00
prompt -s "Changing Nautilus style ..."
sed $SED_OPT "/\$nautilus_style/s/stable/${nautilus_style}/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
2021-04-08 02:09:27 +02:00
fi
2021-04-09 17:06:04 +02:00
2021-05-09 08:25:44 +02:00
# Change Nautilus titlebutton placement style
if [[ "${right_placement}" == 'true' ]]; then
2021-05-15 02:14:04 +02:00
prompt -s "Changing Nautilus titlebutton placement style ..."
sed $SED_OPT "/\$placement/s/left/right/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
2021-05-09 08:25:44 +02:00
fi
2021-04-09 17:06:04 +02:00
# Change maximized window radius
if [[ "${max_round}" == 'true' ]]; then
2021-05-15 02:14:04 +02:00
prompt -s "Changing maximized window style ..."
sed $SED_OPT "/\$max_window_style/s/square/round/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
if [[ "${compact}" == 'false' ]]; then
prompt -s "Changing Definition mode to HD (Bigger font, Bigger size) ..."
2021-05-23 09:46:03 +02:00
#FIXME: @vince is it not implemented yet?
2021-04-09 17:06:04 +02:00
fi
2021-04-08 02:09:27 +02:00
}
#-----------------------------------DIALOGS------------------------------------#
# The default values here should get manually set and updated. Some of default
# values are taken from _variables.scss
show_panel_opacity_dialog() {
if [[ -x /usr/bin/dialog ]]; then
tui=$(dialog --backtitle "${THEME_NAME} gtk theme installer" \
--radiolist "Choose your panel background opacity
(Default is 0.15. The less value, the more transparency!):" 20 50 10 \
0 "${PANEL_OPACITY_VARIANTS[0]}" on \
1 "0.${PANEL_OPACITY_VARIANTS[1]}" off \
2 "0.${PANEL_OPACITY_VARIANTS[2]}" off \
3 "0.${PANEL_OPACITY_VARIANTS[3]}" off \
4 "0.${PANEL_OPACITY_VARIANTS[4]}" off --output-fd 1 )
case "$tui" in
0) panel_opacity="${PANEL_OPACITY_VARIANTS[0]}" ;;
1) panel_opacity="${PANEL_OPACITY_VARIANTS[1]}" ;;
2) panel_opacity="${PANEL_OPACITY_VARIANTS[2]}" ;;
3) panel_opacity="${PANEL_OPACITY_VARIANTS[3]}" ;;
4) panel_opacity="${PANEL_OPACITY_VARIANTS[4]}" ;;
2021-05-27 14:58:12 +02:00
*) operation_aborted ;;
2021-04-08 02:09:27 +02:00
esac
fi
clear
}
show_sidebar_size_dialog() {
if [[ -x /usr/bin/dialog ]]; then
tui=$(dialog --backtitle "${THEME_NAME} gtk theme installer" \
--radiolist "Choose your Nautilus sidebar size (default is 200px width):" 15 40 5 \
0 "${SIDEBAR_SIZE_VARIANTS[0]}" on \
1 "${SIDEBAR_SIZE_VARIANTS[1]}px" off \
2 "${SIDEBAR_SIZE_VARIANTS[2]}px" off \
3 "${SIDEBAR_SIZE_VARIANTS[3]}px" off \
4 "${SIDEBAR_SIZE_VARIANTS[4]}px" off --output-fd 1 )
case "$tui" in
0) sidebar_size="${SIDEBAR_SIZE_VARIANTS[0]}" ;;
1) sidebar_size="${SIDEBAR_SIZE_VARIANTS[1]}" ;;
2) sidebar_size="${SIDEBAR_SIZE_VARIANTS[2]}" ;;
3) sidebar_size="${SIDEBAR_SIZE_VARIANTS[3]}" ;;
4) sidebar_size="${SIDEBAR_SIZE_VARIANTS[4]}" ;;
2021-05-27 14:58:12 +02:00
*) operation_aborted ;;
2021-04-08 02:09:27 +02:00
esac
fi
clear
}
show_nautilus_style_dialog() {
if [[ -x /usr/bin/dialog ]]; then
tui=$(dialog --backtitle "${THEME_NAME} gtk theme installer" \
--radiolist "Choose your Nautilus style (default is BigSur-like style):" 15 40 5 \
0 "${NAUTILUS_STYLE_VARIANTS[0]}" on \
2021-04-08 06:12:34 +02:00
1 "${NAUTILUS_STYLE_VARIANTS[1]}" off \
1 "${NAUTILUS_STYLE_VARIANTS[2]}" off \
2 "${NAUTILUS_STYLE_VARIANTS[3]}" off --output-fd 1 )
2021-04-08 02:09:27 +02:00
case "$tui" in
0) nautilus_style="${NAUTILUS_STYLE_VARIANTS[0]}" ;;
1) nautilus_style="${NAUTILUS_STYLE_VARIANTS[1]}" ;;
2) nautilus_style="${NAUTILUS_STYLE_VARIANTS[2]}" ;;
2021-04-08 06:12:34 +02:00
3) nautilus_style="${NAUTILUS_STYLE_VARIANTS[3]}" ;;
2021-05-27 14:58:12 +02:00
*) operation_aborted ;;
2021-04-08 02:09:27 +02:00
esac
fi
clear
}
show_needed_dialogs() {
2021-05-27 14:58:12 +02:00
if [[ "${need_dialog[@]}" =~ "true" ]]; then install_dialog_deps; fi
if [[ "${need_dialog["-p"]}" == "true" ]]; then show_panel_opacity_dialog; fi
if [[ "${need_dialog["-s"]}" == "true" ]]; then show_sidebar_size_dialog; fi
if [[ "${need_dialog["-N"]}" == "true" ]]; then show_nautilus_style_dialog; fi
2021-04-08 02:09:27 +02:00
}