diff --git a/swww.sh b/swww.sh index eae467c..0faec32 100644 --- a/swww.sh +++ b/swww.sh @@ -6,6 +6,30 @@ command -v "$@" >/dev/null 2>&1 } + # ─< package variable >─────────────────────────────────────────────────────────────────── + unset PACKAGE + + # ─< argument list variables >──────────────────────────────────────────────────────────── + silent=false + + sleep 0.1 + + PACKAGE=packagename + if command_exists "$PACKAGE"; then + echo_warning "$PACKAGE is already installed!" + echo_warning "Exiting now!" + exit 69 + fi + + # ─< parse arguments and get variable contents >────────────────────────────────────────── + for arg in "$@"; do + case "$arg" in + --silent | -s) + export silent=true + ;; + esac + done + # WHY: # This import will give you the following variables: # _sudo="sudo -E" <- only if non root user @@ -64,6 +88,10 @@ } main() { + if $silent; then + echo_warning "Executing script silently!" + fi + case "$distro" in arch) echo_info "Arch detected.. installing directly" @@ -81,18 +109,7 @@ } if getImports; then - case "$1" in - --silent | -s) - echo_info "Executing main silently.." - silent=true - ;; - *) silent=false ;; - esac + main fi - if ! command_exists swww; then - main - else - echo_warning "swww is already installed!" - fi }