This commit is contained in:
vinceliuice
2022-12-02 23:48:50 +08:00
parent 30227337b3
commit 029a1206a1
35 changed files with 109 additions and 22 deletions

753
shell/lib-core.sh Executable file
View File

@@ -0,0 +1,753 @@
# WARNING: Please make this shell not working-directory dependant, for example
# instead of using 'ls blabla', use 'ls "${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 )
set -Eeo pipefail
if [[ ! "${REPO_DIR}" ]]; then
echo "Please define 'REPODIR' variable"; exit 1
elif [[ "${WHITESUR_SOURCE[@]}" =~ "lib-core.sh" ]]; then
echo "'lib-core.sh' is already imported"; exit 1
fi
WHITESUR_SOURCE=("lib-core.sh")
###############################################################################
# VARIABLES #
###############################################################################
#--------------System--------------#
export WHITESUR_PID=$$
MY_USERNAME="${SUDO_USER:-$(logname 2> /dev/null || echo "${USER}")}"
MY_HOME=$(getent passwd "${MY_USERNAME}" | cut -d: -f6)
if command -v gnome-shell &> /dev/null; then
SHELL_VERSION="$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -1)"
if [[ "${SHELL_VERSION:-}" -ge "42" ]]; then
GNOME_VERSION="42-0"
elif [[ "${SHELL_VERSION:-}" -ge "40" ]]; then
GNOME_VERSION="40-0"
else
GNOME_VERSION="3-28"
fi
else
GNOME_VERSION="none"
fi
#----------Program options-------------#
SASSC_OPT="-t expanded"
if [[ "$(uname -s)" =~ "BSD" || "$(uname -s)" == "Darwin" ]]; then
SED_OPT="-i """
else
SED_OPT="-i"
fi
SUDO_BIN="$(which sudo)"
#------------Directories--------------#
THEME_SRC_DIR="${REPO_DIR}/src"
DASH_TO_DOCK_SRC_DIR="${REPO_DIR}/src/other/dash-to-dock"
DASH_TO_DOCK_DIR_ROOT="/usr/share/gnome-shell/extensions/dash-to-dock@micxgx.gmail.com"
DASH_TO_DOCK_DIR_HOME="${MY_HOME}/.local/share/gnome-shell/extensions/dash-to-dock@micxgx.gmail.com"
GNOME_SHELL_EXTENSION_DIR="${MY_HOME}/.local/share/gnome-shell/extensions"
FIREFOX_SRC_DIR="${REPO_DIR}/src/other/firefox"
FIREFOX_DIR_HOME="${MY_HOME}/.mozilla/firefox"
FIREFOX_THEME_DIR="${MY_HOME}/.mozilla/firefox/firefox-themes"
FIREFOX_FLATPAK_DIR_HOME="${MY_HOME}/.var/app/org.mozilla.firefox/.mozilla/firefox"
FIREFOX_FLATPAK_THEME_DIR="${MY_HOME}/.var/app/org.mozilla.firefox/.mozilla/firefox/firefox-themes"
FIREFOX_SNAP_DIR_HOME="${MY_HOME}/snap/firefox/common/.mozilla/firefox"
FIREFOX_SNAP_THEME_DIR="${MY_HOME}/snap/firefox/common/.mozilla/firefox/firefox-themes"
export WHITESUR_TMP_DIR="/tmp/WhiteSur.lock"
if [[ -w "/root" ]]; then
THEME_DIR="/usr/share/themes"
else
THEME_DIR="$HOME/.themes"
fi
#--------------GDM----------------#
WHITESUR_GS_DIR="/usr/share/gnome-shell/theme/WhiteSur"
COMMON_CSS_FILE="/usr/share/gnome-shell/theme/gnome-shell.css"
UBUNTU_CSS_FILE="/usr/share/gnome-shell/theme/ubuntu.css"
ZORIN_CSS_FILE="/usr/share/gnome-shell/theme/zorin.css"
ETC_CSS_FILE="/etc/alternatives/gdm3.css"
ETC_GR_FILE="/etc/alternatives/gdm3-theme.gresource"
YARU_GR_FILE="/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource"
POP_OS_GR_FILE="/usr/share/gnome-shell/theme/Pop/gnome-shell-theme.gresource"
ZORIN_GR_FILE="/usr/share/gnome-shell/theme/ZorinBlue-Light/gnome-shell-theme.gresource"
MISC_GR_FILE="/usr/share/gnome-shell/gnome-shell-theme.gresource"
GS_GR_XML_FILE="${THEME_SRC_DIR}/main/gnome-shell/gnome-shell-theme.gresource.xml"
#-------------Theme---------------#
THEME_NAME="WhiteSur"
COLOR_VARIANTS=('Light' 'Dark')
OPACITY_VARIANTS=('normal' 'solid')
ALT_VARIANTS=('normal' 'alt')
THEME_VARIANTS=('default' 'blue' 'purple' 'pink' 'red' 'orange' 'yellow' 'green' 'grey')
ICON_VARIANTS=('standard' 'simple' 'gnome' 'ubuntu' 'tux' 'arch' 'manjaro' 'fedora' 'debian' 'void' 'opensuse' 'popos' 'mxlinux' 'zorin')
SIDEBAR_SIZE_VARIANTS=('default' '180' '220' '240' '260' '280')
PANEL_OPACITY_VARIANTS=('default' '30' '45' '60' '75')
PANEL_SIZE_VARIANTS=('default' 'smaller' 'bigger')
NAUTILUS_STYLE_VARIANTS=('stable' 'normal' 'mojave' 'glassy')
#--------Customization, default values----------#
dest="${THEME_DIR}"
name="${THEME_NAME}"
colors=("${COLOR_VARIANTS}")
opacities=("${OPACITY_VARIANTS}")
alts=("${ALT_VARIANTS[0]}")
themes=("${THEME_VARIANTS[0]}")
icon="${ICON_VARIANTS[0]}"
sidebar_size="${SIDEBAR_SIZE_VARIANTS[0]}"
panel_opacity="${PANEL_OPACITY_VARIANTS[0]}"
panel_size="${PANEL_SIZE_VARIANTS[0]}"
nautilus_style="${NAUTILUS_STYLE_VARIANTS[0]}"
background="blank"
compact="true"
colorscheme=""
#--Ambigous arguments checking and overriding default values--#
declare -A has_set=([-b]="false" [-s]="false" [-p]="false" [-P]="false" [-d]="false" [-n]="false" [-a]="false" [-o]="false" [-c]="false" [-i]="false" [-t]="false" [-N]="false")
declare -A need_dialog=([-b]="false" [-s]="false" [-p]="false" [-P]="false" [-d]="false" [-n]="false" [-a]="false" [-o]="false" [-c]="false" [-i]="false" [-t]="false" [-N]="false")
#------------Tweaks---------------#
need_help="false"
uninstall="false"
interactive="false"
silent_mode="false"
no_darken="false"
no_blur="false"
firefox="false"
edit_firefox="false"
flatpak="false"
snap="false"
gdm="false"
dash_to_dock="false"
max_round="false"
showapps_normal="false"
#--------------Misc----------------#
msg=""
final_msg="Run '${0} --help' to explore more customization features!"
notif_msg=""
process_ids=()
# This is important for 'udo' because 'return "${result}"' is considered the
# last command in 'BASH_COMMAND' variable
WHITESUR_COMMAND=""
export ANIM_PID="0"
has_any_error="false"
swupd_packages=""
# '/' ending is required in 'swupd_url'
swupd_url="https://cdn.download.clearlinux.org/current/x86_64/os/Packages/"
swupd_ver_url="https://cdn.download.clearlinux.org/latest"
swupd_prepared="false"
xbps_prepared="false"
#------------Decoration-----------#
export c_default="\033[0m"
export c_blue="\033[1;34m"
export c_magenta="\033[1;35m"
export c_cyan="\033[1;36m"
export c_green="\033[1;32m"
export c_red="\033[1;31m"
export c_yellow="\033[1;33m"
anim=(
"${c_blue}${c_green}${c_red}${c_magenta}"
" ${c_green}${c_red}${c_magenta}${c_blue}"
" ${c_red}${c_magenta}${c_blue}${c_green}"
" ${c_magenta}${c_blue}${c_green}${c_red}"
" ${c_blue}${c_green}${c_red}${c_magenta}"
)
# Check command availability
has_command() {
command -v "$1" &> /dev/null
}
has_flatpak_app() {
flatpak list --columns=application | grep "${1}" &> /dev/null || return 1
}
has_snap_app() {
snap list "${1}" &> /dev/null || return 1
}
is_my_distro() {
[[ "$(cat '/etc/os-release' | awk -F '=' '/ID/{print $2}')" =~ "${1}" ]]
}
is_running() {
pgrep "$1" &> /dev/null
}
###############################################################################
# CORE UTILITIES #
###############################################################################
start_animation() {
[[ "${silent_mode}" == "true" ]] && return 0
setterm -cursor off
(
while true; do
for i in {0..4}; do
echo -ne "\r\033[2K ${anim[i]}"
sleep 0.1
done
for i in {4..0}; do
echo -ne "\r\033[2K ${anim[i]}"
sleep 0.1
done
done
) &
export ANIM_PID="${!}"
}
stop_animation() {
[[ "${silent_mode}" == "true" ]] && return 0
[[ -e "/proc/${ANIM_PID}" ]] && kill -13 "${ANIM_PID}"
setterm -cursor on
}
# Echo like ... with flag type and display message colors
prompt() {
case "${1}" in
"-s")
echo -e " ${c_green}${2}${c_default}" ;; # print success message
"-e")
echo -e " ${c_red}${2}${c_default}" ;; # print error message
"-w")
echo -e " ${c_yellow}${2}${c_default}" ;; # print warning message
"-i")
echo -e " ${c_cyan}${2}${c_default}" ;; # print info message
"-t")
echo -e " ${c_magenta}${2}${c_default}" ;; # print title message
esac
}
###############################################################################
# SELF SAFETY #
###############################################################################
##### This is the core of error handling, make sure there's no error here #####
### TODO: return "lockWhiteSur()" back for non functional syntax error handling
### and lock dir removal after immediate terminal window closing
if [[ -d "${WHITESUR_TMP_DIR}" ]]; then
start_animation; sleep 2; stop_animation; echo
if [[ -d "${WHITESUR_TMP_DIR}" ]]; then
prompt -e "ERROR: Whitesur installer or tweaks is already running. Probably it's run by '$(ls -ld "${WHITESUR_TMP_DIR}" | awk '{print $3}')'"
exit 1
fi
fi
rm -rf "${WHITESUR_TMP_DIR}"
mkdir -p "${WHITESUR_TMP_DIR}"; exec 2> "${WHITESUR_TMP_DIR}/error_log.txt"
signal_exit() {
rm -rf "${WHITESUR_TMP_DIR}"
stop_animation
}
signal_abort() {
signal_exit
prompt -e "\n\n Oops! Operation has been aborted...\n\n"
exit 1
}
signal_error() {
# TODO: make this more accurate
IFS=$'\n'
local sources=($(basename -a "${WHITESUR_SOURCE[@]}" "${BASH_SOURCE[@]}" | sort -u))
local dist_ids=($(awk -F '=' '/ID/{print $2}' "/etc/os-release" | tr -d '"' | sort -Vru))
local repo_ver=""
local lines=()
local log="$(awk '{printf "\033[1;31m >>> %s\n", $0}' "${WHITESUR_TMP_DIR}/error_log.txt" || echo "")"
if ! repo_ver="$(cd "${REPO_DIR}"; git log -1 --date=format-local:"%FT%T%z" --format="%ad")"; then
if ! repo_ver="$(date -r "${REPO_DIR}" +"%FT%T%z")"; then
repo_ver="unknown"
fi
fi
# Some computer may have a bad performance. We need to avoid the error log
# to be cut. Sleeping for awhile may help
sleep 0.75; clear
prompt -e "\n\n Oops! Operation failed...\n"
prompt -e "=========== ERROR LOG ==========="
if [[ "${log}" ]] ; then
echo -e "${log}"
else
prompt -e "\n>>>>>>> No error log found <<<<<<"
fi
prompt -e "\n =========== ERROR INFO =========="
prompt -e "FOUND :"
for i in "${sources[@]}"; do
lines=($(grep -Fn "${WHITESUR_COMMAND:-${BASH_COMMAND}}" "${REPO_DIR}/${i}" | cut -d : -f 1 || echo ""))
prompt -e " >>> ${i}$(IFS=';'; [[ "${lines[*]}" ]] && echo " at ${lines[*]}")"
done
prompt -e "SNIPPET:\n >>> ${WHITESUR_COMMAND:-${BASH_COMMAND}}"
prompt -e "TRACE :"
for i in "${FUNCNAME[@]}"; do
prompt -e " >>> ${i}"
done
prompt -e "\n =========== SYSTEM INFO ========="
prompt -e "DISTRO : $(IFS=';'; echo "${dist_ids[*]}")"
prompt -e "SUDO : $([[ -w "/root" ]] && echo "yes" || echo "no")"
prompt -e "GNOME : ${GNOME_VERSION}"
prompt -e "REPO : ${repo_ver}\n"
if [[ "$(grep -ril "Release" "${WHITESUR_TMP_DIR}/error_log.txt")" == "${WHITESUR_TMP_DIR}/error_log.txt" ]]; then
prompt -w "HINT: You can run: 'sudo apt install sassc libglib2.0-dev libxml2-utils' on ubuntu 18.04 or 'sudo apt install sassc libglib2.0-dev-bin' on ubuntu >= 20.04 \n"
fi
prompt -i "HINT: You can google or report to us the info above \n"
prompt -i "https://github.com/vinceliuice/WhiteSur-gtk-theme/issues \n"
rm -rf "${WHITESUR_TMP_DIR}"; exit 1
}
trap 'signal_exit' EXIT
trap 'signal_error' ERR
trap 'signal_abort' INT TERM TSTP
###############################################################################
# USER UTILITIES #
###############################################################################
ask() {
[[ "${silent_mode}" == "true" ]] && return 0
echo -ne "${c_magenta}"
read -p " ${2}: " ${1} 2>&1
echo -ne "${c_default}"
}
confirm() {
[[ "${silent_mode}" == "true" ]] && return 0
while [[ "${!1}" != "y" && "${!1}" != "n" ]]; do
ask ${1} "${2} (y/n)"
done
}
dialogify() {
if [[ "${silent_mode}" == "true" ]]; then
prompt -w "Oops... silent mode has been activated so we can't show the dialog"
return 0
fi
local lists=""
local i=0
local result=""
local n_result=4
for list in "${@:4}"; do
lists+=" ${i} ${list} off "; ((i+=1))
done
result="$(dialog --backtitle "${2}" --radiolist "${3}" 0 0 0 ${lists} --output-fd 1 || echo "x")"
clear
if [[ "${result}" != "x" ]]; then
((n_result+=result))
printf -v "${1}" "%s" "${!n_result}"
else
signal_abort
fi
}
helpify_title() {
printf "${c_cyan}%s${c_blue}%s ${c_green}%s\n\n" "Usage: " "$0" "[OPTIONS...]"
printf "${c_cyan}%s\n" "OPTIONS:"
}
helpify() {
printf " ${c_blue}%s ${c_green}%s\n ${c_magenta}%s. ${c_cyan}%s\n\n${c_default}" "${1}" "${2}" "${3}" "${4}"
}
###############################################################################
# PARAMETERS #
###############################################################################
destify() {
case "${1}" in
normal|default|standard)
echo "" ;;
*)
echo "-${1}" ;;
esac
}
parsimplify() {
case "${1}" in
--name|-n)
# workaround for echo
echo "~-n" | cut -c 2- ;;
--dest)
echo "-d" ;;
--size)
echo "-s" ;;
--alt)
echo "-a" ;;
--opacity)
echo "-o" ;;
--color)
echo "-c" ;;
--icon)
echo "-i" ;;
--theme)
echo "-t" ;;
--panel-opacity)
echo "-p" ;;
--panel-size)
echo "-P" ;;
--nautilus-style)
echo "-N" ;;
--background)
echo "-b" ;;
*)
echo "${1}" ;;
esac
}
check_param() {
local global_param="$(parsimplify "${1}")"
local display_param="${2}" # used for aliases
local value="${3}"
local must_not_ambigous="${4}" # options: must, optional, not-at-all
local must_have_value="${5}" # options: must, optional, not-at-all
local value_must_found="${6}" # options: must, optional, not-at-all
local allow_all_choice="${7}" # options: true, false
local has_any_ambiguity_error="false"
local variant_found="false"
if [[ "${silent_mode}" == "true" ]]; then
must_not_ambigous="must"
must_have_value="must"
value_must_found="must"
fi
if [[ "${has_set["${global_param}"]}" == "true" ]]; then
need_dialog["${global_param}"]="true"
case "${must_not_ambigous}" in
must)
prompt -e "ERROR: Ambigous '${display_param}' option. Choose one only."; has_any_error="true" ;;
optional)
prompt -w "WARNING: Ambigous '${display_param}' option. We'll show a chooser dialog when possible" ;;
esac
fi
if [[ "${value}" == "" || "${value}" == "-"* ]]; then
need_dialog["${global_param}"]="true"
case "${must_have_value}" in
must)
prompt -e "ERROR: '${display_param}' can't be empty."; has_any_error="true" ;;
optional)
prompt -w "WARNING: '${display_param}' can't be empty. We'll show a chooser dialog when possible" ;;
esac
has_set["${global_param}"]="true"; return 1
else
if [[ "${has_set["${global_param}"]}" == "false" ]]; then
case "${global_param}" in
-a)
alts=() ;;
-o)
opacities=() ;;
-c)
colors=() ;;
-t)
themes=() ;;
esac
fi
case "${global_param}" in
-d)
if [[ "$(readlink -m "${value}")" =~ "${REPO_DIR}" ]]; then
prompt -e "'${display_param}' ERROR: Can't install in the source directory."
has_any_error="true"
elif [[ ! -w "${value}" && ! -w "$(dirname "${value}")" ]]; then
prompt -e "'${display_param}' ERROR: You have no permission to access that directory."
has_any_error="true"
else
if [[ ! -d "${value}" ]]; then
prompt -w "Destination directory does not exist. Let's make a new one..."; echo
mkdir -p "${value}"
fi
dest="${value}"
fi
remind_relative_path "${display_param}" "${value}"; variant_found="skip" ;;
-b)
if [[ "${value}" == "blank" || "${value}" == "default" ]]; then
background="${value}"
elif [[ ! -r "${value}" ]]; then
prompt -e "'${display_param}' ERROR: Image file is not found or unreadable."
has_any_error="true"
elif file "${value}" | grep -qE "image|bitmap"; then
background="${value}"
else
prompt -e "'${display_param}' ERROR: Invalid image file."
has_any_error="true"
fi
remind_relative_path "${display_param}" "${value}"; variant_found="skip" ;;
-n)
name="${value}"; variant_found="skip" ;;
-s)
for i in {0..5}; do
if [[ "${value}" == "${SIDEBAR_SIZE_VARIANTS[i]}" ]]; then
sidebar_size="${value}"; variant_found="true"; break
fi
done ;;
-p)
for i in {0..4}; do
if [[ "${value}" == "${PANEL_OPACITY_VARIANTS[i]}" ]]; then
panel_opacity="${value}"; variant_found="true"; break
fi
done ;;
-P)
for i in {0..2}; do
if [[ "${value}" == "${PANEL_SIZE_VARIANTS[i]}" ]]; then
panel_size="${value}"; variant_found="true"; break
fi
done ;;
-a)
if [[ "${value}" == "all" ]]; then
for i in {0..2}; do
alts+=("${ALT_VARIANTS[i]}")
done
variant_found="true"
else
for i in {0..2}; do
if [[ "${value}" == "${ALT_VARIANTS[i]}" ]]; then
alts+=("${ALT_VARIANTS[i]}"); variant_found="true"; break
fi
done
fi ;;
-o)
for i in {0..1}; do
if [[ "${value}" == "${OPACITY_VARIANTS[i]}" ]]; then
opacities+=("${OPACITY_VARIANTS[i]}"); variant_found="true"; break
fi
done ;;
-c)
for i in {0..1}; do
if [[ "${value}" == "${COLOR_VARIANTS[i]}" ]]; then
colors+=("${COLOR_VARIANTS[i]}"); variant_found="true"; break
fi
done ;;
-i)
for i in {0..13}; do
if [[ "${value}" == "${ICON_VARIANTS[i]}" ]]; then
icon="${ICON_VARIANTS[i]}"; variant_found="true"; break
fi
done ;;
-t)
if [[ "${value}" == "all" ]]; then
for i in {0..8}; do
themes+=("${THEME_VARIANTS[i]}")
done
variant_found="true"
else
for i in {0..8}; do
if [[ "${value}" == "${THEME_VARIANTS[i]}" ]]; then
themes+=("${THEME_VARIANTS[i]}")
variant_found="true"
break
fi
done
fi ;;
-N)
for i in {0..3}; do
if [[ "${value}" == "${NAUTILUS_STYLE_VARIANTS[i]}" ]]; then
nautilus_style="${NAUTILUS_STYLE_VARIANTS[i]}"; variant_found="true"; break
fi
done ;;
esac
if [[ "${variant_found}" == "false" && "${variant_found}" != "skip" ]]; then
case "${value_must_found}" in
must)
prompt -e "ERROR: Unrecognized '${display_param}' variant: '${value}'."; has_any_error="true" ;;
optional)
prompt -w "WARNING: '${display_param}' variant of '${value}' isn't recognized. We'll show a chooser dialog when possible"
need_dialog["${global_param}"]="true" ;;
esac
elif [[ "${allow_all_choice}" == "false" && "${value}" == "all" ]]; then
prompt -e "ERROR: Can't choose all '${display_param}' variants."; has_any_error="true"
fi
has_set["${global_param}"]="true"; return 0
fi
}
avoid_variant_duplicates() {
colors=($(printf "%s\n" "${colors[@]}" | sort -u))
opacities=($(printf "%s\n" "${opacities[@]}" | sort -u))
alts=($(printf "%s\n" "${alts[@]}" | sort -u))
themes=($(printf "%s\n" "${themes[@]}" | sort -u))
}
# 'finalize_argument_parsing' is in the 'MISC' section
###############################################################################
# FILES #
###############################################################################
restore_file() {
if [[ -f "${1}.bak" || -d "${1}.bak" ]]; then
case "${2}" in
sudo)
sudo rm -rf "${1}"; sudo mv "${1}"{".bak",""} ;;
udo)
udo rm -rf "${1}"; udo mv "${1}"{".bak",""} ;;
*)
rm -rf "${1}"; mv "${1}"{".bak",""} ;;
esac
fi
}
backup_file() {
if [[ -f "${1}" || -d "${1}" ]]; then
case "${2}" in
sudo)
sudo mv -n "${1}"{"",".bak"} ;;
udo)
udo mv -n "${1}"{"",".bak"} ;;
*)
mv -n "${1}"{"",".bak"} ;;
esac
fi
}
udoify_file() {
if [[ -f "${1}" && "$(ls -ld "${1}" | awk '{print $3}')" != "${MY_USERNAME}" ]]; then
sudo chown "${MY_USERNAME}:" "${1}"
fi
}
check_theme_file() {
[[ -f "${1}" || -f "${1}.bak" ]]
}
remind_relative_path() {
[[ "${2}" =~ "~" ]] && prompt -w "'${1}' REMEMBER: ~/'path to somewhere' and '~/path to somewhere' are different."
}
###############################################################################
# MISC #
###############################################################################
sudo() {
local result="0"
prompt -w "Executing '$(echo "${@}" | cut -c -35 )...' as root"
if ! ${SUDO_BIN} -n true &> /dev/null; then
echo -e "\n ${c_magenta} Authentication is required${c_default} ${c_green}(Please input your password):${c_default} \n"
fi
if [[ -p /dev/stdin ]]; then
${SUDO_BIN} "${@}" < /dev/stdin || result="${?}"
else
${SUDO_BIN} "${@}" || result="${?}"
fi
[[ "${result}" != "0" ]] && WHITESUR_COMMAND="${*}"
return "${result}"
}
udo() {
local result="0"
# Just in case. We put the prompt here to make it less annoying
if ! ${SUDO_BIN} -u "${MY_USERNAME}" -n true &> /dev/null; then
prompt -w "Executing '$(echo "${@}" | cut -c -35 )...' as user"
echo -e "${c_magenta} Authentication is required${c_default} ${c_green}(Please input your password):${c_default}"
fi
if [[ -p /dev/stdin ]]; then
${SUDO_BIN} -u "${MY_USERNAME}" "${@}" < /dev/stdin || result="${?}"
else
${SUDO_BIN} -u "${MY_USERNAME}" "${@}" || result="${?}"
fi
[[ "${result}" != "0" ]] && WHITESUR_COMMAND="${*}"
return "${result}"
}
full_sudo() {
if [[ ! -w "/root" ]]; then
prompt -e "ERROR: '${1}' needs a root priviledge. Please run this '${0}' as root"
has_any_error="true"
fi
}
get_utc_epoch_time() {
local time=""
local epoch=""
if exec 3<> "/dev/tcp/iana.org/80"; then
echo -e "GET / HTTP/1.1\nHost: iana.org\n\n" >&3
while read -r -t 2 line 0<&3; do
if [[ "${line}" =~ "Date:" ]]; then
time="${line#*':'}"; exec 3<&-; break
fi
done
exec 3<&-
if [[ "${time}" ]]; then
epoch="$(date -d "${time}" "+%s")"
echo "$((epoch + 2))"
else
return 1
fi
else
exec 3<&-; return 1
fi
}
usage() {
prompt -e "Usage function is not implemented"; exit 1
}
finalize_argument_parsing() {
if [[ "${need_help}" == "true" ]]; then
echo; usage; echo
[[ "${has_any_error}" == "true" ]] && exit 1 || exit 0
elif [[ "${has_any_error}" == "true" ]]; then
echo; prompt -i "Try '$0 --help' for more information."; echo; exit 1
fi
}

