Skip to content

Commit

Permalink
Merge pull request #442 from stablestud/master
Browse files Browse the repository at this point in the history
Improve Non-interactive use of script
  • Loading branch information
Mgldvd authored May 30, 2024
2 parents 12fccbc + 216b3f3 commit 50be184
Show file tree
Hide file tree
Showing 279 changed files with 2,034 additions and 3,606 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ gh-pages/node_modules
.stfolder
apply-colors-original.sh
.tmp
venv
.venv
.*.swp
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ bash -c "$(curl -sLo- https://git.io/vQgMr)"
<br/>

## ⚙️ Install (non-interactive mode)
Two ways:
* Clone repo
* Download only required files (bare minimum)

### Clone repo
```bash
# clone the repo into "$HOME/src/gogh"
# Clone the repo into "$HOME/src/gogh"
mkdir -p "$HOME/src"
cd "$HOME/src"
git clone https://github.com/Gogh-Co/Gogh.git gogh
Expand All @@ -119,6 +123,31 @@ cd installs
./dracula.sh
```

### Download only required files (bare minimum)
```bash
# Download apply script
wget https://github.com/Gogh-Co/Gogh/raw/master/apply-colors.sh
# Download desired themes from Gogh/installs dir like this one:
wget https://github.com/Gogh-Co/Gogh/raw/master/installs/selenized-dark.sh

# Optional - download Alacritty dependency (may require additional python packages, see requirements.txt for more)
wget https://github.com/Gogh-Co/Gogh/raw/master/apply-alacritty.py
# Optional - download Terminator dependency (may require additional python packages, see requirements.txt for more)
wget https://github.com/Gogh-Co/Gogh/raw/master/apply-terminator.py

# Note you can also tell the theme file where to find the the apply scripts with the following environmental variables:
# - GOGH_APPLY_SCRIPT=/path/to/file/apply-colors.sh
# - GOGH_ALACRITTY_SCRIPT=/path/to/file/apply-alacritty.py <-- only needed if applying to Alacritty terminal
# - GOGH_TERMINATOR_SCRIPT=/path/to/file/apply-terminator.py <-- only needed if applying to Terminator terminal

# Select for which terminal to install the theme (see apply-colors.sh for all supported terminals)
export TERMINAL=gnome-terminal
# Apply downloaded theme (apply script must be in the same folder)
bash ./selenized-dark.sh
# OR specify apply script path
GOGH_APPLY_SCRIPT=/path/to/file/apply-colors.sh bash ./selenized-dark.sh
```

<br/>

## 💻 Terminals
Expand Down
61 changes: 22 additions & 39 deletions apply-colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ GLOBAL_VAR_CLEANUP() {
unset PROFILE_NAME
}

SCRIPT_PATH="${SCRIPT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
PARENT_PATH="$(dirname "${SCRIPT_PATH}")"

# Note: Since all scripts gets invoked in a subshell the traps from the parent shell
# will not get inherited. Hence traps defined in gogh.sh and print-themes.sh will still trigger
trap 'GLOBAL_VAR_CLEANUP; trap - EXIT' EXIT HUP INT QUIT PIPE TERM
Expand Down Expand Up @@ -508,26 +511,14 @@ apply_alacritty() {
}\
}"

SCRIPT_PATH="${SCRIPT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
PARENT_PATH="$(dirname "${SCRIPT_PATH}")"

# Allow developer to change url to forked url for easier testing
# IMPORTANT: Make sure you export this variable if your main shell is not bash
BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/Gogh-Co/Gogh/master"}


if [[ -e "${SCRIPT_PATH}/apply-alacritty.py" ]]; then
if [[ -e "${GOGH_ALACRITTY_SCRIPT}" ]]; then
python3 "${GOGH_ALACRITTY_SCRIPT}" "$json_str"
elif [[ -e "${SCRIPT_PATH}/apply-alacritty.py" ]]; then
python3 "${SCRIPT_PATH}/apply-alacritty.py" "$json_str"
else
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
python3 -c "$(curl -so- "${BASE_URL}/apply-alacritty.py")" "$json_str"
else
# Linux ships with wget
python3 -c "$(wget -qO- "${BASE_URL}/apply-alacritty.py")" "$json_str"
fi
printf '\n%s\n' "Error: Couldn't find apply-alacritty.py file."
exit 1
fi

}

