From 7fd7db2107b96f24cb04a111361bbfc43763bda3 Mon Sep 17 00:00:00 2001 From: Muhammad Rivan Date: Mon, 31 May 2021 17:04:08 +0700 Subject: [PATCH] Add support for Firefox theme for Snap, and add more debuging info --- lib-core.sh | 15 ++++++++++++++- lib-install.sh | 18 +++++++++++++----- tweaks.sh | 15 +++++++-------- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/lib-core.sh b/lib-core.sh index 328b31a..bc62c11 100755 --- a/lib-core.sh +++ b/lib-core.sh @@ -46,6 +46,8 @@ FIREFOX_DIR_HOME="/home/${MY_USERNAME}/.mozilla/firefox" FIREFOX_THEME_DIR="/home/${MY_USERNAME}/.mozilla/firefox/firefox-themes" FIREFOX_FLATPAK_DIR_HOME="/home/${MY_USERNAME}/.var/app/org.mozilla.firefox/.mozilla/firefox" FIREFOX_FLATPAK_THEME_DIR="/home/${MY_USERNAME}/.var/app/org.mozilla.firefox/.mozilla/firefox/firefox-themes" +FIREFOX_SNAP_DIR_HOME="/home/${MY_USERNAME}/snap/firefox/common/.mozilla/firefox" +FIREFOX_SNAP_THEME_DIR="/home/${MY_USERNAME}/snap/firefox/common/.mozilla/firefox/firefox-themes" export WHITESUR_TMP_DIR="/tmp/WhiteSur.lock" if [[ -w "/" ]]; then @@ -199,6 +201,10 @@ has_flatpak_app() { flatpak list --columns=application 2> /dev/null | 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}" ]] } @@ -498,6 +504,7 @@ signal_exit() { operation_aborted() { local sources=($(basename -a "${BASH_SOURCE[@]}" | sort -u)) + local dist_ids=($(cat '/etc/os-release' | awk -F '=' '/ID/{print $2}')) clear @@ -520,7 +527,13 @@ operation_aborted() { prompt -e ">>> ${BASH_COMMAND}\n" - prompt -i "TIP: you can google or report to us the infos above\n\n" + prompt -e "SYSTEM INFO:" + prompt -e " DISTRO : $(IFS=';'; echo "${dist_ids[*]}")" + prompt -e " SUDO : $([[ -w "/" ]] && echo "yes" || echo "no")" + prompt -e " GNOME : ${GNOME_VERSION}\n" + + prompt -i "TIP: you can google or report to us the infos above\n" + prompt -i "https://github.com/vinceliuice/WhiteSur-gtk-theme/issues\n\n" rm -rf "${WHITESUR_TMP_DIR}"; exit 1 } diff --git a/lib-install.sh b/lib-install.sh index 85e982d..4aab205 100755 --- a/lib-install.sh +++ b/lib-install.sh @@ -433,9 +433,9 @@ revert_gdm_theme() { ############################################################################### install_firefox_theme() { - #TODO: add support for Snap - - if has_flatpak_app org.mozilla.firefox; then + 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}" @@ -448,7 +448,10 @@ install_firefox_theme() { } config_firefox() { - if has_flatpak_app org.mozilla.firefox; then + if has_snap_app firefox; then + local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}" + local FIREFOX_DIR="${FIREFOX_SNAP_DIR_HOME}" + elif has_flatpak_app org.mozilla.firefox; then local TARGET_DIR="${FIREFOX_FLATPAK_THEME_DIR}" local FIREFOX_DIR="${FIREFOX_FLATPAK_DIR_HOME}" else @@ -473,7 +476,9 @@ config_firefox() { } edit_firefox_theme_prefs() { - if has_flatpak_app org.mozilla.firefox; then + 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}" @@ -492,6 +497,9 @@ remove_firefox_theme() { # This too rm -rf "${FIREFOX_FLATPAK_DIR_HOME}/"*"default"*"/chrome" rm -rf "${FIREFOX_FLATPAK_THEME_DIR}" + # Again, this too + rm -rf "${FIREFOX_SNAP_DIR_HOME}/"*"default"*"/chrome" + rm -rf "${FIREFOX_SNAP_THEME_DIR}" } ############################################################################### diff --git a/tweaks.sh b/tweaks.sh index 26c4f21..e62a408 100755 --- a/tweaks.sh +++ b/tweaks.sh @@ -67,10 +67,10 @@ while [[ $# -gt 0 ]]; do edit_firefox="true" ;; esac - if ! has_command firefox && ! has_flatpak_app org.mozilla.firefox; then + if ! has_command firefox && ! has_flatpak_app org.mozilla.firefox && ! has_snap_app firefox; then prompt -e "'${1}' ERROR: There's no Firefox installed in your system" has_any_error="true" - elif [[ ! -d "${FIREFOX_DIR_HOME}" && ! -d "${FIREFOX_FLATPAK_DIR_HOME}" ]]; then + elif [[ ! -d "${FIREFOX_DIR_HOME}" && ! -d "${FIREFOX_FLATPAK_DIR_HOME}" && ! -d "${FIREFOX_SNAP_DIR_HOME}" ]]; then prompt -e "'${1}' ERROR: Firefox is installed but not yet initialized." prompt -w "'${1}': Don't forget to close it after you run/initialize it" has_any_error="true" @@ -95,20 +95,19 @@ while [[ $# -gt 0 ]]; do -g|--gdm) gdm="true"; full_rootify "${1}" - if ! has_command gdm && ! has_command gdm3; then + if ! has_command gdm && ! has_command gdm3 && [[ ! -e /usr/sbin/gdm3 ]]; then prompt -e "'${1}' ERROR: There's no GDM installed in your system" has_any_error="true" fi; shift ;; -d|--dash-to-dock) if [[ "${GNOME_VERSION}" == 'new' ]]; then - prompt -e "'${1}' ERROR: There's no need to install on >= Gnome 40.0!" + prompt -e "'${1}' WARNING: There's no need to install on >= GNOME 40.0" + dash_to_dock="false" + elif [[ ! -d "${DASH_TO_DOCK_DIR_HOME}" && ! -d "${DASH_TO_DOCK_DIR_ROOT}" ]]; then + prompt -e "'${1}' ERROR: There's no Dash to Dock installed in your system" has_any_error="true" else dash_to_dock="true" - fi - if [[ ! -d "${DASH_TO_DOCK_DIR_HOME}" && ! -d "${DASH_TO_DOCK_DIR_ROOT}" ]]; then - prompt -e "'${1}' ERROR: There's no Dash to Dock installed in your system" - has_any_error="true" fi; shift ;; -N|--no-darken) no_darken="true"; shift ;;