Merge pull request #200 from rivanfebrian123/master

Use different approach for distro detection and do a code refactoring
This commit is contained in:
Vince 2021-04-21 21:42:20 +08:00 committed by GitHub
commit e67c8022a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 13 deletions

View file

@ -129,7 +129,7 @@ else
echo; install_themes; echo; prompt -s "Done!" echo; install_themes; echo; prompt -s "Done!"
if [[ "${DISTRO_BASE}" == "arch" && "$(which xfce4-session 2> /dev/null)" ]]; then if is_my_distro "arch" && has_command xfce4-session; then
msg="XFCE: you may need to logout after changing your theme to fix your panel opacity." msg="XFCE: you may need to logout after changing your theme to fix your panel opacity."
notif_msg="${msg}\n\n${final_msg}" notif_msg="${msg}\n\n${final_msg}"

View file

@ -18,7 +18,6 @@ else LIB_CORE_IMPORTED="true"; fi
export WHITESUR_PID=$$ export WHITESUR_PID=$$
MY_USERNAME="$(logname 2> /dev/null || echo ${SUDO_USER:-${USER}})" MY_USERNAME="$(logname 2> /dev/null || echo ${SUDO_USER:-${USER}})"
DISTRO_BASE="$(cat '/etc/os-release' | awk -F '=' '/ID_LIKE/{print $2}')"
if command -v gnome-shell &> /dev/null; then if command -v gnome-shell &> /dev/null; then
if (( $(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f 1) >= 4 )); then if (( $(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f 1) >= 4 )); then
@ -205,6 +204,10 @@ has_command() {
command -v "$1" &> /dev/null command -v "$1" &> /dev/null
} }
is_my_distro() {
[[ "$(cat '/etc/os-release' | awk -F '=' '/ID/{print $2}')" =~ "${1}" ]]
}
############################################################################### ###############################################################################
# PARAMETERS # # PARAMETERS #
############################################################################### ###############################################################################
@ -455,7 +458,7 @@ backup_file() {
} }
check_theme_file() { check_theme_file() {
[[ -f "${1}" || -f "${1}.bak" ]] && return 0 || return 1 [[ -f "${1}" || -f "${1}.bak" ]]
} }
remind_relative_path() { remind_relative_path() {

View file

@ -23,8 +23,8 @@ source "${REPO_DIR}/lib-core.sh"
############################################################################### ###############################################################################
install_theme_deps() { install_theme_deps() {
if [[ ! "$(which glib-compile-resources 2> /dev/null)" || ! "$(which sassc 2> /dev/null)" || \ if ! has_command glib-compile-resources || ! has_command sassc || \
! -r "/usr/share/gtk-engines/murrine.xml" || ! "$(which xmllint 2> /dev/null)" ]]; then ! has_command xmllint || [[ ! -r "/usr/share/gtk-engines/murrine.xml" ]]; then
echo; prompt -w "'glib2.0', 'sassc', 'xmllint', 'libmurrine' are required for theme installation." echo; prompt -w "'glib2.0', 'sassc', 'xmllint', 'libmurrine' are required for theme installation."
if has_command zypper; then if has_command zypper; then
@ -67,7 +67,7 @@ install_gdm_deps() {
} }
install_beggy_deps() { install_beggy_deps() {
if [[ ! "$(which convert 2> /dev/null)" ]]; then if ! has_command convert; then
echo; prompt -w "'imagemagick' are required for this option." echo; prompt -w "'imagemagick' are required for this option."
if has_command zypper; then if has_command zypper; then
@ -87,7 +87,7 @@ install_beggy_deps() {
} }
install_dialog_deps() { install_dialog_deps() {
if [[ ! "$(which dialog 2> /dev/null)" ]]; then if ! has_command dialog; then
echo; prompt -w "'dialog' are required for this option." echo; prompt -w "'dialog' are required for this option."
if has_command zypper; then if has_command zypper; then
@ -317,9 +317,12 @@ install_theemy() {
remove_packy() { remove_packy() {
rm -rf "${dest}/${name}$(destify ${1})$(destify ${2})$(destify ${3})$(destify ${4})" rm -rf "${dest}/${name}$(destify ${1})$(destify ${2})$(destify ${3})$(destify ${4})"
rm -rf "${dest}/${name}$(destify ${1})-mdpi" rm -rf "${dest}/${name}$(destify ${1})"
rm -rf "${dest}/${name}$(destify ${1})-hdpi" rm -rf "${dest}/${name}$(destify ${1})-hdpi"
rm -rf "${dest}/${name}$(destify ${1})-xhdpi" rm -rf "${dest}/${name}$(destify ${1})-xhdpi"
# Backward compatibility
rm -rf "${dest}/${name}$(destify ${1})-mdpi"
} }
############################################################################### ###############################################################################

View file

@ -8,7 +8,7 @@ has_command() {
"$1" -v $1 > /dev/null 2>&1 "$1" -v $1 > /dev/null 2>&1
} }
if [ ! "$(which inkscape 2> /dev/null)" ]; then if ! has_command inkscape; then
echo inkscape and optipng needs to be installed to generate the assets. echo inkscape and optipng needs to be installed to generate the assets.
if has_command zypper; then if has_command zypper; then
sudo zypper in inkscape optipng sudo zypper in inkscape optipng

View file

@ -67,7 +67,7 @@ while [[ $# -gt 0 ]]; do
edit_firefox="true" ;; edit_firefox="true" ;;
esac esac
if [[ ! "$(which firefox 2> /dev/null)" ]]; then if ! has_command firefox; then
prompt -e "'${1}' ERROR: There's no Firefox installed in your system" prompt -e "'${1}' ERROR: There's no Firefox installed in your system"
has_any_error="true" has_any_error="true"
elif [[ ! -d "${FIREFOX_DIR_HOME}" ]]; then elif [[ ! -d "${FIREFOX_DIR_HOME}" ]]; then
@ -81,21 +81,21 @@ while [[ $# -gt 0 ]]; do
-F|--flatpak) -F|--flatpak)
flatpak="true"; flatpak="true";
if [[ ! "$(which flatpak 2> /dev/null)" ]]; then if ! has_command flatpak; then
prompt -e "'${1}' ERROR: There's no Flatpak installed in your system" prompt -e "'${1}' ERROR: There's no Flatpak installed in your system"
has_any_error="true" has_any_error="true"
fi; shift ;; fi; shift ;;
-s|--snap) -s|--snap)
snap="true"; snap="true";
if [[ ! "$(which snap 2> /dev/null)" ]]; then if ! has_command snap; then
prompt -e "'${1}' ERROR: There's no Snap installed in your system" prompt -e "'${1}' ERROR: There's no Snap installed in your system"
has_any_error="true" has_any_error="true"
fi; shift ;; fi; shift ;;
-g|--gdm) -g|--gdm)
gdm="true"; full_rootify "${1}" gdm="true"; full_rootify "${1}"
if [[ ! "$(which gdm 2> /dev/null)" && ! "$(which gdm3 2> /dev/null)" ]]; then if ! has_command gdm && ! has_command gdm3; then
prompt -e "'${1}' ERROR: There's no GDM installed in your system" prompt -e "'${1}' ERROR: There's no GDM installed in your system"
has_any_error="true" has_any_error="true"
fi; shift ;; fi; shift ;;