Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceliuice committed Dec 2, 2022
1 parent 86144b7 commit b625857
Show file tree
Hide file tree
Showing 40 changed files with 850 additions and 108 deletions.
193 changes: 142 additions & 51 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,69 +269,148 @@ uninstall() {
[[ -d "$THEME_DIR" ]] && rm -rf "$THEME_DIR" && echo -e "Uninstalling "$THEME_DIR" ..."
}

# Backup and install files related to GDM theme
GS_THEME_FILE="/usr/share/gnome-shell/gnome-shell-theme.gresource"
UBUNTU_THEME_FILE="/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource"
POP_OS_THEME_FILE="/usr/share/gnome-shell/theme/Pop/gnome-shell-theme.gresource"
ZORIN_THEME_FILE="/usr/share/gnome-shell/theme/ZorinBlue-Light/gnome-shell-theme.gresource"
# GDM Theme

install_gdm() {
local GDM_THEME_DIR="${1}/${2}${3}${4}"

if [[ -f "$GS_THEME_FILE" ]] && command -v glib-compile-resources >/dev/null ; then
echo "Installing '$GS_THEME_FILE'..."
cp -an "$GS_THEME_FILE" "$GS_THEME_FILE.bak"
glib-compile-resources \
--sourcedir="$GDM_THEME_DIR/gnome-shell" \
--target="$GS_THEME_FILE" \
"${SRC_DIR}/src/gnome-shell/gnome-shell-theme.gresource.xml"
fi
check_exist() {
[[ -f "${1}" || -f "${1}.bak" ]]
}

if [[ -f "$UBUNTU_THEME_FILE" ]]; then
echo "Installing '$UBUNTU_THEME_FILE'..."
cp -an "$UBUNTU_THEME_FILE" "$UBUNTU_THEME_FILE.bak"
cp -rf "$GS_THEME_FILE" "$UBUNTU_THEME_FILE"
restore_file() {
if [[ -f "${1}.bak" || -d "${1}.bak" ]]; then
rm -rf "${1}"; mv "${1}"{".bak",""}
fi
}

if [[ -f "$POP_OS_THEME_FILE" ]]; then
echo "Installing '$POP_OS_THEME_FILE'..."
cp -an "$POP_OS_THEME_FILE" "$POP_OS_THEME_FILE.bak"
cp -rf "$GS_THEME_FILE" "$POP_OS_THEME_FILE"
backup_file() {
if [[ -f "${1}" || -d "${1}" ]]; then
mv -n "${1}"{"",".bak"}
fi
}

if [[ -f "$ZORIN_THEME_FILE" ]]; then
echo "Installing '$ZORIN_THEME_FILE'..."
cp -an "$ZORIN_THEME_FILE" "$ZORIN_THEME_FILE.bak"
cp -rf "$GS_THEME_FILE" "$ZORIN_THEME_FILE"
install_gdm_deps() {
if ! has_command glib-compile-resources; then
echo -e "\n'glib2.0' are required for theme installation."

if has_command zypper; then
sudo zypper in -y glib2-devel
elif has_command swupd; then
sudo swupd bundle-add libglib
elif has_command apt; then
sudo apt install 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
sudo xbps-install -Sy glib-devel
elif has_command eopkg; then
sudo eopkg -y install glib2
else
echo -e "\nWARNING: We're sorry, your distro isn't officially supported yet.\n"
fi
fi
}

revert_gdm() {
if [[ -f "$GS_THEME_FILE.bak" ]]; then
echo "reverting '$GS_THEME_FILE'..."
rm -rf "$GS_THEME_FILE"
mv "$GS_THEME_FILE.bak" "$GS_THEME_FILE"
fi
GS_THEME_DIR="/usr/share/gnome-shell/theme"
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="${SRC_DIR}/src/gnome-shell/gnome-shell-theme.gresource.xml"

if [[ -f "$UBUNTU_THEME_FILE.bak" ]]; then
echo "reverting '$UBUNTU_THEME_FILE'..."
rm -rf "$UBUNTU_THEME_FILE"
mv "$UBUNTU_THEME_FILE.bak" "$UBUNTU_THEME_FILE"
install_gdm() {
local name="${1}"
local theme="${2}"
local gcolor="${3}"
local icon="${4}"
local TARGET=

[[ "${gcolor}" == '-Light' ]] && local ELSE_LIGHT="${gcolor}"
[[ "${gcolor}" == '-Dark' ]] && local ELSE_DARK="${gcolor}"

local THEME_TEMP="/tmp/${1}${2}${3}"

theme_tweaks && install_gdm_deps && install_theme_color

echo -e "\nInstall ${1}${2}${3} GDM Theme..."

rm -rf "${THEME_TEMP}"
mkdir -p "${THEME_TEMP}/gnome-shell"
cp -r "${SRC_DIR}/src/gnome-shell/common-assets" "${THEME_TEMP}/gnome-shell/assets"
cp -r "${SRC_DIR}/src/gnome-shell/assets${theme}/"{background.jpg,calendar-today.svg} "${THEME_TEMP}/gnome-shell/assets"
cp -r "${SRC_DIR}/src/gnome-shell/assets${theme}/assets${ELSE_DARK}/"*.svg "${THEME_TEMP}/gnome-shell/assets"
mv "${THEME_TEMP}/gnome-shell/assets/"{process-working.svg,no-events.svg,no-notifications.svg} "${THEME_TEMP}/gnome-shell"

if [[ -f "${SRC_DIR}/src/gnome-shell/logos/logo-${icon}.svg" ]] ; then
cp -r "${SRC_DIR}/src/gnome-shell/logos/logo-${icon}.svg" "${THEME_TEMP}/gnome-shell/assets/activities.svg"
else
echo "${icon} icon not supported, Qogir icon will install..."
cp -r "${SRC_DIR}/src/gnome-shell/logos/logo-qogir.svg" "${THEME_TEMP}/gnome-shell/assets/activities.svg"
fi

if [[ -f "$POP_OS_THEME_FILE.bak" ]]; then
echo "reverting '$POP_OS_THEME_FILE'..."
rm -rf "$POP_OS_THEME_FILE"
mv "$POP_OS_THEME_FILE.bak" "$POP_OS_THEME_FILE"
cp -r "${SRC_DIR}/src/gnome-shell/icons" "${THEME_TEMP}/gnome-shell"
cp -r "${SRC_DIR}/src/gnome-shell/pad-osd.css" "${THEME_TEMP}/gnome-shell"

if [[ "$tweaks" == 'true' ]]; then
sassc $SASSC_OPT "${SRC_DIR}/src/gnome-shell/theme-${GS_VERSION}/gnome-shell${ELSE_DARK}.scss" "${THEME_TEMP}/gnome-shell/gnome-shell.css"
else
cp -r "${SRC_DIR}/src/gnome-shell/theme-${GS_VERSION}/gnome-shell${ELSE_DARK}.css" "${THEME_TEMP}/gnome-shell/gnome-shell.css"
fi

if [[ -f "$ZORIN_THEME_FILE.bak" ]]; then
echo "reverting '$ZORIN_THEME_FILE'..."
rm -rf "$ZORIN_THEME_FILE"
mv "$ZORIN_THEME_FILE.bak" "$ZORIN_THEME_FILE"
if check_exist "${COMMON_CSS_FILE}"; then # CSS-based theme
if check_exist "${UBUNTU_CSS_FILE}"; then
TARGET="${UBUNTU_CSS_FILE}"
elif check_exist "${ZORIN_CSS_FILE}"; then
TARGET="${ZORIN_CSS_FILE}"
fi

backup_file "${COMMON_CSS_FILE}"; backup_file "${TARGET}"

if check_exist "${GS_THEME_DIR}/${name}"; then
rm -rf "${GS_THEME_DIR}/${name}"
fi

cp -rf "${THEME_TEMP}/gnome-shell" "${GS_THEME_DIR}/${name}"
ln -sf "${GS_THEME_DIR}/${name}/gnome-shell.css" "${COMMON_CSS_FILE}"
ln -sf "${GS_THEME_DIR}/${name}/gnome-shell.css" "${TARGET}"

# Fix previously installed theme
restore_file "${ETC_CSS_FILE}"
else # GR-based theme
if check_exist "$POP_OS_GR_FILE"; then
TARGET="${POP_OS_GR_FILE}"
elif check_exist "$YARU_GR_FILE"; then
TARGET="${YARU_GR_FILE}"
elif check_exist "$ZORIN_GR_FILE"; then
TARGET="${ZORIN_GR_FILE}"
elif check_exist "$MISC_GR_FILE"; then
TARGET="${MISC_GR_FILE}"
fi

backup_file "${TARGET}"
glib-compile-resources --sourcedir="${THEME_TEMP}/gnome-shell" --target="${TARGET}" "${GS_GR_XML_FILE}"

# Fix previously installed theme
restore_file "${ETC_GR_FILE}"
fi
}

uninstall_gdm_theme() {
rm -rf "${GS_THEME_DIR}/$THEME_NAME"
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}"
}

while [[ $# -gt 0 ]]; do
case "${1}" in
-d|--dest)
Expand Down Expand Up @@ -401,16 +480,19 @@ while [[ $# -gt 0 ]]; do
standard)
colors+=("${COLOR_VARIANTS[0]}")
lcolors+=("${COLOR_VARIANTS[0]}")
gcolors+=("${COLOR_VARIANTS[0]}")
shift
;;
light)
colors+=("${COLOR_VARIANTS[1]}")
lcolors+=("${COLOR_VARIANTS[1]}")
gcolors+=("${COLOR_VARIANTS[1]}")
shift
;;
dark)
colors+=("${COLOR_VARIANTS[2]}")
lcolors+=("${COLOR_VARIANTS[2]}")
gcolors+=("${COLOR_VARIANTS[2]}")
shift
;;
-*|--*)
Expand Down Expand Up @@ -468,7 +550,7 @@ function has_command() {
command -v $1 > /dev/null
}

