WhiteSur-gtk-theme/shell/lib-install.sh

1011 lines
44 KiB
Bash
Raw Permalink Normal View History

2021-04-08 02:09:27 +02:00
# WARNING: Please make this shell not working-directory dependant, for example
2021-06-03 01:43:49 +02:00
# instead of using 'ls blabla', use 'ls "${REPO_DIR}/blabla"'
2021-04-08 02:09:27 +02:00
#
# WARNING: Don't use "cd" in this shell, use it in a subshell instead,
# for example ( cd blabla && do_blabla ) or $( cd .. && do_blabla )
###############################################################################
# VARIABLES #
###############################################################################
2022-12-02 16:48:50 +01:00
source "${REPO_DIR}/shell/lib-core.sh"
source "${REPO_DIR}/shell/lib-flatpak.sh"
2021-06-02 18:04:59 +02:00
WHITESUR_SOURCE+=("lib-install.sh")
2021-04-08 02:09:27 +02:00
###############################################################################
# DEPENDENCIES #
###############################################################################
2021-06-09 03:14:30 +02:00
# Be careful of some distro mechanism, some of them use rolling-release
# based installation instead of point-release, e.g., Arch Linux
# Rolling-release based distro doesn't have a seprate repo for each different
# build. This can cause a system call error since an app require the compatible
# version of dependencies. In other words, if you install an new app (which you
# definitely reinstall/upgrade the dependency for that app), but your other
# dependencies are old/expired, you'll end up with broken system.
# That's why we need a full system upgrade there
#---------------------SWUPD--------------------#
# 'swupd' bundles just don't make any sense. It takes about 30GB of space only
# for installing a util, e.g. 'sassc' (from 'desktop-dev' bundle, or
# 'os-utils-gui-dev' bundle, or any other 'sassc' provider bundle)
# Manual package installation is needed for that, but please don't use 'dnf'.
# The known worst impact of using 'dnf' is you install 'sassc' and then you
# remove it, and you run 'sudo dnf upgrade', and boom! Your 'sudo' and other
# system utilities have gone!
2021-06-09 03:14:30 +02:00
2021-06-11 04:17:28 +02:00
#----------------------APT---------------------#
# Some apt version doesn't update the repo list before it install some app.
# It may cause "unable to fetch..." when you're trying to install them
2021-06-14 03:02:52 +02:00
#--------------------PACMAN--------------------#
# 'Syu' (with a single y) may causes "could not open ... decompression failed"
# and "target not found <package>". We got to force 'pacman' to update the repos
2021-06-11 13:59:07 +02:00
#--------------------OTHERS--------------------#
2021-06-11 10:04:34 +02:00
# Sometimes, some Ubuntu distro doesn't enable automatic time. This can cause
2021-06-11 13:59:07 +02:00
# 'Release file for ... is not valid yet'. This may also happen on other distros
2021-06-11 10:04:34 +02:00
2021-06-11 13:59:07 +02:00
#============================================#
#-------------------Prepare------------------#
2021-06-08 16:03:41 +02:00
installation_sorry() {
prompt -w "WARNING: We're sorry, your distro isn't officially supported yet."
prompt -i "INSTRUCTION: Please make sure you have installed all of the required dependencies. We'll continue the installation in 15 seconds"
prompt -i "INSTRUCTION: Press 'ctrl'+'c' to cancel the installation if you haven't install them yet"
start_animation; sleep 15; stop_animation
}
2021-06-11 13:59:07 +02:00
prepare_deps() {
2021-06-12 09:01:28 +02:00
local remote_time=""
local local_time=""
prompt -i "DEPS: Checking your internet connection..."
2021-06-14 03:02:52 +02:00
local_time="$(date -u "+%s")"
if ! remote_time="$(get_utc_epoch_time)"; then
2021-06-12 09:01:28 +02:00
prompt -e "DEPS ERROR: You have an internet connection issue\n"; exit 1
fi
2021-06-14 03:02:52 +02:00
# 5 minutes is the maximum reasonable time delay, so we choose '4' here just
# in case
if (( local_time < remote_time-(4*60) )); then
2021-06-12 09:01:28 +02:00
prompt -w "DEPS: Your system clock is wrong"
prompt -i "DEPS: Updating your system clock..."
2021-06-14 03:02:52 +02:00
# Add "+ 25" here to accomodate potential time delay by sudo prompt
sudo date -s "@$((remote_time + 25))"; sudo hwclock --systohc
2021-06-11 13:59:07 +02:00
fi
}
2021-06-08 04:53:53 +02:00
prepare_swupd() {
[[ "${swupd_prepared}" == "true" ]] && return 0
2021-06-09 03:14:30 +02:00
local remove=""
local ver=""
local conf=""
local dist=""
2021-06-08 04:53:53 +02:00
2021-06-09 03:14:30 +02:00
if has_command dnf; then
2021-06-12 05:07:19 +02:00
prompt -w "CLEAR LINUX: You have 'dnf' installed in your system. It may break your system especially when you remove a package"
2021-06-11 07:11:02 +02:00
confirm remove "CLEAR LINUX: You wanna remove it?"; echo
2021-06-09 03:14:30 +02:00
fi
if ! sudo swupd update -y; then
2021-06-09 11:48:52 +02:00
ver="$(curl -s -o - "${swupd_ver_url}")"
2021-06-09 03:14:30 +02:00
dist="NAME=\"Clear Linux OS\"\nVERSION=1\nID=clear-linux-os\nID_LIKE=clear-linux-os\n"
dist+="VERSION_ID=${ver}\nANSI_COLOR=\"1;35\"\nSUPPORT_URL=\"https://clearlinux.org\"\nBUILD_ID=${ver}"
2021-06-08 04:53:53 +02:00
prompt -w "\n CLEAR LINUX: Your 'swupd' is broken"
2021-06-09 18:53:49 +02:00
prompt -i "CLEAR LINUX: Patching 'swupd' distro version detection and try again...\n"
sudo rm -rf "/etc/os-release"; echo -e "${dist}" | sudo tee "/usr/lib/os-release" > /dev/null
sudo ln -s "/usr/lib/os-release" "/etc/os-release"
2021-06-09 03:14:30 +02:00
sudo swupd update -y
2021-06-09 03:14:30 +02:00
fi
if ! has_command bsdtar; then sudo swupd bundle-add libarchive; fi
if [[ "${remove}" == "y" ]]; then sudo swupd bundle-remove -y dnf; fi
swupd_prepared="true"
2021-06-09 03:14:30 +02:00
}
install_swupd_packages() {
if [[ ! "${swupd_packages}" ]]; then
2021-06-09 11:48:52 +02:00
swupd_packages="$(curl -s -o - "${swupd_url}" | awk -F '"' '/-bin-|-lib-/{print $2}')"
2021-06-09 03:14:30 +02:00
fi
for key in "${@}"; do
for pkg in $(echo "${swupd_packages}" | grep -F "${key}"); do
curl -s -o - "${swupd_url}/${pkg}" | sudo bsdtar -xf - -C "/"
2021-06-09 03:14:30 +02:00
done
done
2021-06-08 04:53:53 +02:00
}
2021-06-12 05:07:19 +02:00
prepare_install_apt_packages() {
2021-06-12 05:37:11 +02:00
local status="0"
2021-06-11 15:48:43 +02:00
2023-01-05 02:04:04 +01:00
# sudo apt update -y
sudo apt install -y "${@}" || status="${?}"
2021-06-12 05:25:56 +02:00
if [[ "${status}" == "100" ]]; then
2021-06-12 05:07:19 +02:00
prompt -w "\n APT: Your repo lists might be broken"
2021-06-11 15:48:43 +02:00
prompt -i "APT: Full-cleaning your repo lists and try again...\n"
2021-06-12 05:07:19 +02:00
sudo apt clean -y; sudo rm -rf /var/lib/apt/lists
sudo apt update -y; sudo apt install -y "${@}"
2021-06-11 15:48:43 +02:00
fi
}
2021-06-08 04:53:53 +02:00
prepare_xbps() {
[[ "${xbps_prepared}" == "true" ]] && return 0
2021-06-11 02:16:45 +02:00
# 'xbps-install' requires 'xbps' to be always up-to-date
sudo xbps-install -Syu xbps
2021-06-11 07:11:02 +02:00
# System upgrading can't remove the old kernel files by it self. It eats the
# boot partition and may cause kernel panic when there is no enough space
sudo vkpurge rm all; sudo xbps-install -Syu
xbps_prepared="true"
2021-06-08 04:53:53 +02:00
}
2021-06-11 13:59:07 +02:00
#-----------------Deps-----------------#
2021-04-08 02:09:27 +02:00
install_theme_deps() {
2022-11-12 04:22:06 +01:00
if ! has_command sassc; then
prompt -w "DEPS: 'sassc' are required for theme installation."
2021-06-11 13:59:07 +02:00
prepare_deps
2021-04-08 02:09:27 +02:00
if has_command zypper; then
2022-11-12 04:22:06 +01:00
sudo zypper in -y sassc
2021-06-08 01:08:06 +02:00
elif has_command swupd; then
2022-11-12 04:22:06 +01:00
prepare_swupd && install_swupd_packages sassc libsass
2021-04-08 02:09:27 +02:00
elif has_command apt; then
2022-11-12 04:22:06 +01:00
prepare_install_apt_packages sassc
2021-04-08 02:09:27 +02:00
elif has_command dnf; then
2022-11-12 04:22:06 +01:00
sudo dnf install -y sassc
2021-04-08 02:09:27 +02:00
elif has_command yum; then
2022-11-12 04:22:06 +01:00
sudo yum install -y sassc
2021-04-08 02:09:27 +02:00
elif has_command pacman; then
2022-11-12 04:22:06 +01:00
sudo pacman -Syyu --noconfirm --needed sassc
2021-06-07 03:32:52 +02:00
elif has_command xbps-install; then
2022-11-12 04:22:06 +01:00
prepare_xbps && sudo xbps-install -Sy sassc
2021-06-25 08:41:42 +02:00
elif has_command eopkg; then
2022-11-12 04:22:06 +01:00
sudo eopkg -y upgrade; sudo eopkg -y install sassc
else
installation_sorry
fi
fi
if ! has_command glib-compile-resources; then
prompt -w "DEPS: 'glib2.0' are required for theme installation."
prepare_deps
if has_command zypper; then
sudo zypper in -y glib2-devel
elif has_command swupd; then
prepare_swupd && sudo swupd bundle-add libglib
elif has_command apt; then
prepare_install_apt_packages libglib2.0-dev-bin
elif has_command dnf; then
sudo dnf install -y glib2-devel
elif has_command yum; then
sudo yum install -y glib2-devel
elif has_command pacman; then
sudo pacman -Syyu --noconfirm --needed glib2
elif has_command xbps-install; then
prepare_xbps && sudo xbps-install -Sy glib-devel
elif has_command eopkg; then
sudo eopkg -y upgrade; sudo eopkg -y install glib2
else
installation_sorry
fi
fi
if ! has_command xmllint; then
prompt -w "DEPS: 'xmllint' are required for theme installation."
prepare_deps
if has_command zypper; then
sudo zypper in -y libxml2-tools
elif has_command swupd; then
prepare_swupd && sudo swupd bundle-add libxml2
elif has_command apt; then
prepare_install_apt_packages sassc libxml2-utils
elif has_command dnf; then
sudo dnf install -y libxml2
elif has_command yum; then
sudo yum install -y libxml2
elif has_command pacman; then
sudo pacman -Syyu --noconfirm --needed libxml2
elif has_command eopkg; then
sudo eopkg -y upgrade; sudo eopkg -y install libxml2
2021-04-08 02:09:27 +02:00
else
2021-06-08 16:03:41 +02:00
installation_sorry
2021-04-08 02:09:27 +02:00
fi
fi
}
2021-04-10 09:09:46 +02:00
install_beggy_deps() {
if ! has_command convert; then
2021-06-12 09:01:28 +02:00
prompt -w "DEPS: 'imagemagick' is required for background editing."
2021-06-17 05:37:58 +02:00
prepare_deps; stop_animation
2021-04-10 09:09:46 +02:00
if has_command zypper; then
sudo zypper in -y ImageMagick
2021-06-08 01:08:06 +02:00
elif has_command swupd; then
prepare_swupd && sudo swupd bundle-add ImageMagick
2021-04-10 09:09:46 +02:00
elif has_command apt; then
2021-06-12 05:07:19 +02:00
prepare_install_apt_packages imagemagick
2021-04-10 09:09:46 +02:00
elif has_command dnf; then
sudo dnf install -y ImageMagick
2021-04-10 09:09:46 +02:00
elif has_command yum; then
sudo yum install -y ImageMagick
2021-04-10 09:09:46 +02:00
elif has_command pacman; then
2021-06-14 03:02:52 +02:00
sudo pacman -Syyu --noconfirm --needed imagemagick
2021-06-07 03:32:52 +02:00
elif has_command xbps-install; then
prepare_xbps && sudo xbps-install -Sy ImageMagick
2021-06-25 08:41:42 +02:00
elif has_command eopkg; then
2021-06-25 10:16:50 +02:00
sudo eopkg -y upgrade; sudo eopkg -y install imagemagick
2021-04-10 09:09:46 +02:00
else
2021-06-08 16:03:41 +02:00
installation_sorry
2021-04-10 09:09:46 +02:00
fi
fi
}
install_dialog_deps() {
2021-06-15 15:15:34 +02:00
[[ "${silent_mode}" == "true" ]] && return 0
if ! has_command dialog; then
2021-06-12 09:01:28 +02:00
prompt -w "DEPS: 'dialog' is required for this option."
2021-06-11 13:59:07 +02:00
prepare_deps
2021-04-10 09:09:46 +02:00
if has_command zypper; then
sudo zypper in -y dialog
2021-06-08 01:08:06 +02:00
elif has_command swupd; then
2021-06-09 03:14:30 +02:00
prepare_swupd && install_swupd_packages dialog
2021-04-10 09:09:46 +02:00
elif has_command apt; then
2021-06-12 05:07:19 +02:00
prepare_install_apt_packages dialog
2021-04-10 09:09:46 +02:00
elif has_command dnf; then
sudo dnf install -y dialog
2021-04-10 09:09:46 +02:00
elif has_command yum; then
sudo yum install -y dialog
2021-04-10 09:09:46 +02:00
elif has_command pacman; then
2021-06-14 03:02:52 +02:00
sudo pacman -Syyu --noconfirm --needed dialog
2021-06-07 03:32:52 +02:00
elif has_command xbps-install; then
prepare_xbps && sudo xbps-install -Sy dialog
2021-06-25 08:41:42 +02:00
elif has_command eopkg; then
2021-06-25 10:16:50 +02:00
sudo eopkg -y upgrade; sudo eopkg -y install dialog
2021-04-10 09:09:46 +02:00
else
2021-06-08 16:03:41 +02:00
installation_sorry
2021-04-10 09:09:46 +02:00
fi
fi
}
2021-08-27 16:02:58 +02:00
install_flatpak_deps() {
if ! has_command ostree || ! has_command appstream-compose; then
prompt -w "DEPS: 'ostree' and 'appstream-util' is required for flatpak installing."
prepare_deps; stop_animation
if has_command zypper; then
2021-08-30 03:52:06 +02:00
sudo zypper in -y libostree appstream-glib
2021-08-27 16:02:58 +02:00
elif has_command swupd; then
2021-08-30 03:52:06 +02:00
prepare_swupd && sudo swupd ostree libappstream-glib
2021-08-27 16:02:58 +02:00
elif has_command apt; then
2021-08-30 03:52:06 +02:00
prepare_install_apt_packages ostree appstream-util
2021-08-27 16:02:58 +02:00
elif has_command dnf; then
2021-08-30 03:52:06 +02:00
sudo dnf install -y ostree libappstream-glib
2021-08-27 16:02:58 +02:00
elif has_command yum; then
2021-08-30 03:52:06 +02:00
sudo yum install -y ostree libappstream-glib
2021-08-27 16:02:58 +02:00
elif has_command pacman; then
2021-08-30 03:52:06 +02:00
sudo pacman -Syyu --noconfirm --needed ostree appstream-glib
2021-08-27 16:02:58 +02:00
elif has_command xbps-install; then
2021-08-30 03:52:06 +02:00
prepare_xbps && sudo xbps-install -Sy ostree appstream-glib
2021-08-27 16:02:58 +02:00
elif has_command eopkg; then
2021-08-30 03:52:06 +02:00
sudo eopkg -y upgrade; sudo eopkg -y ostree appstream-glib
2021-08-27 16:02:58 +02:00
else
installation_sorry
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)
2023-04-01 07:05:28 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/backgrounds/background-blank.png" "${WHITESUR_TMP_DIR}/beggy.png" ;;
2021-04-08 02:09:27 +02:00
default)
2021-05-24 07:18:19 +02:00
if [[ "${no_blur}" == "false" && "${no_darken}" == "true" ]]; then
2023-04-01 07:05:28 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/backgrounds/background-blur.png" "${WHITESUR_TMP_DIR}/beggy.png"
2021-05-24 07:18:19 +02:00
elif [[ "${no_blur}" == "false" && "${no_darken}" == "false" ]]; then
2023-04-01 07:05:28 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/backgrounds/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
2023-04-01 07:05:28 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/backgrounds/background-default.png" "${WHITESUR_TMP_DIR}/beggy.png"
2021-04-29 04:58:54 +02:00
else
2023-04-01 07:05:28 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/backgrounds/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
2021-06-17 05:37:58 +02:00
install_beggy_deps
2021-06-08 12:19:57 +02:00
convert "${background}" ${CONVERT_OPT} "${WHITESUR_TMP_DIR}/beggy.png"
2021-05-09 05:05:51 +02:00
else
cp -r "${background}" "${WHITESUR_TMP_DIR}/beggy.png"
fi
;;
2021-04-08 02:09:27 +02:00
esac
}
2021-04-19 13:35:20 +02:00
install_xfwmy() {
local color="$(destify ${1})"
2022-02-23 14:11:08 +01:00
local TARGET_DIR="${dest}/${name}${color}${colorscheme}"
local HDPI_TARGET_DIR="${dest}/${name}${color}${colorscheme}-hdpi"
local XHDPI_TARGET_DIR="${dest}/${name}${color}${colorscheme}-xhdpi"
2021-04-19 13:35:20 +02:00
mkdir -p "${TARGET_DIR}/xfwm4"
2022-02-23 14:11:08 +01:00
cp -r "${THEME_SRC_DIR}/assets/xfwm4/assets${color}${colorscheme}/"*".png" "${TARGET_DIR}/xfwm4"
2021-04-19 13:35:20 +02:00
cp -r "${THEME_SRC_DIR}/main/xfwm4/themerc${color}" "${TARGET_DIR}/xfwm4/themerc"
mkdir -p "${HDPI_TARGET_DIR}/xfwm4"
2022-02-23 14:11:08 +01:00
cp -r "${THEME_SRC_DIR}/assets/xfwm4/assets${color}${colorscheme}-hdpi/"*".png" "${HDPI_TARGET_DIR}/xfwm4"
2021-04-19 13:35:20 +02:00
cp -r "${THEME_SRC_DIR}/main/xfwm4/themerc${color}" "${HDPI_TARGET_DIR}/xfwm4/themerc"
mkdir -p "${XHDPI_TARGET_DIR}/xfwm4"
2022-02-23 14:11:08 +01:00
cp -r "${THEME_SRC_DIR}/assets/xfwm4/assets${color}${colorscheme}-xhdpi/"*".png" "${XHDPI_TARGET_DIR}/xfwm4"
2021-04-19 13:35:20 +02:00
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
2022-02-23 14:11:08 +01:00
TARGET_DIR="${dest}/${name}${color}${opacity}${alt}${theme}${colorscheme}/gnome-shell"
2021-06-02 18:04:59 +02:00
else
TARGET_DIR="${6}"
fi
2021-04-08 02:09:27 +02:00
2022-05-05 14:20:23 +02:00
if [[ "${GNOME_VERSION}" == 'none' ]]; then
2023-03-29 08:48:35 +02:00
local GNOME_VERSION='44-0'
2022-05-05 14:20:23 +02:00
fi
2021-04-08 02:09:27 +02:00
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}"
2022-05-05 11:53:22 +02:00
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gnome-shell/shell-${GNOME_VERSION}/gnome-shell${color}.scss" "${TARGET_DIR}/gnome-shell.css"
2021-04-08 16:59:05 +02:00
2021-04-08 02:09:27 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/"*".svg" "${TARGET_DIR}/assets"
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/assets${color}/"*".svg" "${TARGET_DIR}/assets"
2022-02-23 14:37:49 +01:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/theme${theme}${colorscheme}/"*".svg" "${TARGET_DIR}/assets"
2021-04-08 02:09:27 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/activities/activities${icon}.svg" "${TARGET_DIR}/assets/activities.svg"
2021-07-19 16:24:56 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/activities/activities${icon}.svg" "${TARGET_DIR}/assets/activities-white.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"
)
2022-05-07 03:30:42 +02:00
if [[ "${black_font:-}" == 'true' || "${opacity}" == '-solid' ]] && [[ "${color}" == '-Light' ]]; then
2021-04-08 02:09:27 +02:00
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/activities-black/activities${icon}.svg" "${TARGET_DIR}/assets/activities.svg"
fi
}
install_theemy() {
local color="$(destify ${1})"
local opacity="$(destify ${2})"
local alt="$(destify ${3})"
local theme="$(destify ${4})"
2022-05-07 03:30:42 +02:00
if [[ "${color}" == '-Light' ]]; then
2021-06-06 16:45:33 +02:00
local iconcolor=''
2022-05-07 03:30:42 +02:00
elif [[ "${color}" == '-Dark' ]]; then
local iconcolor='-Dark'
2021-06-06 16:45:33 +02:00
fi
2022-02-23 14:11:08 +01:00
local TARGET_DIR="${dest}/${name}${color}${opacity}${alt}${theme}${colorscheme}"
local TMP_DIR_T="${WHITESUR_TMP_DIR}/gtk-3.0${color}${opacity}${alt}${theme}${colorscheme}"
local TMP_DIR_F="${WHITESUR_TMP_DIR}/gtk-4.0${color}${opacity}${alt}${theme}${colorscheme}"
2021-04-08 02:09:27 +02:00
mkdir -p "${TARGET_DIR}"
2021-06-08 10:36:57 +02:00
local desktop_entry="[Desktop Entry]\n"
desktop_entry+="Type=X-GNOME-Metatheme\n"
2022-02-23 14:11:08 +01:00
desktop_entry+="Name=${name}${color}${opacity}${alt}${theme}${colorscheme}\n"
2021-06-08 10:36:57 +02:00
desktop_entry+="Comment=A MacOS BigSur like Gtk+ theme based on Elegant Design\n"
desktop_entry+="Encoding=UTF-8\n\n"
desktop_entry+="[X-GNOME-Metatheme]\n"
2022-02-23 14:11:08 +01:00
desktop_entry+="GtkTheme=${name}${color}${opacity}${alt}${theme}${colorscheme}\n"
desktop_entry+="MetacityTheme=${name}${color}${opacity}${alt}${theme}${colorscheme}\n"
2021-06-08 10:36:57 +02:00
desktop_entry+="IconTheme=${name}${iconcolor}\n"
desktop_entry+="CursorTheme=WhiteSur-cursors\n"
desktop_entry+="ButtonLayout=close,minimize,maximize:menu\n"
2021-06-09 18:00:46 +02:00
echo -e "${desktop_entry}" > "${TARGET_DIR}/index.theme"
2021-04-08 02:09:27 +02:00
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"
2021-12-26 15:16:39 +01:00
cp -r "${THEME_SRC_DIR}/assets/gtk/scalable" "${TMP_DIR_T}/assets"
2022-02-23 14:11:08 +01:00
cp -r "${THEME_SRC_DIR}/assets/gtk/windows-assets/titlebutton${alt}${colorscheme}" "${TMP_DIR_T}/windows-assets"
2021-04-08 02:09:27 +02:00
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"
2022-05-07 03:30:42 +02:00
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"
2022-05-05 11:53:22 +02:00
cp -r "${THEME_SRC_DIR}/assets/gtk/thumbnails/thumbnail${color}${theme}${colorscheme}.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"
2022-05-07 03:30:42 +02:00
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"
2022-05-05 11:53:22 +02:00
cp -r "${THEME_SRC_DIR}/assets/gtk/thumbnails/thumbnail${color}${theme}${colorscheme}.png" "${TARGET_DIR}/gtk-4.0/thumbnail.png"
2021-04-09 14:03:06 +02:00
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"
2022-02-23 14:11:08 +01:00
cp -r "${THEME_SRC_DIR}/assets/cinnamon/assets${color}${colorscheme}/"*".svg" "${TARGET_DIR}/cinnamon/assets"
cp -r "${THEME_SRC_DIR}/assets/cinnamon/theme${theme}${colorscheme}/"*".svg" "${TARGET_DIR}/cinnamon/assets"
2022-05-05 11:53:22 +02:00
cp -r "${THEME_SRC_DIR}/assets/cinnamon/thumbnails/thumbnail${color}${theme}${colorscheme}.png" "${TARGET_DIR}/cinnamon/thumbnail.png"
2021-04-08 02:09:27 +02:00
#----------------Misc------------------#
mkdir -p "${TARGET_DIR}/gtk-2.0"
2022-02-23 14:11:08 +01:00
cp -r "${THEME_SRC_DIR}/main/gtk-2.0/gtkrc${color}${theme}${colorscheme}" "${TARGET_DIR}/gtk-2.0/gtkrc"
2021-04-08 02:09:27 +02:00
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"
2022-02-23 14:11:08 +01:00
cp -r "${THEME_SRC_DIR}/assets/gtk-2.0/assets-common${color}${colorscheme}" "${TARGET_DIR}/gtk-2.0/assets"
cp -r "${THEME_SRC_DIR}/assets/gtk-2.0/assets${color}${theme}${colorscheme}/"*".png" "${TARGET_DIR}/gtk-2.0/assets"
2021-04-08 02:09:27 +02:00
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"
2022-05-05 11:53:22 +02:00
cp -r "${THEME_SRC_DIR}/assets/metacity-1/titlebuttons${color}${colorscheme}" "${TARGET_DIR}/metacity-1/titlebuttons"
cp -r "${THEME_SRC_DIR}/assets/metacity-1/thumbnail${color}${colorscheme}.png" "${TARGET_DIR}/metacity-1/thumbnail.png"
2021-04-08 02:09:27 +02:00
( 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"
2023-06-10 13:25:22 +02:00
cp -r "${THEME_SRC_DIR}/assets/unity" "${TARGET_DIR}"
2021-04-08 02:09:27 +02:00
}
remove_packy() {
2022-04-26 11:01:06 +02:00
rm -rf "${dest}/${name}$(destify ${1})$(destify ${2})$(destify ${3})$(destify ${4})${colorscheme}"
2022-02-23 14:11:08 +01:00
rm -rf "${dest}/${name}$(destify ${1})${colorscheme}-hdpi"
rm -rf "${dest}/${name}$(destify ${1})${colorscheme}-xhdpi"
2021-04-08 02:09:27 +02:00
}
2022-05-07 03:30:42 +02:00
remove_old_packy() {
rm -rf "${dest}/${name}${1}$(destify ${2})$(destify ${3})$(destify ${4})${5}"
rm -rf "${dest}/${name}${1}${5}-hdpi"
rm -rf "${dest}/${name}${1}${5}-xhdpi"
}
2022-10-19 12:03:26 +02:00
###############################################################################
# LIBADWAITA #
###############################################################################
2022-05-05 11:53:22 +02:00
config_gtk4() {
2022-10-19 12:03:26 +02:00
local color="$(destify ${1})"
2022-10-19 09:45:53 +02:00
local alt="$(destify ${2})"
2022-05-05 11:53:22 +02:00
local TARGET_DIR="${HOME}/.config/gtk-4.0"
# Install gtk4.0 into config for libadwaita
mkdir -p "${TARGET_DIR}"
2023-08-07 10:24:33 +02:00
# backup_file "${TARGET_DIR}/gtk.css" "udo"
rm -rf "${TARGET_DIR}/"{gtk.css,gtk-Light.css,gtk-Dark.css,assets,windows-assets}
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-4.0/gtk-Light.scss" "${TARGET_DIR}/gtk-Light.css"
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-4.0/gtk-Dark.scss" "${TARGET_DIR}/gtk-Dark.css"
ln -sf "${TARGET_DIR}/gtk-${colors}.css" "${TARGET_DIR}/gtk.css"
2022-05-05 11:53:22 +02:00
cp -r "${THEME_SRC_DIR}/assets/gtk/common-assets/assets" "${TARGET_DIR}"
cp -r "${THEME_SRC_DIR}/assets/gtk/common-assets/sidebar-assets/"*".png" "${TARGET_DIR}/assets"
cp -r "${THEME_SRC_DIR}/assets/gtk/scalable" "${TARGET_DIR}/assets"
cp -r "${THEME_SRC_DIR}/assets/gtk/windows-assets/titlebutton${alt}${colorscheme}" "${TARGET_DIR}/windows-assets"
}
2022-10-19 12:03:26 +02:00
install_libadwaita() {
opacity="${opacities[0]}"
color="${colors[1]}"
gtk_base "${opacities[0]}" "${themes[0]}"
config_gtk4 "${colors}" "${alts}"
}
remove_libadwaita() {
2023-08-07 10:24:33 +02:00
# restore_file "${TARGET_DIR}/gtk.css"
rm -rf "${HOME}/.config/gtk-4.0/"{gtk.css,gtk-Light.css,gtk-Dark.css,assets,windows-assets}
2022-10-19 12:03:26 +02:00
}
2021-04-08 02:09:27 +02:00
###############################################################################
# THEMES #
###############################################################################
2023-07-24 15:42:24 +02:00
fix_whiskermenu() {
2023-07-25 09:44:20 +02:00
if (command -v xfce4-popup-whiskermenu &> /dev/null) && $(sed -i "s|.*menu-opacity=.*|menu-opacity=95|" "$HOME/.config/xfce4/panel/whiskermenu"*".rc" &> /dev/null); then
2023-07-24 15:42:24 +02:00
sed -i "s|.*menu-opacity=.*|menu-opacity=95|" "$HOME/.config/xfce4/panel/whiskermenu"*".rc"
fi
if (pgrep xfce4-session &> /dev/null); then
xfce4-panel -r
fi
}
2021-04-08 02:09:27 +02:00
install_themes() {
2021-05-23 15:04:01 +02:00
# "install_theemy" and "install_shelly" require "gtk_base", so multithreading
# isn't possible
2021-06-11 13:59:07 +02:00
install_theme_deps; 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
for color in "${colors[@]}"; do
2022-10-19 09:45:53 +02:00
gtk_base "${opacity}" "${theme}" "${compact}"
2022-05-05 11:53:22 +02:00
install_theemy "${color}" "${opacity}" "${alt}" "${theme}"
2021-05-23 09:46:03 +02:00
install_shelly "${color}" "${opacity}" "${alt}" "${theme}" "${icon}"
2022-01-31 15:20:25 +01:00
install_xfwmy "${color}"
2021-04-08 02:09:27 +02:00
done
done
done
done
2023-07-24 15:42:24 +02:00
stop_animation; fix_whiskermenu
2021-04-08 02:09:27 +02:00
}
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
2022-05-07 03:30:42 +02:00
for color in '-light' '-dark'; do
for opacity in "${OPACITY_VARIANTS[@]}"; do
for alt in "${ALT_VARIANTS[@]}"; do
for theme in "${THEME_VARIANTS[@]}"; do
for scheme in '' '-nord'; do
remove_old_packy "${color}" "${opacity}" "${alt}" "${theme}" "${scheme}"
done
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() {
local TARGET=
# Let's go!
2021-06-12 10:58:03 +02:00
install_theme_deps
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}"
2021-08-28 18:27:35 +02:00
elif check_theme_file "$ZORIN_GR_FILE"; then
TARGET="${ZORIN_GR_FILE}"
2021-04-08 02:09:27 +02:00
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
}
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}"
2021-08-28 18:27:35 +02:00
restore_file "${ZORIN_GR_FILE}"
2021-04-08 02:09:27 +02:00
}
###############################################################################
# FIREFOX #
###############################################################################
install_firefox_theme() {
if has_snap_app firefox; then
local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}"
elif 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
udo mkdir -p "${TARGET_DIR}"
2021-06-24 04:55:17 +02:00
udo cp -rf "${FIREFOX_SRC_DIR}"/customChrome.css "${TARGET_DIR}"
if [[ "${monterey}" == 'true' ]]; then
udo cp -rf "${FIREFOX_SRC_DIR}"/Monterey "${TARGET_DIR}"
2023-05-24 18:47:54 +02:00
udo cp -rf "${FIREFOX_SRC_DIR}"/common/{icons,titlebuttons,pages} "${TARGET_DIR}"/Monterey
udo cp -rf "${FIREFOX_SRC_DIR}"/common/*.css "${TARGET_DIR}"/Monterey
udo cp -rf "${FIREFOX_SRC_DIR}"/common/parts/*.css "${TARGET_DIR}"/Monterey/parts
2023-02-14 11:00:15 +01:00
udo cp -rf "${FIREFOX_SRC_DIR}"/userContent-Monterey.css "${TARGET_DIR}"/userContent.css
2021-10-10 18:52:35 +02:00
if [[ "${alttheme}" == 'true' ]]; then
udo cp -rf "${FIREFOX_SRC_DIR}"/userChrome-Monterey-alt.css "${TARGET_DIR}"/userChrome.css
2023-06-11 20:18:15 +02:00
udo cp -rf "${FIREFOX_SRC_DIR}"/WhiteSur/parts/headerbar-urlbar.css "${TARGET_DIR}"/Monterey/parts/headerbar-urlbar-alt.css
2021-10-10 18:52:35 +02:00
else
udo cp -rf "${FIREFOX_SRC_DIR}"/userChrome-Monterey.css "${TARGET_DIR}"/userChrome.css
fi
2021-06-24 04:55:17 +02:00
else
udo cp -rf "${FIREFOX_SRC_DIR}"/WhiteSur "${TARGET_DIR}"
2023-05-24 18:47:54 +02:00
udo cp -rf "${FIREFOX_SRC_DIR}"/common/{icons,titlebuttons,pages} "${TARGET_DIR}"/WhiteSur
udo cp -rf "${FIREFOX_SRC_DIR}"/common/*.css "${TARGET_DIR}"/WhiteSur
udo cp -rf "${FIREFOX_SRC_DIR}"/common/parts/*.css "${TARGET_DIR}"/WhiteSur/parts
2021-06-24 04:55:17 +02:00
udo cp -rf "${FIREFOX_SRC_DIR}"/userChrome-WhiteSur.css "${TARGET_DIR}"/userChrome.css
2023-02-14 11:00:15 +01:00
udo cp -rf "${FIREFOX_SRC_DIR}"/userContent-WhiteSur.css "${TARGET_DIR}"/userContent.css
2021-06-24 04:55:17 +02:00
fi
2021-04-08 02:09:27 +02:00
config_firefox
}
config_firefox() {
2023-05-11 15:26:20 +02:00
if has_snap_app firefox; then
local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}"
local FIREFOX_DIR="${FIREFOX_SNAP_DIR_HOME}"
2023-05-11 15:58:57 +02:00
elif 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"
udo ln -sf "${TARGET_DIR}" "${d}/chrome"
udoify_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"
2021-05-27 18:23:57 +02:00
fi
2021-04-08 02:09:27 +02:00
done
}
edit_firefox_theme_prefs() {
2023-05-11 15:26:20 +02:00
if has_snap_app firefox; then
local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}"
2023-05-11 15:58:57 +02:00
elif 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
udo ${EDITOR:-nano} "${TARGET_DIR}/userChrome.css"
udo ${EDITOR:-nano} "${TARGET_DIR}/customChrome.css"
2021-04-08 02:09:27 +02:00
}
remove_firefox_theme() {
2023-06-11 11:57:14 +02:00
if has_snap_app firefox; then
local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}"
elif has_flatpak_app org.mozilla.firefox; then
local TARGET_DIR="${FIREFOX_FLATPAK_THEME_DIR}"
else
local TARGET_DIR="${FIREFOX_THEME_DIR}"
fi
[[ -f "${TARGET_DIR}"/customChrome.css && ! -f "${TARGET_DIR}"/customChrome.css.bak ]] && cp -r "${TARGET_DIR}"/customChrome.css "${TARGET_DIR}"/customChrome.css.bak
[[ -f "${TARGET_DIR}"/userChrome.css && ! -f "${TARGET_DIR}"/userChrome.css.bak ]] && cp -r "${TARGET_DIR}"/userChrome.css "${TARGET_DIR}"/userChrome.css.bak
[[ -f "${TARGET_DIR}"/userContent.css && ! -f "${TARGET_DIR}"/userContent.css.bak ]] && cp -r "${TARGET_DIR}"/userContent.css "${TARGET_DIR}"/userContent.css.bak
rm -rf "${TARGET_DIR}/${THEME_NAME}"
rm -rf "${TARGET_DIR}"/customChrome.css
rm -rf "${TARGET_DIR}"/userChrome.css
rm -rf "${TARGET_DIR}"/userContent.css
2021-04-08 02:09:27 +02:00
}
###############################################################################
# DASH TO DOCK #
###############################################################################
2021-08-21 16:39:24 +02:00
install_dash_to_dock() {
if [[ -d "${DASH_TO_DOCK_DIR_HOME}" ]]; then
backup_file "${DASH_TO_DOCK_DIR_HOME}" "udo"
rm -rf "${DASH_TO_DOCK_DIR_HOME}"
fi
udo cp -rf "${DASH_TO_DOCK_SRC_DIR}/dash-to-dock@micxgx.gmail.com" "${GNOME_SHELL_EXTENSION_DIR}"
2022-11-12 15:35:09 +01:00
if has_command dbus-launch; then
udo dbus-launch dconf write /org/gnome/shell/extensions/dash-to-dock/apply-custom-theme true
fi
2021-08-21 16:39:24 +02:00
}
2021-04-08 02:09:27 +02:00
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" "udo"
2021-08-27 07:24:32 +02:00
udoify_file "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
2022-06-02 17:02:12 +02:00
if [[ "${GNOME_VERSION}" != '3-28' ]]; then
2021-12-31 04:08:07 +01:00
udo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-4.scss" "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
2022-05-05 11:53:22 +02:00
else
2023-07-10 13:48:47 +02:00
udo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-3.scss" "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
2021-08-27 07:24:32 +02:00
fi
2021-04-08 02:09:27 +02:00
elif [[ -d "${DASH_TO_DOCK_DIR_ROOT}" ]]; then
backup_file "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css" "sudo"
2022-06-02 17:02:12 +02:00
if [[ "${GNOME_VERSION}" != '3-28' ]]; then
2021-12-31 04:08:07 +01:00
sudo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-4.scss" "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css"
2021-08-27 07:24:32 +02:00
else
2021-12-31 04:08:07 +01:00
sudo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-3.scss" "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css"
2021-08-27 07:24:32 +02:00
fi
2021-04-08 02:09:27 +02:00
fi
2022-11-12 15:35:09 +01:00
if has_command dbus-launch; then
udo dbus-launch dconf write /org/gnome/shell/extensions/dash-to-dock/apply-custom-theme true
fi
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" "udo"
2021-04-08 02:09:27 +02:00
elif [[ -d "${DASH_TO_DOCK_DIR_ROOT}" ]]; then
restore_file "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css" "sudo"
2021-04-08 02:09:27 +02:00
fi
2021-06-25 06:17:37 +02:00
2022-11-12 15:35:09 +01:00
if has_command dbus-launch; then
udo dbus-launch dconf write /org/gnome/shell/extensions/dash-to-dock/apply-custom-theme false
fi
2021-04-08 02:09:27 +02:00
}
###############################################################################
# FLATPAK & SNAP #
###############################################################################
connect_flatpak() {
2021-08-30 03:52:06 +02:00
install_flatpak_deps
2021-08-27 16:02:58 +02:00
2021-08-21 16:39:24 +02:00
for opacity in "${opacities[@]}"; do
for alt in "${alts[@]}"; do
for theme in "${themes[@]}"; do
for color in "${colors[@]}"; do
2021-08-28 16:04:02 +02:00
pakitheme_gtk3 "${color}" "${opacity}" "${alt}" "${theme}"
2021-08-21 16:39:24 +02:00
done
done
done
done
2021-04-08 02:09:27 +02:00
}
disconnect_flatpak() {
2021-08-21 16:39:24 +02:00
for opacity in "${opacities[@]}"; do
for alt in "${alts[@]}"; do
for theme in "${themes[@]}"; do
for color in "${colors[@]}"; do
flatpak_remove "${color}" "${opacity}" "${alt}" "${theme}"
done
done
done
done
2021-04-08 02:09:27 +02:00
}
2022-12-07 15:06:48 +01:00
#connect_snap() {
# sudo snap install whitesur-gtk-theme
# for i in $(snap connections | grep gtk-common-themes | awk '{print $2}' | cut -f1 -d: | sort -u); do
# sudo snap connect "${i}:gtk-3-themes" "whitesur-gtk-theme:gtk-3-themes"
# sudo 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
# sudo snap disconnect "${i}:gtk-3-themes" "whitesur-gtk-theme:gtk-3-themes"
# sudo snap disconnect "${i}:icon-themes" "whitesur-gtk-theme:icon-themes"
# done
#}
2021-04-08 02:09:27 +02:00
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-07-19 16:24:56 +02:00
if [[ "${compact}" == 'false' ]]; then
sed $SED_OPT "/\$laptop/s/true/false/" "${THEME_SRC_DIR}/sass/_gtk-base-temp.scss"
fi
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 [[ "${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"}
2023-04-18 08:30:43 +02:00
# Nord dark colors
2022-02-23 14:11:08 +01:00
if [[ "${colorscheme}" == '-nord' ]]; then
2023-04-18 08:30:43 +02:00
prompt -s "Changing ColorScheme style to nord version ...\n"
sed $SED_OPT "/\$colorscheme/s/default/nord/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
2021-12-26 15:16:39 +01:00
fi
2021-11-04 04:09:13 +01:00
# Darker dark colors
if [[ "${darker}" == 'true' ]]; then
2022-11-11 09:45:37 +01:00
prompt -s "Changing dark color style to darker one ...\n"
2021-11-04 04:09:13 +01:00
sed $SED_OPT "/\$darker/s/false/true/" "${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
2022-11-12 16:11:11 +01:00
prompt -s "Changing Nautilus sidebar size ...\n"
2021-05-15 02:14:04 +02:00
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
2022-11-11 09:45:37 +01:00
prompt -s "Changing Nautilus style ...\n"
2021-05-15 02:14:04 +02:00
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
2022-11-11 09:45:37 +01:00
prompt -s "Changing Nautilus titlebutton placement style ...\n"
2021-05-15 02:14:04 +02:00
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
2022-11-11 09:45:37 +01:00
prompt -s "Changing maximized window style ...\n"
2021-05-15 02:14:04 +02:00
sed $SED_OPT "/\$max_window_style/s/square/round/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
2021-11-04 04:09:13 +01:00
# Change gnome-shell panel transparency
if [[ "${panel_opacity}" != 'default' ]]; then
2022-11-11 09:45:37 +01:00
prompt -s "Changing panel transparency ...\n"
2021-11-04 04:09:13 +01:00
sed $SED_OPT "/\$panel_opacity/s/0.15/0.${panel_opacity}/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Change gnome-shell panel height size
if [[ "${panel_size}" != 'default' ]]; then
2022-11-11 09:45:37 +01:00
prompt -s "Changing panel height size to '${panel_size}'...\n"
2021-11-04 04:09:13 +01:00
sed $SED_OPT "/\$panel_size/s/default/${panel_size}/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Change gnome-shell show apps button style
if [[ "${showapps_normal}" == 'true' ]]; then
2022-11-11 09:45:37 +01:00
prompt -s "Changing gnome-shell show apps button style ...\n"
2021-11-04 04:09:13 +01:00
sed $SED_OPT "/\$showapps_button/s/bigsur/normal/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
2021-07-19 16:24:56 +02:00
# Change panel font color
if [[ "${monterey}" == 'true' ]]; then
black_font="true"
2022-11-11 09:45:37 +01:00
prompt -s "Changing to Monterey style ...\n"
2021-07-19 16:24:56 +02:00
sed $SED_OPT "/\$monterey/s/false/true/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
sed $SED_OPT "/\$panel_opacity/s/0.15/0.5/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Change panel font color
if [[ "${black_font}" == 'true' ]]; then
2022-11-11 09:45:37 +01:00
prompt -s "Changing panel font color ...\n"
2021-07-19 16:24:56 +02:00
sed $SED_OPT "/\$panel_font/s/white/black/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
2021-05-15 02:14:04 +02:00
if [[ "${compact}" == 'false' ]]; then
2021-11-04 04:09:13 +01:00
prompt -s "Changing Definition mode to HD (Bigger font, Bigger size) ..."
2021-06-25 06:17:37 +02:00
#FIXME: @vince is it not implemented yet? (Only Gnome-shell and Gtk theme finished!)
2021-04-09 17:06:04 +02:00
fi
2021-08-23 12:42:07 +02:00
if [[ "${scale}" == 'x2' ]]; then
2022-11-11 09:45:37 +01:00
prompt -s "Changing GDM scaling to 200% ...\n"
2021-08-23 12:42:07 +02:00
sed $SED_OPT "/\$scale/s/default/x2/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
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() {
2021-06-11 13:59:07 +02:00
install_dialog_deps
dialogify panel_opacity "${THEME_NAME}" "Choose your panel opacity (Default is 15)" ${PANEL_OPACITY_VARIANTS[*]}
2021-04-08 02:09:27 +02:00
}
show_sidebar_size_dialog() {
2021-06-11 13:59:07 +02:00
install_dialog_deps
dialogify sidebar_size "${THEME_NAME}" "Choose your Nautilus minimum sidebar size (default is 200px)" ${SIDEBAR_SIZE_VARIANTS[*]}
2021-04-08 02:09:27 +02:00
}
show_nautilus_style_dialog() {
2021-06-11 13:59:07 +02:00
install_dialog_deps
dialogify nautilus_style "${THEME_NAME}" "Choose your Nautilus style (default is BigSur-like style)" ${NAUTILUS_STYLE_VARIANTS[*]}
2021-04-08 02:09:27 +02:00
}
show_needed_dialogs() {
2021-05-27 14:58:12 +02:00
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
}