Skip to content

Commit

Permalink
updated code to whitesur 120921 a0730b0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aryan20 committed Sep 12, 2021
1 parent bc7fca7 commit 47ed033
Show file tree
Hide file tree
Showing 103 changed files with 1,659 additions and 14,466 deletions.
3 changes: 2 additions & 1 deletion lib-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ else
fi

#----------Program options-------------#
SASSC_OPT="-M -t expanded"
SASSC_OPT="-t expanded"

if [[ "$(uname -s)" =~ "BSD" || "$(uname -s)" == "Darwin" ]]; then
SED_OPT="-i """
Expand Down Expand Up @@ -75,6 +75,7 @@ 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"

Expand Down
60 changes: 39 additions & 21 deletions lib-flatpak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,43 @@
# 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/.

[[ -n "$PAKITHEME_VERBOSE" ]] && set -x ||:

die() {
echo "$@" >&2
exit 1
}

pakitheme() {
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}"

local GTK_THEME_VER=3.22
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 app_id="org.gtk.Gtk3theme.$FLATPAK_THEME"
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"

prompt -i "Converting theme: $FLATPAK_THEME"

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"
prompt -s "Found theme located at: $location/$FLATPAK_THEME \n"
theme_path="$location/$FLATPAK_THEME"
break
fi
done

[[ -n "$theme_path" ]] || die 'Could not locate theme.'
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"
Expand All @@ -54,40 +55,40 @@ pakitheme() {
cp -a "$theme_path/gtk-3.$theme_gtk_version/"* "$build_dir/files"

mkdir -p "$build_dir/files/share/appdata"
cat >"$build_dir/files/share/appdata/$app_id.appdata.xml" <<EOF
cat >"$build_dir/files/share/appdata/$gtk3_app_id.appdata.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<component type="runtime">
<id>$app_id</id>
<id>$gtk3_app_id</id>
<metadata_license>CC0-1.0</metadata_license>
<name>$flatpak_name Gtk theme</name>
<summary>$flatpak_name Gtk theme (generated via pakitheme)</summary>
<name>$FLATPAK_THEME Gtk theme</name>
<summary>$FLATPAK_THEME Gtk theme (generated via pakitheme)</summary>
</component>
EOF

appstream-compose --prefix="$build_dir/files" --basename="$app_id" --origin=flatpak "$app_id"
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/$app_id-$arch.flatpak"
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=$app_id
runtime=$app_id/$arch/$GTK_THEME_VER
sdk=$app_id/$arch/$GTK_THEME_VER
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/$app_id/$arch/$GTK_THEME_VER" \
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" "$app_id" "$GTK_THEME_VER"
flatpak build-bundle --runtime "$repo_dir" "$bundle" "$gtk3_app_id" "$GTK_3_THEME_VER"

trap 'rm "$bundle"' EXIT

Expand All @@ -97,6 +98,23 @@ EOF
done < <(flatpak list --runtime --columns=arch:f | sort -u)

for bundle in "${bundles[@]}"; do
flatpak install -y --$install_target "${bundle}"
if [[ -w "/root" ]]; then
sudo flatpak install -y --system "${bundle}"
else
udo 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}
else
udo flatpak remove -y --user org.gtk.Gtk3theme.${name}${color}${opacity}${alt}${theme}
fi
}
103 changes: 65 additions & 38 deletions lib-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,39 @@ install_dialog_deps() {
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
# Rolling release
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
# Rolling release
sudo pacman -Syyu --noconfirm --needed ostree appstream-glib
elif has_command xbps-install; then
# Rolling release
# 'libxml2' is already included here, and it's gonna broke the installation
# if you add it
prepare_xbps && sudo xbps-install -Sy ostree appstream-glib
elif has_command eopkg; then
# Rolling release
sudo eopkg -y upgrade; sudo eopkg -y ostree appstream-glib
else
installation_sorry
fi
fi
}

###############################################################################
# THEME MODULES #
###############################################################################
Expand Down Expand Up @@ -552,6 +585,8 @@ install_gdm_theme() {
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
Expand All @@ -570,6 +605,7 @@ revert_gdm_theme() {
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}"
}

###############################################################################
Expand Down Expand Up @@ -671,22 +707,24 @@ install_dash_to_dock_theme() {

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"
udo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet$(destify ${colors[0]}).scss" "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
udoify_file "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
if [[ "${GNOME_VERSION}" == 'new' ]]; then
udo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-40.scss" "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css"
else
udo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet$(destify ${colors[0]}).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"
sudo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet$(destify ${colors[0]}).scss" "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css"
if [[ "${GNOME_VERSION}" == 'new' ]]; then
sudo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet-40.scss" "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css"
else
sudo sassc ${SASSC_OPT} "${DASH_TO_DOCK_SRC_DIR}/stylesheet$(destify ${colors[0]}).scss" "${DASH_TO_DOCK_DIR_ROOT}/stylesheet.css"
fi
fi

udo dbus-launch dconf write /org/gnome/shell/extensions/dash-to-dock/apply-custom-theme true
}

revert_dash_to_dock() {
if [[ -d "${DASH_TO_DOCK_DIR_HOME}.bak" ]]; then
restore_file "${DASH_TO_DOCK_DIR_HOME}" "udo"
fi
}

revert_dash_to_dock_theme() {
if [[ -d "${DASH_TO_DOCK_DIR_HOME}" ]]; then
restore_file "${DASH_TO_DOCK_DIR_HOME}/stylesheet.css" "udo"
Expand All @@ -701,30 +739,14 @@ revert_dash_to_dock_theme() {
# FLATPAK & SNAP #
###############################################################################

flatpak_remove() {
local color="$(destify ${1})"
local opacity="$(destify ${2})"
local alt="$(destify ${3})"
local theme="$(destify ${4})"

if [[ -w "/root" ]]; then
flatpak remove -y --system org.gtk.Gtk3theme.${THEME_NAME}${color}${opacity}${alt}${theme}
else
flatpak remove -y --user org.gtk.Gtk3theme.${THEME_NAME}${color}${opacity}${alt}${theme}
fi
}

connect_flatpak() {
if [[ -w "/root" ]]; then
install_target=system
else
install_target=user
fi
install_flatpak_deps

for opacity in "${opacities[@]}"; do
for alt in "${alts[@]}"; do
for theme in "${themes[@]}"; do
for color in "${colors[@]}"; do
pakitheme "${color}" "${opacity}" "${alt}" "${theme}"
pakitheme_gtk3 "${color}" "${opacity}" "${alt}" "${theme}"
done
done
done
Expand Down Expand Up @@ -789,64 +811,69 @@ customize_theme() {

# Change gnome-shell panel transparency
if [[ "${panel_opacity}" != 'default' ]]; then
prompt -s "Changing panel transparency ..."
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}'..."
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 ..."
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 Nautilus sidarbar size
if [[ "${sidebar_size}" != 'default' ]]; then
prompt -s "Changing Nautilus sidebar size ..."
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 ..."
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 ..."
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 ..."
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 panel font color
if [[ "${monterey}" == 'true' ]]; then
black_font="true"
prompt -s "Changing to Monterey style ..."
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 ..."
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) ..."
prompt -s "Changing Definition mode to HD (Bigger font, Bigger size) ... \n"
#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------------------------------------#
Expand Down
Loading

0 comments on commit 47ed033

Please sign in to comment.