diff --git a/install.sh b/install.sh index 3808df7..28a25f3 100755 --- a/install.sh +++ b/install.sh @@ -129,7 +129,7 @@ else 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." notif_msg="${msg}\n\n${final_msg}" diff --git a/lib-core.sh b/lib-core.sh index 31ada8b..a0b2e9d 100755 --- a/lib-core.sh +++ b/lib-core.sh @@ -18,7 +18,6 @@ else LIB_CORE_IMPORTED="true"; fi export WHITESUR_PID=$$ 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 (( $(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f 1) >= 4 )); then @@ -205,6 +204,10 @@ has_command() { command -v "$1" &> /dev/null } +is_my_distro() { + [[ "$(cat '/etc/os-release' | awk -F '=' '/ID/{print $2}')" =~ "${1}" ]] +} + ############################################################################### # PARAMETERS # ############################################################################### @@ -455,7 +458,7 @@ backup_file() { } check_theme_file() { - [[ -f "${1}" || -f "${1}.bak" ]] && return 0 || return 1 + [[ -f "${1}" || -f "${1}.bak" ]] } remind_relative_path() { diff --git a/lib-install.sh b/lib-install.sh index 5ae602e..c194312 100755 --- a/lib-install.sh +++ b/lib-install.sh @@ -23,8 +23,8 @@ source "${REPO_DIR}/lib-core.sh" ############################################################################### install_theme_deps() { - if [[ ! "$(which glib-compile-resources 2> /dev/null)" || ! "$(which sassc 2> /dev/null)" || \ - ! -r "/usr/share/gtk-engines/murrine.xml" || ! "$(which xmllint 2> /dev/null)" ]]; then + if ! has_command glib-compile-resources || ! has_command sassc || \ + ! has_command xmllint || [[ ! -r "/usr/share/gtk-engines/murrine.xml" ]]; then echo; prompt -w "'glib2.0', 'sassc', 'xmllint', 'libmurrine' are required for theme installation." if has_command zypper; then @@ -67,7 +67,7 @@ install_gdm_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." if has_command zypper; then @@ -87,7 +87,7 @@ install_beggy_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." if has_command zypper; then @@ -317,9 +317,12 @@ install_theemy() { remove_packy() { 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})-xhdpi" + + # Backward compatibility + rm -rf "${dest}/${name}$(destify ${1})-mdpi" } ############################################################################### diff --git a/src/assets/render-all-assets.sh b/src/assets/render-all-assets.sh index bb405dd..b2554dc 100755 --- a/src/assets/render-all-assets.sh +++ b/src/assets/render-all-assets.sh @@ -8,7 +8,7 @@ has_command() { "$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. if has_command zypper; then sudo zypper in inkscape optipng diff --git a/tweaks.sh b/tweaks.sh index 42a3f35..6ec9455 100755 --- a/tweaks.sh +++ b/tweaks.sh @@ -67,7 +67,7 @@ while [[ $# -gt 0 ]]; do edit_firefox="true" ;; 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" has_any_error="true" elif [[ ! -d "${FIREFOX_DIR_HOME}" ]]; then @@ -81,21 +81,21 @@ while [[ $# -gt 0 ]]; do -F|--flatpak) 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" has_any_error="true" fi; shift ;; -s|--snap) 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" has_any_error="true" fi; shift ;; -g|--gdm) 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" has_any_error="true" fi; shift ;;