111
shell/lib-flatpak.sh Executable file
View File

@@ -0,0 +1,111 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
pakitheme_gtk3() {
local color="$(destify ${1})"
local opacity="$(destify ${2})"
local alt="$(destify ${3})"
local theme="$(destify ${4})"
local FLATPAK_THEME="${name}${color}${opacity}${alt}${theme}${colorscheme}"
local GTK_3_THEME_VER=3.22
local cache_home="${XDG_CACHE_HOME:-$HOME/.cache}"
local data_home="${XDG_DATA_HOME:-$HOME/.local/share}"
local pakitheme_cache="$cache_home/pakitheme"
local repo_dir="$pakitheme_cache/repo"
local gtk3_app_id="org.gtk.Gtk3theme.$FLATPAK_THEME"
local root_dir="$pakitheme_cache/$FLATPAK_THEME"
local repo_dir="$root_dir/repo"
local build_dir="$root_dir/build"
for location in "$data_home/themes" "$HOME/.themes" /usr/share/themes; do
if [[ -d "$location/$FLATPAK_THEME" ]]; then
prompt -s "Found theme located at: $location/$FLATPAK_THEME \n"
theme_path="$location/$FLATPAK_THEME"
break
fi
done
if [[ -n "$theme_path" ]]; then
prompt -i "Converting theme: $FLATPAK_THEME... \n"
else
prompt -e "Could not locate theme... install theme first! \n"
exit 0
fi
rm -rf "$root_dir" "$repo_dir"
mkdir -p "$repo_dir"
ostree --repo="$repo_dir" init --mode=archive
ostree --repo="$repo_dir" config set core.min-free-space-percent 0
rm -rf "$build_dir"
mkdir -p "$build_dir/files"
cp -a "$theme_path/gtk-3.0/"* "$build_dir/files"
mkdir -p "$build_dir/files/share/appdata"
cat >"$build_dir/files/share/appdata/$gtk3_app_id.appdata.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<component type="runtime">
<id>$gtk3_app_id</id>
<metadata_license>CC0-1.0</metadata_license>
<name>$FLATPAK_THEME Gtk theme</name>
<summary>$FLATPAK_THEME Gtk theme for flatpak</summary>
</component>
EOF
appstream-compose --prefix="$build_dir/files" --basename="$gtk3_app_id" --origin=flatpak "$gtk3_app_id"
ostree --repo="$repo_dir" commit -b base --tree=dir="$build_dir"
bundles=()
while read -r arch; do
bundle="$root_dir/$gtk3_app_id-$arch.flatpak"
rm -rf "$build_dir"
ostree --repo="$repo_dir" checkout -U base "$build_dir"
read -rd '' metadata <<EOF ||:
[Runtime]
name=$gtk3_app_id
runtime=$gtk3_app_id/$arch/$GTK_3_THEME_VER
sdk=$gtk3_app_id/$arch/$GTK_3_THEME_VER
EOF
# Make sure there is no trailing newline, so xa.metadata doesn't get confused later
echo -n "$metadata" > "$build_dir/metadata"
ostree --repo="$repo_dir" commit -b "runtime/$gtk3_app_id/$arch/$GTK_3_THEME_VER" \
--add-metadata-string "xa.metadata=$(cat $build_dir/metadata)" --link-checkout-speedup "$build_dir"
flatpak build-bundle --runtime "$repo_dir" "$bundle" "$gtk3_app_id" "$GTK_3_THEME_VER"
trap 'rm "$bundle"' EXIT
bundles+=("$bundle")
# Note: a pipe can't be used because it will mess with subshells and cause the append
# to bundles to fail.
done < <(flatpak list --runtime --columns=arch:f | sort -u)
for bundle in "${bundles[@]}"; do
if [[ -w "/root" ]]; then
sudo flatpak install -y --system "${bundle}"
else
flatpak install -y --user "${bundle}"
fi
done
}
flatpak_remove() {
local color="$(destify ${1})"
local opacity="$(destify ${2})"
local alt="$(destify ${3})"
local theme="$(destify ${4})"
if [[ -w "/root" ]]; then
sudo flatpak remove -y --system org.gtk.Gtk3theme.${name}${color}${opacity}${alt}${theme}${colorscheme}
else
flatpak remove -y --user org.gtk.Gtk3theme.${name}${color}${opacity}${alt}${theme}${colorscheme}
fi
}

