From 5ceb83064f8ce33df8bec09c01de39ba65f843c4 Mon Sep 17 00:00:00 2001 From: Autumn McKee Date: Sat, 20 Jun 2026 21:37:39 +0200 Subject: [PATCH] feat(installer): add quiet flag to suppress default logging --- README.md | 2 +- install.sh | 125 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 86 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 524649c..d6db74d 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ #### Automated Installation Install without any prompts by passing the flavour, accent, and window-decoration numbers plus `auto`: -`./install.sh auto` +`./install.sh [-q|--quiet] auto` Example (Mocha, Blue, Classic): `./install.sh 1 13 2 auto` diff --git a/install.sh b/install.sh index 8fae602..d6b061d 100755 --- a/install.sh +++ b/install.sh @@ -1,13 +1,32 @@ #!/bin/sh -# Syntax +# Syntax [-q|--quiet] + +QUIET=0 +case "$1" in + -q | --quiet) + QUIET=1 + shift + ;; +esac + +log() { + if [ "$QUIET" -ne 1 ]; then + echo "$@" + fi +} + +missing_arg() { + echo "Error: Missing $1." >&2 + exit 1 +} check_command_exists() { command_name="$1" if ! command -v "$command_name" >/dev/null 2>&1; then - echo "Error: Dependency '$command_name' is not met." - echo "Exiting.." + echo "Error: Dependency '$command_name' is not met." >&2 + echo "Exiting.." >&2 exit 1 fi } @@ -25,7 +44,7 @@ AURORAEDIR="${XDG_DATA_HOME:-$HOME/.local/share}/aurorae/themes" LOOKANDFEELDIR="${XDG_DATA_HOME:-$HOME/.local/share}/plasma/look-and-feel" CURSORDIR="${XDG_DATA_HOME:-$HOME/.local/share}/icons" -echo "Creating theme directories.." +log "Creating theme directories.." mkdir -p "$COLORDIR" "$AURORAEDIR" "$LOOKANDFEELDIR" "$CURSORDIR" mkdir -p ./dist @@ -35,11 +54,14 @@ ACCENT="$2" WINDECSTYLE="$3" DEBUGMODE="$4" -if [ "$DEBUGMODE" != "auto" ]; then +if [ "$DEBUGMODE" != "auto" ] && [ "$QUIET" -ne 1 ]; then clear fi if [ -z "$FLAVOUR" ]; then + if [ "$QUIET" -eq 1 ]; then + missing_arg "flavour" + fi cat <&2 exit 1 ;; esac -echo "$FLAVOURNAME($FLAVOUR) palette was selected." -echo +log "$FLAVOURNAME($FLAVOUR) palette was selected." +log "" if [ -z "$ACCENT" ]; then + if [ "$QUIET" -eq 1 ]; then + missing_arg "accent" + fi cat <&2 exit 1 ;; esac -echo "$ACCENTNAME($ACCENT) accent color was selected." +log "$ACCENTNAME($ACCENT) accent color was selected." # v2 cursors install to lowercase dirs and KDE keys the cursor theme off the dir name LCFLAVOUR=$(printf '%s' "$FLAVOURNAME" | tr '[:upper:]' '[:lower:]') @@ -234,6 +259,9 @@ GLOBALTHEMENAME="Catppuccin-$FLAVOURNAME-$ACCENTNAME" SPLASHSCREENNAME="Catppuccin-$FLAVOURNAME-$ACCENTNAME-splash" if [ -z "$WINDECSTYLE" ]; then + if [ "$QUIET" -eq 1 ]; then + missing_arg "window decoration" + fi cat </dev/null 2>&1 || + kpackagetool6 -t Plasma/LookAndFeel -u "$GLOBALTHEMENAME".tar.gz >/dev/null 2>&1 + else + kpackagetool6 -t Plasma/LookAndFeel -i "$GLOBALTHEMENAME".tar.gz || + kpackagetool6 -t Plasma/LookAndFeel -u "$GLOBALTHEMENAME".tar.gz + fi ) # Build SplashScreen - echo "Building SplashScreen.." + log "Building SplashScreen.." BuildSplashScreen } InstallColorscheme() { - echo "Building Colorscheme.." + log "Building Colorscheme.." # Generate Color scheme BuildColorscheme # Install Colorscheme - echo "Installing Colorscheme.." + log "Installing Colorscheme.." mv ./dist/Catppuccin"$FLAVOURNAME$ACCENTNAME".colors "$COLORDIR" } GetCursor() { # Fetches cursors - echo "Downloading Catppuccin Cursors from Catppuccin/cursors..." - sleep 2 + log "Downloading Catppuccin Cursors from Catppuccin/cursors..." + [ "$QUIET" -eq 1 ] || sleep 2 wget -q -P ./dist https://github.com/catppuccin/cursors/releases/download/"$CURSORVERSION"/"$CURSORACCENT".zip wget -q -P ./dist https://github.com/catppuccin/cursors/releases/download/"$CURSORVERSION"/"$CURSORDARK".zip ( @@ -418,13 +457,17 @@ InstallCursor() { mv ./dist/"$CURSORDARK" "$CURSORDIR" } -# Syntax +# Syntax [-q|--quiet] case "$DEBUGMODE" in "") - echo - echo "Install $FLAVOURNAME $ACCENTNAME? with the $WINDECSTYLENAME window Decorations? [y/N]:" - read -r CONFIRMATION - clear + if [ "$QUIET" -eq 1 ]; then + CONFIRMATION=Y + else + echo + echo "Install $FLAVOURNAME $ACCENTNAME? with the $WINDECSTYLENAME window Decorations? [y/N]:" + read -r CONFIRMATION + clear + fi ;; auto) CONFIRMATION=Y @@ -450,7 +493,7 @@ case "$DEBUGMODE" in BuildSplashScreen ;; cursor) GetCursor ;; - *) echo "Invalid Debug Mode" ;; + *) echo "Invalid Debug Mode" >&2 ;; esac if [ "$CONFIRMATION" = "Y" ] || [ "$CONFIRMATION" = "y" ]; then @@ -463,17 +506,17 @@ if [ "$CONFIRMATION" = "Y" ] || [ "$CONFIRMATION" = "y" ]; then # Build Colorscheme InstallColorscheme - echo "Installing Catppuccin Cursor theme.." + log "Installing Catppuccin Cursor theme.." InstallCursor # Cleanup - echo "Cleaning up.." + log "Cleaning up.." rm -r ./dist - if [ "$DEBUGMODE" != "auto" ]; then + if [ "$DEBUGMODE" != "auto" ] && [ "$QUIET" -ne 1 ]; then # Apply theme - echo - echo "Do you want to apply theme? [Y/n]:" + log "" + log "Do you want to apply theme? [Y/n]:" read -r CONFIRMATION fi @@ -483,18 +526,20 @@ if [ "$CONFIRMATION" = "Y" ] || [ "$CONFIRMATION" = "y" ]; then kwriteconfig6 --file kwinrc --group org.kde.kdecoration2 --key BorderSizeAuto false plasma-apply-lookandfeel -a "$GLOBALTHEMENAME" if [ "$DEBUGMODE" != "auto" ]; then - clear + [ "$QUIET" -eq 1 ] || clear fi # Some legacy apps still look in ~/.icons - cat <