apply_terminator() {
Expand All @@ -548,24 +539,13 @@ apply_terminator() {
}\
}"

SCRIPT_PATH="${SCRIPT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
PARENT_PATH="$(dirname "${SCRIPT_PATH}")"

# Allow developer to change url to forked url for easier testing
# IMPORTANT: Make sure you export this variable if your main shell is not bash
BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/Gogh-Co/Gogh/master"}


if [[ -e "${SCRIPT_PATH}/apply-terminator.py" ]]; then
if [[ -e "${GOGH_TERMINATOR_SCRIPT}" ]]; then
python3 "${GOGH_TERMINATOR_SCRIPT}" "$json_str"
elif [[ -e "${SCRIPT_PATH}/apply-terminator.py" ]]; then
python3 "${SCRIPT_PATH}/apply-terminator.py" "$json_str"
else
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
python3 -c "$(curl -so- "${BASE_URL}/apply-terminator.py")" "$json_str"
else
# Linux ships with wget
python3 -c "$(wget -qO- "${BASE_URL}/apply-terminator.py")" "$json_str"
fi
printf '\n%s\n' "Error: Couldn't find apply-terminator.py."
exit 1
fi

}
Expand Down Expand Up @@ -1118,7 +1098,7 @@ case "${TERMINAL}" in
;;

terminator )
apply_terminator
apply_terminator
;;

foot )
Expand Down Expand Up @@ -1146,10 +1126,12 @@ case "${TERMINAL}" in
"Unsupported terminal!" \
"" \
"Supported terminals:" \
" mintty and deriviates" \
" alacritty" \
" mintty (and deriviates)" \
" guake" \
" iTerm2" \
" elementary terminal (pantheon/elementary)" \
" iTerm.app (iTerm2)" \
" pantheon-terminal" \
" io.elementary.t* (elementary terminal)" \
" mate-terminal" \
" gnome-terminal" \
" tilix" \
Expand All @@ -1158,11 +1140,12 @@ case "${TERMINAL}" in
" kitty" \
" kmscon" \
" konsole" \
" linux" \
" linux (linux vt)" \
" terminator" \
"" \
"If you believe you have received this message in error," \
"try manually setting \`TERMINAL', hint: ps -h -o comm -p \$PPID"
"try manually setting env \`TERMINAL' with the value above." \
"hint: ps -h -o comm -p \$PPID"
exit 1
;;

Expand Down
62 changes: 59 additions & 3 deletions gogh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

# Define traps and trapfunctions early in case any errors before script exits
GLOBAL_VAR_CLEANUP(){
echo "Cleanup up..."
[[ -n "$(command -v TILIX_TMP_CLEANUP)" ]] && TILIX_TMP_CLEANUP
[[ -n "$(command -v ALACRITTY_APPLY_TMP_CLEANUP)" ]] && ALACRITTY_APPLY_TMP_CLEANUP
[[ -n "$(command -v TERMINATOR_APPLY_TMP_CLEANUP)" ]] && TERMINATOR_APPLY_TMP_CLEANUP
[[ -n "$(command -v APPLY_SCRIPT_TMP_CLEANUP)" ]] && APPLY_SCRIPT_TMP_CLEANUP
unset PROFILE_NAME
unset PROFILE_SLUG
unset TILIX_RES
unset TERMINAL
echo "Done"
}

