Skip to content

Commit

Permalink
Merge pull request #443 from stablestud/master
Browse files Browse the repository at this point in the history
Add GOGH_NONINTERACTIVE flag for non-interactive mode
  • Loading branch information
Mgldvd committed May 31, 2024
2 parents 50be184 + 5eff551 commit a989352
Show file tree
Hide file tree
Showing 278 changed files with 4,515 additions and 2,276 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,27 @@ cd installs
```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:
# Download desired themes from ./installs/ like this:
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
# You can also specify where to find the apply scripts with the following environmental variables
GOGH_APPLY_SCRIPT=/path/to/apply-colors.sh
GOGH_ALACRITTY_SCRIPT=/path/to/apply-alacritty.py # only needed if applying to Alacritty terminal
GOGH_TERMINATOR_SCRIPT=/path/to/apply-terminator.py # only needed if applying to Terminator terminal

# Control Gogh behavior with the following environmental variables
TERMINAL=gnome-terminal # Select for which terminal to install the theme
# (see apply-colors.sh for all supported terminals)
GOGH_NONINTERACTIVE= # Make output silent and answer all prompts with default value
# (errors will still be printed)

# 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
TERMINAL=gnome-terminal bash ./selenized-dark.sh
# OR specify apply script path
GOGH_APPLY_SCRIPT=/path/to/file/apply-colors.sh bash ./selenized-dark.sh
```
Expand Down
24 changes: 15 additions & 9 deletions apply-alacritty.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from ruamel.yaml import YAML # use ruamel.yaml to preserve comments in config


def printerr(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)


def get_conf_path():
# Determine system
# When we are in some Java world do extra checks
Expand Down Expand Up @@ -58,7 +62,7 @@ def get_conf_path():
if home is not None and os.path.exists(home + '/.alacritty.toml'):
return home + "/.alacritty.toml"

print("Could not find alacritty config file\nPlease make sure you have a file in one of the paths specified on\nhttps://github.com/alacritty/alacritty#configuration")
printerr("Could not find alacritty config file\nPlease make sure you have a file in one of the paths specified on\nhttps://github.com/alacritty/alacritty#configuration")
sys.exit(1)
# end

Expand All @@ -74,6 +78,7 @@ def get_conf_path():
with open(conf_path, 'rb') as stream:
data_loaded = tomli.load(stream)
else:
printerr(f'Config parsing no available for config file {conf_path}')
raise NotImplementedError(f'Config parsing not available for config file {conf_path}')

# parse new colors
Expand All @@ -86,17 +91,18 @@ def get_conf_path():
data_loaded['colors']['normal'].update(js['colors']['normal'])
data_loaded['colors']['bright'].update(js['colors']['bright'])
except KeyError:
print("Could not find existing 'colors' settings in your alacritty.yml file\nplease make sure to uncomment\n'colors', as well as 'primary', 'normal' and 'bright'")
print("Check the example config at\nhttps://github.com/alacritty/alacritty/releases/download/v0.12.2/alacritty.yml for more information")
print("Note that alacritty following release 0.13.0 uses toml configuration.")
printerr("Could not find existing 'colors' settings in your alacritty.yml file\nplease make sure to uncomment\n'colors', as well as 'primary', 'normal' and 'bright'")
printerr("Check the example config at\nhttps://github.com/alacritty/alacritty/releases/download/v0.12.2/alacritty.yml for more information")
printerr("Note that alacritty following release 0.13.0 uses toml configuration.")
sys.exit(1)

# make sure the user is okay with having their config changed
answer = input("This script will update your alacritty config at: \n" +
conf_path + "\nIt is recommended to make a copy of this file before proceeding.\nAre you sure you want to continue? (Y/N)\n")
if answer.lower() not in ['y', 'yes']:
print("Aborted")
sys.exit(1)
if not "GOGH_NONINTERACTIVE" in os.environ:
answer = input("This script will update your alacritty config at: \n" +
conf_path + "\nIt is recommended to make a copy of this file before proceeding.\nAre you sure you want to continue? (Y/N)\n")
if answer.lower() not in ['y', 'yes']:
print("Aborted")
sys.exit(1)

# Write alacritty config
if conf_path.endswith('yml'):
Expand Down
Loading

0 comments on commit a989352

Please sign in to comment.