install_package() {
install_css_deps() {
if [ ! "$(which sassc 2> /dev/null)" ]; then
echo "\n sassc needs to be installed to generate the css."

Expand Down Expand Up @@ -587,7 +669,7 @@ install_theme_color() {
theme_tweaks() {
if [[ "$image" == "true" || "$square" == "true" || "$accent" == 'true' || "$window" == 'round' ]]; then
tweaks='true'
install_package; tweaks_temp
install_css_deps; tweaks_temp
fi

if [[ "$image" == "true" ]] ; then
Expand Down Expand Up @@ -655,19 +737,28 @@ if [[ "${gdm:-}" != 'true' && "${remove:-}" == 'true' ]]; then
fi

if [[ "${gdm:-}" == 'true' && "${remove:-}" != 'true' && "$UID" -eq "$ROOT_UID" ]]; then
if [[ "${#colors[@]}" -gt 1 ]]; then
if [[ "${#gcolors[@]}" -gt 1 ]]; then
echo 'Error: To install a gdm theme you can only select one color'
exit 1
fi
if [[ "${#themes[@]}" -gt 1 ]]; then
echo 'Error: To install a gdm theme you can only select one theme'
exit 1
fi
install_gdm "${dest:-${DEST_DIR}}" "${name:-${THEME_NAME}}" "${themes[0]}" "${colors[0]}"
for theme in "${themes[@]-${THEME_VARIANTS[0]}}"; do
for gcolor in "${gcolors[@]-${COLOR_VARIANTS[2]}}"; do
install_gdm "${name:-${THEME_NAME}}" "${theme}" "${gcolor}" "${icon:-${ICON_NAME}}"
done
done
fi

if [[ "${gdm:-}" == 'true' && "${remove:-}" == 'true' && "$UID" -eq "$ROOT_UID" ]]; then
revert_gdm
uninstall_gdm_theme
fi

if [[ "${gdm:-}" == 'true' && "$UID" != "$ROOT_UID" ]]; then
echo 'Error: need run it with sudo !'
exit 0
fi

echo -e "\nDone.\n"
4 changes: 3 additions & 1 deletion src/_sass/gnome-shell/widgets-42-0/_app-grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
}

.page-navigation-arrow {
& > StIcon {
border-radius: 100%;

> StIcon {
margin: 6px;
padding: 18px;
width: 24px;
Expand Down
2 changes: 1 addition & 1 deletion src/_sass/gnome-shell/widgets-common/_entries.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Entries */

StEntry {
padding: 7px;
padding: 8px;
caret-size: 1px;
caret-color: $fg_color;
selection-background-color: $selected_bg_color;
Expand Down
Loading

0 comments on commit b625857

Please sign in to comment.