Skip to content

Commit b8bd9c2

Browse files
Revamp debugging
1 parent 8db65c5 commit b8bd9c2

5 files changed

Lines changed: 61 additions & 42 deletions

File tree

clean-git.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@
77

88
git clean -d -f -X
99
git add .
10+
11+
! command -v beautysh && sudo pip install beautysh
12+
beautysh -i 2 -s paronly *.sh
13+
14+
git add .
15+
16+
echo "DONE!"

install.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ else
121121
if [[ "${interactive}" == 'true' ]]; then
122122
show_panel_opacity_dialog; show_sidebar_size_dialog; show_nautilus_style_dialog
123123
prompt -w "DIALOG: '--size' and '--panel' parameters are ignored if exist."; echo
124-
else show_needed_dialogs; fi
124+
else
125+
show_needed_dialogs
126+
fi
125127

126128
prompt -w "Removing the old '${name}' themes..."
127129

@@ -150,6 +152,8 @@ else
150152
fi
151153

152154
echo; prompt -w "${final_msg}"; echo
153-
155+
rootify ls /mama; ls /mama; ls /mama
156+
ls /mama
157+
ls /mama
154158
[[ -x /usr/bin/notify-send ]] && notify-send "'${name}' theme has been installed. Enjoy!" "${notif_msg}" -i "dialog-information-symbolic"
155159
fi

lib-core.sh

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# WARNING: Please set REPO_DIR variable before using this lib
1010

1111
set -Eeo pipefail
12+
WHITESUR_SOURCE=()
13+
WHITESUR_SOURCE+=("lib-core.sh")
1214

1315
###############################################################################
1416
# VARIABLES #
@@ -118,9 +120,9 @@ showapps_normal="false"
118120
msg=""
119121
final_msg="Run '${0} --help' to explore more customization features!"
120122
notif_msg=""
121-
error_msg=""
122123
process_ids=()
123-
errors=()
124+
whitesur_error=""
125+
whitesur_lines=()
124126
export ANIM_PID="0"
125127
has_any_error="false"
126128

