Add silent mode

This commit is contained in:
Muhammad Rivan 2021-06-15 20:15:34 +07:00
parent a9f3d168a9
commit 65f4feecbe
No known key found for this signature in database
GPG key ID: C56A200FD936FAAA
4 changed files with 30 additions and 2 deletions

View file

@ -42,6 +42,7 @@ usage() {
helpify "--normal, --normalshowapps" "" "Set gnome-shell show apps button style to normal" "Default is bigsur"
helpify "--dialog, --interactive" "" "Run this installer interactively, with dialogs" ""
helpify "-r, --remove, -u, --uninstall" "" "Remove all installed ${THEME_NAME} themes" ""
helpify "--silent-mode" "" "Meant for developers: ignore any confirm prompt and params become more strict" ""
helpify "-h, --help" "" "Show this help" ""
}
@ -67,8 +68,12 @@ while [[ $# -gt 0 ]]; do
# Parameters that don't require value
-r|--remove|-u|-uninstall)
uninstall='true'; shift ;;
--silent-mode)
full_sudo "${1}"; silent_mode='true'; shift ;;
--dialog|--interactive)
interactive='true'; shift ;;
-h|--help)
need_help="true"; shift ;;
--normal|--normalshowapps)
showapps_normal="true"; shift ;;
--right|--rightplacement)
@ -77,8 +82,6 @@ while [[ $# -gt 0 ]]; do
max_round="true"; shift ;;
-HD|--highdefinition)
compact="false"; shift ;;
-h|--help)
need_help="true"; shift ;;
# Parameters that require value, single use
-b|--background)
check_param "${1}" "${1}" "${2}" "must" "must" "must" "false" && shift 2 || shift ;;

View file

@ -109,6 +109,7 @@ declare -A need_dialog=([-b]="false" [-s]="false" [-p]="false" [-d]="false" [-n]
need_help="false"
uninstall="false"
interactive="false"
silent_mode="false"
no_darken="false"
no_blur="false"
@ -161,6 +162,8 @@ anim=(
###############################################################################
start_animation() {
[[ "${silent_mode}" == "true" ]] && return 0
setterm -cursor off
(
@ -181,6 +184,8 @@ start_animation() {
}
stop_animation() {
[[ "${silent_mode}" == "true" ]] && return 0
[[ -e "/proc/${ANIM_PID}" ]] && kill -13 "${ANIM_PID}"
setterm -cursor on
}
@ -295,18 +300,27 @@ trap 'signal_abort' INT TERM TSTP
###############################################################################
ask() {
[[ "${silent_mode}" == "true" ]] && return 0
echo -ne "${c_magenta}"
read -p " ${2}: " ${1} 2>&1
echo -ne "${c_default}"
}
confirm() {
[[ "${silent_mode}" == "true" ]] && return 0
while [[ "${!1}" != "y" && "${!1}" != "n" ]]; do
ask ${1} "${2} (y/n)"
done
}
dialogify() {
if [[ "${silent_mode}" == "true" ]]; then
prompt -w "Oops... silent mode has been activated so we can't show the dialog"
return 0
fi
local lists=""
local i=0
local result=""
@ -408,6 +422,12 @@ check_param() {
local has_any_ambiguity_error="false"
local variant_found="false"
if [[ "${silent_mode}" == "true" ]]; then
must_not_ambigous="must"
must_have_value="must"
value_must_found="must"
fi
if [[ "${has_set["${global_param}"]}" == "true" ]]; then
need_dialog["${global_param}"]="true"

View file

@ -211,6 +211,8 @@ install_beggy_deps() {
}
install_dialog_deps() {
[[ "${silent_mode}" == "true" ]] && return 0
if ! has_command dialog; then
prompt -w "DEPS: 'dialog' is required for this option."
prepare_deps

View file

@ -34,6 +34,7 @@ usage() {
helpify "-p, --panel" "[$(IFS='|'; echo "${PANEL_OPACITY_VARIANTS[*]}")]" "Set '${THEME_NAME}' GDM (GNOME Shell) theme panel transparency" "Default is 15%"
helpify "-i, --icon" "[$(IFS='|'; echo "${ICON_VARIANTS[*]}")]" "Set '${THEME_NAME}' GDM (GNOME Shell) 'Activities' icon" "Default is 'standard'"
helpify "-r, --remove, --revert" "" "Revert to the original themes, do the opposite things of install and connect" ""
helpify "--silent-mode" "" "Meant for developers: ignore any confirm prompt and params become more strict" ""
helpify "-h, --help" "" "Show this help" ""
}
@ -59,6 +60,8 @@ while [[ $# -gt 0 ]]; do
# Parameters that don't require value
-r|--remove|--revert)
uninstall='true'; shift ;;
--silent-mode)
full_sudo "${1}"; silent_mode='true'; shift ;;
-h|--help)
need_help="true"; shift ;;
-f|--firefox|-e|--edit-firefox)