trap 'GLOBAL_VAR_CLEANUP; trap - EXIT' EXIT HUP INT QUIT PIPE TERM
Expand Down Expand Up @@ -293,6 +298,8 @@ declare -a THEMES=(
BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/Gogh-Co/Gogh/master"}
PROGRESS_URL="https://raw.githubusercontent.com/phenonymous/shell-progressbar/1.0/progress.sh"

SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

capitalize() {
local ARGUMENT=$1
local RES=""
Expand All @@ -309,6 +316,57 @@ capitalize() {
}


# Used to get required python scripts, either from the internet or from local directory
if [[ ! -f "${SCRIPT_PATH}/apply-alacritty.py" ]]; then
ALACRITTY_APPLY_TMP_CLEANUP() {
rm -rf "${GOGH_ALACRITTY_SCRIPT}"
unset GOGH_ALACRITTY_SCRIPT
}
export GOGH_ALACRITTY_SCRIPT="$(mktemp -t gogh.alacritty.XXXXXX)"
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
curl -so "${GOGH_ALACRITTY_SCRIPT}" "${BASE_URL}/apply-alacritty.py"
else
# Linux ships with wget
wget -qO "${GOGH_ALACRITTY_SCRIPT}" "${BASE_URL}/apply-alacritty.py"
fi
fi


# Used to get required python scripts, either from the internet or from local directory
if [[ ! -e "${SCRIPT_PATH}/apply-terminator.py" ]]; then
TERMINATOR_APPLY_TMP_CLEANUP() {
rm -rf "${GOGH_TERMINATOR_SCRIPT}"
unset GOGH_TERMINATOR_SCRIPT
}
export GOGH_TERMINATOR_SCRIPT="$(mktemp -t gogh.terminator.XXXXXX)"
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
curl -so "${GOGH_TERMINATOR_SCRIPT}" "${BASE_URL}/apply-terminator.py"
else
# Linux ships with wget
wget -qO "${GOGH_TERMINATOR_SCRIPT}" "${BASE_URL}/apply-terminator.py"
fi
fi


# Used to get required shell scripts, either from the internet or from local directory
if [[ ! -e "${SCRIPT_PATH}/apply-colors.sh" ]]; then
APPLY_SCRIPT_TMP_CLEANUP() {
rm -rf "${GOGH_APPLY_SCRIPT}"
unset GOGH_APPLY_SCRIPT
}
export GOGH_APPLY_SCRIPT="$(mktemp -t gogh.apply.XXXXXX)"
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
curl -so "${GOGH_APPLY_SCRIPT}" "${BASE_URL}/apply-colors.sh"
else
# Linux ships with wget
wget -qO "${GOGH_APPLY_SCRIPT}" "${BASE_URL}/apply-colors.sh"
fi
fi


set_gogh() {
string=$1
string_r="${string%???}"
Expand All @@ -318,8 +376,6 @@ set_gogh() {

export {PROFILE_NAME,PROFILE_SLUG}="$result"

# Evaluate if Gogh was called from local source - i.e cloned repo
SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ -e "${SCRIPT_PATH}/installs/$1" ]]; then
bash "${SCRIPT_PATH}/installs/$1"
else
Expand Down Expand Up @@ -475,7 +531,7 @@ if [[ "$TERMINAL" = "tilix" ]] && [[ ${#OPTION[@]} -gt 0 ]]; then
exit 0
}

scratchdir=$(mktemp -d -t tmp.XXXXXXXX)
scratchdir=$(mktemp -d -t gogh.tilix.XXXXXXXX)
export scratchdir
fi
fi
Expand Down
20 changes: 7 additions & 13 deletions installs/3024-day.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,13 @@ export CURSOR_COLOR="#4A4543" # Cursor
SCRIPT_PATH="${SCRIPT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
PARENT_PATH="$(dirname "${SCRIPT_PATH}")"

# Allow developer to change url to forked url for easier testing
# IMPORTANT: Make sure you export this variable if your main shell is not bash
BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/Gogh-Co/Gogh/master"}


if [[ -e "${PARENT_PATH}/apply-colors.sh" ]]; then
if [[ -e "${GOGH_APPLY_SCRIPT}" ]]; then
bash "${GOGH_APPLY_SCRIPT}"
elif [[ -e "${PARENT_PATH}/apply-colors.sh" ]]; then
bash "${PARENT_PATH}/apply-colors.sh"
elif [[ -e "${SCRIPT_PATH}/apply-colors.sh" ]]; then
bash "${SCRIPT_PATH}/apply-colors.sh"
else
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
bash -c "$(curl -so- "${BASE_URL}/apply-colors.sh")"
else
# Linux ships with wget
bash -c "$(wget -qO- "${BASE_URL}/apply-colors.sh")"
fi
printf '\n%s\n' "Error: Couldn't find apply-colors.sh"
exit 1
fi
20 changes: 7 additions & 13 deletions installs/3024-night.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,13 @@ export CURSOR_COLOR="#A5A2A2" # Cursor
SCRIPT_PATH="${SCRIPT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
PARENT_PATH="$(dirname "${SCRIPT_PATH}")"

# Allow developer to change url to forked url for easier testing
# IMPORTANT: Make sure you export this variable if your main shell is not bash
BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/Gogh-Co/Gogh/master"}


if [[ -e "${PARENT_PATH}/apply-colors.sh" ]]; then
if [[ -e "${GOGH_APPLY_SCRIPT}" ]]; then
bash "${GOGH_APPLY_SCRIPT}"
elif [[ -e "${PARENT_PATH}/apply-colors.sh" ]]; then
bash "${PARENT_PATH}/apply-colors.sh"
elif [[ -e "${SCRIPT_PATH}/apply-colors.sh" ]]; then
bash "${SCRIPT_PATH}/apply-colors.sh"
else
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
bash -c "$(curl -so- "${BASE_URL}/apply-colors.sh")"
else
# Linux ships with wget
bash -c "$(wget -qO- "${BASE_URL}/apply-colors.sh")"
fi
printf '\n%s\n' "Error: Couldn't find apply-colors.sh"
exit 1
fi
20 changes: 7 additions & 13 deletions installs/aci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,13 @@ export CURSOR_COLOR="#B4E1FD" # Cursor
SCRIPT_PATH="${SCRIPT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
PARENT_PATH="$(dirname "${SCRIPT_PATH}")"

# Allow developer to change url to forked url for easier testing
# IMPORTANT: Make sure you export this variable if your main shell is not bash
BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/Gogh-Co/Gogh/master"}


if [[ -e "${PARENT_PATH}/apply-colors.sh" ]]; then
if [[ -e "${GOGH_APPLY_SCRIPT}" ]]; then
bash "${GOGH_APPLY_SCRIPT}"
elif [[ -e "${PARENT_PATH}/apply-colors.sh" ]]; then
bash "${PARENT_PATH}/apply-colors.sh"
elif [[ -e "${SCRIPT_PATH}/apply-colors.sh" ]]; then
bash "${SCRIPT_PATH}/apply-colors.sh"
else
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
bash -c "$(curl -so- "${BASE_URL}/apply-colors.sh")"
else
# Linux ships with wget
bash -c "$(wget -qO- "${BASE_URL}/apply-colors.sh")"
fi
printf '\n%s\n' "Error: Couldn't find apply-colors.sh"
exit 1
fi
20 changes: 7 additions & 13 deletions installs/aco.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,13 @@ export CURSOR_COLOR="#B4E1FD" # Cursor
SCRIPT_PATH="${SCRIPT_PATH:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
PARENT_PATH="$(dirname "${SCRIPT_PATH}")"

# Allow developer to change url to forked url for easier testing
# IMPORTANT: Make sure you export this variable if your main shell is not bash
BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/Gogh-Co/Gogh/master"}


if [[ -e "${PARENT_PATH}/apply-colors.sh" ]]; then
if [[ -e "${GOGH_APPLY_SCRIPT}" ]]; then
bash "${GOGH_APPLY_SCRIPT}"
elif [[ -e "${PARENT_PATH}/apply-colors.sh" ]]; then
bash "${PARENT_PATH}/apply-colors.sh"
elif [[ -e "${SCRIPT_PATH}/apply-colors.sh" ]]; then
bash "${SCRIPT_PATH}/apply-colors.sh"
else
if [[ "$(uname)" = "Darwin" ]]; then
# OSX ships with curl and ancient bash
bash -c "$(curl -so- "${BASE_URL}/apply-colors.sh")"
else
# Linux ships with wget
bash -c "$(wget -qO- "${BASE_URL}/apply-colors.sh")"
fi
printf '\n%s\n' "Error: Couldn't find apply-colors.sh"
exit 1
fi
Loading

0 comments on commit 50be184

Please sign in to comment.