976
shell/lib-install.sh Executable file
View File

@@ -0,0 +1,976 @@
# WARNING: Please make this shell not working-directory dependant, for example
# instead of using 'ls blabla', use 'ls "${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 )
###############################################################################
# VARIABLES #
###############################################################################
source "${REPO_DIR}/shell/lib-core.sh"
source "${REPO_DIR}/shell/lib-flatpak.sh"
WHITESUR_SOURCE+=("lib-install.sh")
###############################################################################
# DEPENDENCIES #
###############################################################################
# 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!
#----------------------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
#--------------------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
#--------------------OTHERS--------------------#
# Sometimes, some Ubuntu distro doesn't enable automatic time. This can cause
# 'Release file for ... is not valid yet'. This may also happen on other distros
#============================================#
#-------------------Prepare------------------#
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
}
prepare_deps() {
local remote_time=""
local local_time=""
prompt -i "DEPS: Checking your internet connection..."
local_time="$(date -u "+%s")"
if ! remote_time="$(get_utc_epoch_time)"; then
prompt -e "DEPS ERROR: You have an internet connection issue\n"; exit 1
fi
# 5 minutes is the maximum reasonable time delay, so we choose '4' here just
# in case
if (( local_time < remote_time-(4*60) )); then
prompt -w "DEPS: Your system clock is wrong"
prompt -i "DEPS: Updating your system clock..."
# Add "+ 25" here to accomodate potential time delay by sudo prompt
sudo date -s "@$((remote_time + 25))"; sudo hwclock --systohc
fi
}
prepare_swupd() {
[[ "${swupd_prepared}" == "true" ]] && return 0
local remove=""
local ver=""
local conf=""
local dist=""
if has_command dnf; then
prompt -w "CLEAR LINUX: You have 'dnf' installed in your system. It may break your system especially when you remove a package"
confirm remove "CLEAR LINUX: You wanna remove it?"; echo
fi
if ! sudo swupd update -y; then
ver="$(curl -s -o - "${swupd_ver_url}")"
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}"
prompt -w "\n CLEAR LINUX: Your 'swupd' is broken"
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"
sudo swupd update -y
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"
}
install_swupd_packages() {
if [[ ! "${swupd_packages}" ]]; then
swupd_packages="$(curl -s -o - "${swupd_url}" | awk -F '"' '/-bin-|-lib-/{print $2}')"
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 "/"
done
done
}
prepare_install_apt_packages() {
local status="0"
sudo apt update -y; sudo apt install -y "${@}" || status="${?}"
if [[ "${status}" == "100" ]]; then
prompt -w "\n APT: Your repo lists might be broken"
prompt -i "APT: Full-cleaning your repo lists and try again...\n"
sudo apt clean -y; sudo rm -rf /var/lib/apt/lists
sudo apt update -y; sudo apt install -y "${@}"
fi
}
prepare_xbps() {
[[ "${xbps_prepared}" == "true" ]] && return 0
# 'xbps-install' requires 'xbps' to be always up-to-date
sudo xbps-install -Syu xbps
# 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"
}
#-----------------Deps-----------------#
install_theme_deps() {
if ! has_command sassc; then
prompt -w "DEPS: 'sassc' are required for theme installation."
prepare_deps
if has_command zypper; then
sudo zypper in -y sassc
elif has_command swupd; then
prepare_swupd && install_swupd_packages sassc libsass
elif has_command apt; then
prepare_install_apt_packages sassc
elif has_command dnf; then
sudo dnf install -y sassc
elif has_command yum; then
sudo yum install -y sassc
elif has_command pacman; then
sudo pacman -Syyu --noconfirm --needed sassc
elif has_command xbps-install; then
prepare_xbps && sudo xbps-install -Sy sassc
elif has_command eopkg; then
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
else
installation_sorry
fi
fi
}
install_beggy_deps() {
if ! has_command convert; then
prompt -w "DEPS: 'imagemagick' is required for background editing."
prepare_deps; stop_animation
if has_command zypper; then
sudo zypper in -y ImageMagick
elif has_command swupd; then
prepare_swupd && sudo swupd bundle-add ImageMagick
elif has_command apt; then
prepare_install_apt_packages imagemagick
elif has_command dnf; then
sudo dnf install -y ImageMagick
elif has_command yum; then
sudo yum install -y ImageMagick
elif has_command pacman; then
sudo pacman -Syyu --noconfirm --needed imagemagick
elif has_command xbps-install; then
prepare_xbps && sudo xbps-install -Sy ImageMagick
elif has_command eopkg; then
sudo eopkg -y upgrade; sudo eopkg -y install imagemagick
else
installation_sorry
fi
fi
}
install_dialog_deps() {
[[ "${silent_mode}" == "true" ]] && return 0
if ! has_command dialog; then
prompt -w "DEPS: 'dialog' is required for this option."
prepare_deps
if has_command zypper; then
sudo zypper in -y dialog
elif has_command swupd; then
prepare_swupd && install_swupd_packages dialog
elif has_command apt; then
prepare_install_apt_packages dialog
elif has_command dnf; then
sudo dnf install -y dialog
elif has_command yum; then
sudo yum install -y dialog
elif has_command pacman; then
sudo pacman -Syyu --noconfirm --needed dialog
elif has_command xbps-install; then
prepare_xbps && sudo xbps-install -Sy dialog
elif has_command eopkg; then
sudo eopkg -y upgrade; sudo eopkg -y install dialog
else
installation_sorry
fi
fi
}
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
sudo zypper in -y libostree appstream-glib
elif has_command swupd; then
prepare_swupd && sudo swupd ostree libappstream-glib
elif has_command apt; then
prepare_install_apt_packages ostree appstream-util
elif has_command dnf; then
sudo dnf install -y ostree libappstream-glib
elif has_command yum; then
sudo yum install -y ostree libappstream-glib
elif has_command pacman; then
sudo pacman -Syyu --noconfirm --needed ostree appstream-glib
elif has_command xbps-install; then
prepare_xbps && sudo xbps-install -Sy ostree appstream-glib
elif has_command eopkg; then
sudo eopkg -y upgrade; sudo eopkg -y ostree appstream-glib
else
installation_sorry
fi
fi
}
###############################################################################
# THEME MODULES #
###############################################################################
install_beggy() {
local CONVERT_OPT=""
[[ "${no_blur}" == "false" ]] && CONVERT_OPT+=" -scale 1280x -blur 0x50 "
[[ "${no_darken}" == "false" ]] && CONVERT_OPT+=" -fill black -colorize 45% "
case "${background}" in
blank)
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-blank.png" "${WHITESUR_TMP_DIR}/beggy.png" ;;
default)
if [[ "${no_blur}" == "false" && "${no_darken}" == "true" ]]; then
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-blur.png" "${WHITESUR_TMP_DIR}/beggy.png"
elif [[ "${no_blur}" == "false" && "${no_darken}" == "false" ]]; then
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-blur-darken.png" "${WHITESUR_TMP_DIR}/beggy.png"
elif [[ "${no_blur}" == "true" && "${no_darken}" == "true" ]]; then
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-default.png" "${WHITESUR_TMP_DIR}/beggy.png"
else
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/common-assets/background-darken.png" "${WHITESUR_TMP_DIR}/beggy.png"
fi
;;
*)
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
;;
esac
}
install_xfwmy() {
local color="$(destify ${1})"
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"
mkdir -p "${TARGET_DIR}/xfwm4"
cp -r "${THEME_SRC_DIR}/assets/xfwm4/assets${color}${colorscheme}/"*".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}${colorscheme}-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}${colorscheme}-xhdpi/"*".png" "${XHDPI_TARGET_DIR}/xfwm4"
cp -r "${THEME_SRC_DIR}/main/xfwm4/themerc${color}" "${XHDPI_TARGET_DIR}/xfwm4/themerc"
}
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}${colorscheme}/gnome-shell"
else
TARGET_DIR="${6}"
fi
if [[ "${GNOME_VERSION}" == 'none' ]]; then
local GNOME_VERSION='42-0'
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}"
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gnome-shell/shell-${GNOME_VERSION}/gnome-shell${color}.scss" "${TARGET_DIR}/gnome-shell.css"
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"
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/theme${theme}${colorscheme}/"*".svg" "${TARGET_DIR}/assets"
cp -r "${THEME_SRC_DIR}/assets/gnome-shell/activities/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"
cp -r "${WHITESUR_TMP_DIR}/beggy.png" "${TARGET_DIR}/assets/background.png"
(
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 [[ "${black_font:-}" == 'true' || "${opacity}" == '-solid' ]] && [[ "${color}" == '-Light' ]]; then
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})"
if [[ "${color}" == '-Light' ]]; then
local iconcolor=''
elif [[ "${color}" == '-Dark' ]]; then
local iconcolor='-Dark'
fi
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}"
mkdir -p "${TARGET_DIR}"
local desktop_entry="[Desktop Entry]\n"
desktop_entry+="Type=X-GNOME-Metatheme\n"
desktop_entry+="Name=${name}${color}${opacity}${alt}${theme}${colorscheme}\n"
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"
desktop_entry+="GtkTheme=${name}${color}${opacity}${alt}${theme}${colorscheme}\n"
desktop_entry+="MetacityTheme=${name}${color}${opacity}${alt}${theme}${colorscheme}\n"
desktop_entry+="IconTheme=${name}${iconcolor}\n"
desktop_entry+="CursorTheme=WhiteSur-cursors\n"
desktop_entry+="ButtonLayout=close,minimize,maximize:menu\n"
echo -e "${desktop_entry}" > "${TARGET_DIR}/index.theme"
#--------------------GTK-3.0--------------------#
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/scalable" "${TMP_DIR_T}/assets"
cp -r "${THEME_SRC_DIR}/assets/gtk/windows-assets/titlebutton${alt}${colorscheme}" "${TMP_DIR_T}/windows-assets"
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"
mkdir -p "${TARGET_DIR}/gtk-3.0"
cp -r "${THEME_SRC_DIR}/assets/gtk/thumbnails/thumbnail${color}${theme}${colorscheme}.png" "${TARGET_DIR}/gtk-3.0/thumbnail.png"
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"
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}"
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"
mkdir -p "${TARGET_DIR}/gtk-4.0"
cp -r "${THEME_SRC_DIR}/assets/gtk/thumbnails/thumbnail${color}${theme}${colorscheme}.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"
#----------------Cinnamon-----------------#
mkdir -p "${TARGET_DIR}/cinnamon"
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/cinnamon/cinnamon${color}.scss" "${TARGET_DIR}/cinnamon/cinnamon.css"
cp -r "${THEME_SRC_DIR}/assets/cinnamon/common-assets" "${TARGET_DIR}/cinnamon/assets"
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"
cp -r "${THEME_SRC_DIR}/assets/cinnamon/thumbnails/thumbnail${color}${theme}${colorscheme}.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}${colorscheme}" "${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-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"
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/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"
( 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})${colorscheme}"
rm -rf "${dest}/${name}$(destify ${1})${colorscheme}-hdpi"
rm -rf "${dest}/${name}$(destify ${1})${colorscheme}-xhdpi"
}
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"
}
###############################################################################
# LIBADWAITA #
###############################################################################
config_gtk4() {
local color="$(destify ${1})"
local alt="$(destify ${2})"
local TARGET_DIR="${HOME}/.config/gtk-4.0"
# Install gtk4.0 into config for libadwaita
mkdir -p "${TARGET_DIR}"
rm -rf "${TARGET_DIR}/"{gtk.css,gtk-dark.css,assets,windows-assets}
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-4.0/gtk${color}.scss" "${TARGET_DIR}/gtk.css"
sassc ${SASSC_OPT} "${THEME_SRC_DIR}/main/gtk-4.0/gtk-Dark.scss" "${TARGET_DIR}/gtk-dark.css"
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"
}
install_libadwaita() {
opacity="${opacities[0]}"
color="${colors[1]}"
gtk_base "${opacities[0]}" "${themes[0]}"
config_gtk4 "${colors}" "${alts}"
}
remove_libadwaita() {
rm -rf "${HOME}/.config/gtk-4.0/"{gtk.css,gtk-dark.css,assets,windows-assets}
}
###############################################################################
# THEMES #
###############################################################################
install_themes() {
# "install_theemy" and "install_shelly" require "gtk_base", so multithreading
# isn't possible
install_theme_deps; start_animation; install_beggy
for opacity in "${opacities[@]}"; do
for alt in "${alts[@]}"; do
for theme in "${themes[@]}"; do
for color in "${colors[@]}"; do
gtk_base "${opacity}" "${theme}" "${compact}"
install_theemy "${color}" "${opacity}" "${alt}" "${theme}"
install_shelly "${color}" "${opacity}" "${alt}" "${theme}" "${icon}"
install_xfwmy "${color}"
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
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
wait ${process_ids[*]} &> /dev/null
}
install_gdm_theme() {
local TARGET=
# Let's go!
install_theme_deps
rm -rf "${WHITESUR_GS_DIR}"; install_beggy
gtk_base "${colors[0]}" "${opacities[0]}" "${themes[0]}"
if check_theme_file "${COMMON_CSS_FILE}"; then # CSS-based theme
install_shelly "${colors[0]}" "${opacities[0]}" "${alts[0]}" "${themes[0]}" "${icon}" "${WHITESUR_GS_DIR}"
sed $SED_OPT "s|assets|${WHITESUR_GS_DIR}/assets|" "${WHITESUR_GS_DIR}/gnome-shell.css"
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
install_shelly "${colors[0]}" "${opacities[0]}" "${alts[0]}" "${themes[0]}" "${icon}" "${WHITESUR_TMP_DIR}/shelly"
sed $SED_OPT "s|assets|resource:///org/gnome/shell/theme/assets|" "${WHITESUR_TMP_DIR}/shelly/gnome-shell.css"
if check_theme_file "$POP_OS_GR_FILE"; then
TARGET="${POP_OS_GR_FILE}"
elif check_theme_file "$YARU_GR_FILE"; then
TARGET="${YARU_GR_FILE}"
elif check_theme_file "$ZORIN_GR_FILE"; then
TARGET="${ZORIN_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
}
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}"
restore_file "${ZORIN_GR_FILE}"
}
###############################################################################
# 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
remove_firefox_theme
udo mkdir -p "${TARGET_DIR}"
udo cp -rf "${FIREFOX_SRC_DIR}"/customChrome.css "${TARGET_DIR}"
if [[ "${monterey}" == 'true' ]]; then
udo cp -rf "${FIREFOX_SRC_DIR}"/Monterey "${TARGET_DIR}"
udo cp -rf "${FIREFOX_SRC_DIR}"/WhiteSur/{icons,titlebuttons} "${TARGET_DIR}"/Monterey
if [[ "${alttheme}" == 'true' ]]; then
udo cp -rf "${FIREFOX_SRC_DIR}"/userChrome-Monterey-alt.css "${TARGET_DIR}"/userChrome.css
else
udo cp -rf "${FIREFOX_SRC_DIR}"/userChrome-Monterey.css "${TARGET_DIR}"/userChrome.css
fi
else
udo cp -rf "${FIREFOX_SRC_DIR}"/WhiteSur "${TARGET_DIR}"
udo cp -rf "${FIREFOX_SRC_DIR}"/userChrome-WhiteSur.css "${TARGET_DIR}"/userChrome.css
fi
config_firefox
}
config_firefox() {
# if has_snap_app firefox; then
# local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}"
# local FIREFOX_DIR="${FIREFOX_SNAP_DIR_HOME}"
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
killall "firefox" "firefox-bin" &> /dev/null || true
for d in "${FIREFOX_DIR}/"*"default"*; do
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"
fi
done
}
edit_firefox_theme_prefs() {
# if has_snap_app firefox; then
# local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}"
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
udo ${EDITOR:-nano} "${TARGET_DIR}/userChrome.css"
udo ${EDITOR:-nano} "${TARGET_DIR}/customChrome.css"
}
remove_firefox_theme() {
rm -rf "${FIREFOX_DIR_HOME}/"*"default"*"/chrome"
rm -rf "${FIREFOX_THEME_DIR}"
rm -rf "${FIREFOX_FLATPAK_DIR_HOME}/"*"default"*"/chrome"
rm -rf "${FIREFOX_FLATPAK_THEME_DIR}"
rm -rf "${FIREFOX_SNAP_DIR_HOME}/"*"default"*"/chrome"
rm -rf "${FIREFOX_SNAP_THEME_DIR}"
}
###############################################################################
# DASH TO DOCK #
###############################################################################
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}"
if has_command dbus-launch; then
udo dbus-launch dconf write /org/gnome/shell/extensions/dash-to-dock/apply-custom-theme true
fi
}
install_dash_to_dock_theme() {
gtk_base "${colors[0]}" "${opacities[0]}" "${themes[0]}"
if [[ -d "${DASH_TO_DOCK_DIR_HOME}" ]]; then
backup_file "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css" "udo"
udoify_file "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
if [[ "${GNOME_VERSION}" != '3-28' ]]; then
udo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-4.scss" "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
else
udo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-3.scss" "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
fi
elif [[ -d "${DASH_TO_DOCK_DIR_ROOT}" ]]; then
backup_file "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css" "sudo"
if [[ "${GNOME_VERSION}" != '3-28' ]]; then
sudo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-4.scss" "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css"
else
sudo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-3.scss" "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css"
fi
fi
if has_command dbus-launch; then
udo dbus-launch dconf write /org/gnome/shell/extensions/dash-to-dock/apply-custom-theme true
fi
}
revert_dash_to_dock_theme() {
if [[ -d "${DASH_TO_DOCK_DIR_HOME}" ]]; then
restore_file "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css" "udo"
elif [[ -d "${DASH_TO_DOCK_DIR_ROOT}" ]]; then
restore_file "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css" "sudo"
fi
if has_command dbus-launch; then
udo dbus-launch dconf write /org/gnome/shell/extensions/dash-to-dock/apply-custom-theme false
fi
}
###############################################################################
# FLATPAK & SNAP #
###############################################################################
connect_flatpak() {
install_flatpak_deps
for opacity in "${opacities[@]}"; do
for alt in "${alts[@]}"; do
for theme in "${themes[@]}"; do
for color in "${colors[@]}"; do
pakitheme_gtk3 "${color}" "${opacity}" "${alt}" "${theme}"
done
done
done
done
}
disconnect_flatpak() {
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
}
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
}
#########################################################################
# GTK BASE #
#########################################################################
gtk_base() {
cp -rf "${THEME_SRC_DIR}/sass/_gtk-base"{".scss","-temp.scss"}
# Theme base options
if [[ "${compact}" == 'false' ]]; then
sed $SED_OPT "/\$laptop/s/true/false/" "${THEME_SRC_DIR}/sass/_gtk-base-temp.scss"
fi
if [[ "${opacity}" == 'solid' ]]; then
sed $SED_OPT "/\$trans/s/true/false/" "${THEME_SRC_DIR}/sass/_gtk-base-temp.scss"
fi
if [[ "${theme}" != '' ]]; then
sed $SED_OPT "/\$theme/s/default/${theme}/" "${THEME_SRC_DIR}/sass/_gtk-base-temp.scss"
fi
}
###############################################################################
# CUSTOMIZATIONS #
###############################################################################
customize_theme() {
cp -rf "${THEME_SRC_DIR}/sass/_theme-options"{".scss","-temp.scss"}
# Darker dark colors
if [[ "${colorscheme}" == '-nord' ]]; then
prompt -s "Changing color scheme style to nord style ...\n"
sed $SED_OPT "/\$colorscheme/s/default/nord/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Darker dark colors
if [[ "${darker}" == 'true' ]]; then
prompt -s "Changing dark color style to darker one ...\n"
sed $SED_OPT "/\$darker/s/false/true/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Change Nautilus sidarbar size
if [[ "${sidebar_size}" != 'default' ]]; then
prompt -s "Changing Nautilus sidebar size ...\n"
sed $SED_OPT "/\$sidebar_size/s/200px/${sidebar_size}px/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Change Nautilus style
if [[ "${nautilus_style}" != 'stable' ]]; then
prompt -s "Changing Nautilus style ...\n"
sed $SED_OPT "/\$nautilus_style/s/stable/${nautilus_style}/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Change Nautilus titlebutton placement style
if [[ "${right_placement}" == 'true' ]]; then
prompt -s "Changing Nautilus titlebutton placement style ...\n"
sed $SED_OPT "/\$placement/s/left/right/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Change maximized window radius
if [[ "${max_round}" == 'true' ]]; then
prompt -s "Changing maximized window style ...\n"
sed $SED_OPT "/\$max_window_style/s/square/round/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Change gnome-shell panel transparency
if [[ "${panel_opacity}" != 'default' ]]; then
prompt -s "Changing panel transparency ...\n"
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
prompt -s "Changing panel height size to '${panel_size}'...\n"
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
prompt -s "Changing gnome-shell show apps button style ...\n"
sed $SED_OPT "/\$showapps_button/s/bigsur/normal/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
# Change panel font color
if [[ "${monterey}" == 'true' ]]; then
black_font="true"
prompt -s "Changing to Monterey style ...\n"
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
prompt -s "Changing panel font color ...\n"
sed $SED_OPT "/\$panel_font/s/white/black/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
if [[ "${compact}" == 'false' ]]; then
prompt -s "Changing Definition mode to HD (Bigger font, Bigger size) ..."
#FIXME: @vince is it not implemented yet? (Only Gnome-shell and Gtk theme finished!)
fi
if [[ "${scale}" == 'x2' ]]; then
prompt -s "Changing GDM scaling to 200% ...\n"
sed $SED_OPT "/\$scale/s/default/x2/" "${THEME_SRC_DIR}/sass/_theme-options-temp.scss"
fi
}
#-----------------------------------DIALOGS------------------------------------#
# The default values here should get manually set and updated. Some of default
# values are taken from _variables.scss
show_panel_opacity_dialog() {
install_dialog_deps
dialogify panel_opacity "${THEME_NAME}" "Choose your panel opacity (Default is 15)" ${PANEL_OPACITY_VARIANTS[*]}
}
show_sidebar_size_dialog() {
install_dialog_deps
dialogify sidebar_size "${THEME_NAME}" "Choose your Nautilus minimum sidebar size (default is 200px)" ${SIDEBAR_SIZE_VARIANTS[*]}
}
show_nautilus_style_dialog() {
install_dialog_deps
dialogify nautilus_style "${THEME_NAME}" "Choose your Nautilus style (default is BigSur-like style)" ${NAUTILUS_STYLE_VARIANTS[*]}
}
show_needed_dialogs() {
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
}