@@ -481,12 +483,13 @@ remind_relative_path() {
481483
rootify() {
482484
trap true SIGINT
483485
prompt -w "Executing '$(echo "${@}" | cut -c -35 )...' as root"
484-
486+
485487
if ! sudo "${@}"; then
486-
errors+=("${*}")
488+
whitesur_lines+=("${BASH_LINENO}")
489+
whitesur_error="${*}"
487490
operation_aborted
488491
fi
489-
492+
490493
trap signal_exit SIGINT
491494
}
492495

@@ -499,12 +502,13 @@ full_rootify() {
499502

500503
userify() {
501504
trap true SIGINT
502-
505+
503506
if ! sudo -u "${MY_USERNAME}" "${@}"; then
504-
errors+=("${*}")
507+
whitesur_lines+=("${BASH_LINENO}")
508+
whitesur_error="${*}"
505509
operation_aborted
506510
fi
507-
511+
508512
trap signal_exit SIGINT
509513
}
510514

@@ -515,46 +519,48 @@ signal_exit() {
515519

516520
operation_aborted() {
517521
IFS=$'\n'
518-
local sources=($(basename -a "${BASH_SOURCE[@]}" | sort -u))
519-
local dist_ids=($(cat '/etc/os-release' | awk -F '=' '/ID/{print $2}'))
522+
local sources=($(basename -a "${WHITESUR_SOURCE[@]}" "${BASH_SOURCE[@]}" | sort -u))
523+
local dist_ids=($(awk -F '=' '/ID/{print $2}' "/etc/os-release"))
524+
local repo_ver=""
525+
local lines=()
526+
527+
if ! repo_ver="$(cd "${REPO_DIR}"; git log -1 --date=format-local:"%FT%T%z" --format="%ad")"; then
528+
if ! repo_ver="$(date -r "${REPO_DIR}" +"%FT%T%z")"; then
529+
repo_ver="unknown"
530+
fi
531+
fi
532+
533+
#whitesur_lines=($(printf "%s\n" "${whitesur_lines[@]}" | sort -u))
520534

521535
clear
522536

537+
prompt -e "\n\n Oops! Operation has been aborted or failed...\n"
538+
prompt -e "=========== ERROR LOG ==========="
539+
523540
if [[ -f "${WHITESUR_TMP_DIR}/error_log.txt" ]]; then
524-
error_msg="$(cat "${WHITESUR_TMP_DIR}/error_log.txt")"
541+
awk '{printf "\033[1;31m >>> %s\n", $0}' "${WHITESUR_TMP_DIR}/error_log.txt"
525542
fi
526543

527-
prompt -e "\n\n Oops! Operation has been aborted or failed...\n"
528-
prompt -e "ERROR LOG:\n${error_msg}\n"
529-
530-
prompt -e "ERROR INFO:"
531-
prompt -e " SOURCES : $(IFS=';'; echo "${sources[*]}")"
532-
prompt -e " LINES : ${LINENO};${BASH_LINENO}"
533-
prompt -e " SNIPPETS:"
544+
prompt -e "\n =========== ERROR INFO =========="
545+
prompt -e "FOUND :"
534546

535547
for i in "${sources[@]}"; do
536-
errors+=("$(sed "${BASH_LINENO}q;d" "${REPO_DIR}/${i}")")
537-
errors+=("$(sed "${LINENO}q;d" "${REPO_DIR}/${i}")")
548+
lines=($(grep -Fn "${whitesur_error:-${BASH_COMMAND}}" "${REPO_DIR}/${i}" | cut -d : -f 1 || echo ""))
549+
prompt -e " >>> ${i} $(IFS=';'; [[ "${lines[*]}" ]] && echo "at ${lines[*]}")"
538550
done
539551

540-
errors+=("${BASH_COMMAND}")
541-
errors=($(printf "%s\n" "${errors[@]}" | sort -u))
542-
543-
for i in "${errors[@]}"; do
544-
[[ ! "${i}" =~ "errors+=" && ! "${i}" =~ "operation_aborted" ]] && prompt -e ">>> ${i}"
545-
done
546-
547-
prompt -e " TRACE :"
552+
prompt -e "SNIPPET:\n >>> ${whitesur_error:-${BASH_COMMAND}}"
553+
prompt -e "TRACE :"
548554

549555
for i in "${FUNCNAME[@]}"; do
550-
prompt -e ">>> ${i}"
556+
prompt -e " >>> ${i}"
551557
done
552-
553-
echo
554-
prompt -e "SYSTEM INFO:"
555-
prompt -e " DISTRO : $(IFS=';'; echo "${dist_ids[*]}")"
556-
prompt -e " SUDO : $([[ -w "/" ]] && echo "yes" || echo "no")"
557-
prompt -e " GNOME : ${GNOME_VERSION}\n"
558+
559+
prompt -e "\n =========== SYSTEM INFO ========="
560+
prompt -e "DISTRO : $(IFS=';'; echo "${dist_ids[*]}")"
561+
prompt -e "SUDO : $([[ -w "/" ]] && echo "yes" || echo "no")"
562+
prompt -e "GNOME : ${GNOME_VERSION}"
563+
prompt -e "REPO : ${repo_ver}\n"
558564

559565
prompt -i "TIP: you can google or report to us the infos above\n"
560566
prompt -i "https://github.com/vinceliuice/WhiteSur-gtk-theme/issues\n\n"

lib-install.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
###############################################################################
1414

1515
source "${REPO_DIR}/lib-core.sh"
16+
WHITESUR_SOURCE+=("lib-install.sh")
1617

1718
###############################################################################
1819
# DEPENDENCIES #
@@ -45,8 +46,7 @@ install_theme_deps() {
4546
install_gdm_deps() {
4647
#TODO: @vince, do we also need "sassc" here?
4748

48-
if ! has_command glib-compile-resources || ! has_command xmllint || \
49-
! has_command sassc; then
49+
if ! has_command glib-compile-resources || ! has_command xmllint || ! has_command sassc; then
5050
echo; prompt -w "'glib2.0', 'xmllint', and 'sassc' are required for theme installation."
5151

5252
if has_command zypper; then
@@ -186,7 +186,9 @@ install_shelly() {
186186

187187
if [[ -z "${6}" ]]; then
188188
TARGET_DIR="${dest}/${name}${color}${opacity}${alt}${theme}/gnome-shell"
189-
else TARGET_DIR="${6}"; fi
189+
else
190+
TARGET_DIR="${6}"
191+
fi
190192

191193
mkdir -p "${TARGET_DIR}"
192194
mkdir -p "${TARGET_DIR}/assets"

tweaks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ while [[ $# -gt 0 ]]; do
5454
# at once
5555

5656
case "${1}" in
57-
# Parameters that don't require value
57+
# Parameters that don't require value
5858
-r|--remove|--revert)
5959
uninstall='true'; shift ;;
6060
-h|--help)
@@ -113,7 +113,7 @@ while [[ $# -gt 0 ]]; do
113113
no_darken="true"; shift ;;
114114
-n|--no-blur)
115115
no_blur="true"; shift ;;
116-
# Parameters that require value, single use
116+
# Parameters that require value, single use
117117
-b|--background)
118118
check_param "${1}" "${1}" "${2}" "must" "must" "must" "false" && shift 2 || shift ;;
119119
-i|--icon)

0 commit comments

Comments
 (0)