Improve stability

This commit is contained in:
Muhammad Rivan 2021-06-12 14:01:28 +07:00
parent 4b916727b6
commit 19f6fb2d77
No known key found for this signature in database
GPG key ID: C56A200FD936FAAA
4 changed files with 28 additions and 16 deletions

View file

@ -51,6 +51,8 @@ usage() {
#-----------------------------PARSE ARGUMENTS---------------------------------# #-----------------------------PARSE ARGUMENTS---------------------------------#
echo
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
# Don't show any dialog here. Let this loop checks for errors or shows help # Don't show any dialog here. Let this loop checks for errors or shows help
# We can only show dialogs when there's no error and no -r parameter # We can only show dialogs when there's no error and no -r parameter
@ -117,8 +119,6 @@ if [[ "${uninstall}" == 'true' ]]; then
remove_themes remove_themes
prompt -s "Done! All '${name}' themes has been removed." prompt -s "Done! All '${name}' themes has been removed."
else else
echo
if [[ "${interactive}" == 'true' ]]; then if [[ "${interactive}" == 'true' ]]; then
show_panel_opacity_dialog; show_sidebar_size_dialog; show_nautilus_style_dialog show_panel_opacity_dialog; show_sidebar_size_dialog; show_nautilus_style_dialog
echo; prompt -w "DIALOG: '--size' and '--panel' parameters are ignored if exist."; echo echo; prompt -w "DIALOG: '--size' and '--panel' parameters are ignored if exist."; echo
@ -152,6 +152,8 @@ else
notif_msg="${final_msg}" notif_msg="${final_msg}"
fi fi
echo; prompt -w "${final_msg}"; echo echo; prompt -w "${final_msg}"
[[ -x /usr/bin/notify-send ]] && notify-send "'${name}' theme has been installed. Enjoy!" "${notif_msg}" -i "dialog-information-symbolic" [[ -x /usr/bin/notify-send ]] && notify-send "'${name}' theme has been installed. Enjoy!" "${notif_msg}" -i "dialog-information-symbolic"
fi fi
echo

View file

@ -640,7 +640,7 @@ sudo() {
} }
udo() { udo() {
local result="1" local result="0"
# Just in case. We put the prompt here to make it less annoying # Just in case. We put the prompt here to make it less annoying
if ! ${SUDO_BIN} -u "${MY_USERNAME}" -n true &> /dev/null; then if ! ${SUDO_BIN} -u "${MY_USERNAME}" -n true &> /dev/null; then

View file

@ -55,15 +55,23 @@ installation_sorry() {
} }
prepare_deps() { prepare_deps() {
local head="$(curl -Is -o - 'time.cloudflare.com' || wget -Sq -o - --max-redirect=0 'time.cloudflare.com')" local head=""
local remote_time="$(echo "${head}" | awk -F ': ' '/Date/{print $2}')" local remote_time=""
local remote_time_int="$(date --date "${remote_time}" +"%Y%m%d")" local local_time=""
local local_time_int="$(date -u +"%Y%m%d")"
if (( remote_time_int > local_time_int )); then prompt -i "DEPS: Checking your internet connection..."
prompt -w "\n DEPS: Your system clock is wrong"
prompt -i "DEPS: Updating your system clock...\n" if ! head="$(curl -Is -o - 'time.cloudflare.com' || wget -Sq -o - --max-redirect=0 'time.cloudflare.com')"; then
sudo date -s "${remote_time}"; sudo hwclock --systohc prompt -e "DEPS ERROR: You have an internet connection issue\n"; exit 1
fi
remote_time="$(echo "${head}" | awk -F ': ' '/Date/{print $2}' | date -f - "+%s")"
local_time="$(date -u "+%s")"
if (( remote_time-(5*60) > local_time )); then
prompt -w "DEPS: Your system clock is wrong"
prompt -i "DEPS: Updating your system clock..."
sudo date -s "@${remote_time}"; sudo hwclock --systohc
fi fi
} }
@ -142,7 +150,7 @@ prepare_xbps() {
install_theme_deps() { install_theme_deps() {
if ! has_command glib-compile-resources || ! has_command sassc || ! has_command xmllint || if ! has_command glib-compile-resources || ! has_command sassc || ! has_command xmllint ||
(! is_my_distro "clear-linux" && [[ ! -r "/usr/share/gtk-engines/murrine.xml" ]]); then (! is_my_distro "clear-linux" && [[ ! -r "/usr/share/gtk-engines/murrine.xml" ]]); then
prompt -w "'glib2.0', 'sassc', 'xmllint', and 'libmurrine' are required for theme installation." prompt -w "DEPS: 'glib2.0', 'sassc', 'xmllint', and 'libmurrine' are required for theme installation."
prepare_deps prepare_deps
if has_command zypper; then if has_command zypper; then
@ -174,7 +182,7 @@ install_theme_deps() {
install_beggy_deps() { install_beggy_deps() {
if ! has_command convert; then if ! has_command convert; then
prompt -w "'imagemagick' are required for background editing." prompt -w "DEPS: 'imagemagick' is required for background editing."
prepare_deps prepare_deps
if has_command zypper; then if has_command zypper; then
@ -202,7 +210,7 @@ install_beggy_deps() {
install_dialog_deps() { install_dialog_deps() {
if ! has_command dialog; then if ! has_command dialog; then
prompt -w "'dialog' is required for this option." prompt -w "DEPS: 'dialog' is required for this option."
prepare_deps prepare_deps
if has_command zypper; then if has_command zypper; then

View file

@ -43,6 +43,8 @@ usage() {
#-----------------------------PARSE ARGUMENTS---------------------------------# #-----------------------------PARSE ARGUMENTS---------------------------------#
echo
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
# Don't show any dialog here. Let this loop checks for errors or shows help # Don't show any dialog here. Let this loop checks for errors or shows help
# We can only show dialogs when there's no error and no -r parameter # We can only show dialogs when there's no error and no -r parameter
@ -137,7 +139,7 @@ finalize_argument_parsing
#---------------------------START INSTALL THEMES-------------------------------# #---------------------------START INSTALL THEMES-------------------------------#
if [[ "${uninstall}" == 'true' ]]; then if [[ "${uninstall}" == 'true' ]]; then
echo; prompt -w "REMOVAL: Non file-related parameters will be ignored." prompt -w "REMOVAL: Non file-related parameters will be ignored."
if [[ "${gdm}" == 'true' ]]; then if [[ "${gdm}" == 'true' ]]; then
echo; prompt -i "Removing '${name}' GDM theme..." echo; prompt -i "Removing '${name}' GDM theme..."