Skip to content

Commit

Permalink
fixed to choose profile
Browse files Browse the repository at this point in the history
  • Loading branch information
gabsbandeira committed Feb 13, 2024
1 parent b833f00 commit 11cbbf0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ cd installs
- Pantheon / Elementary - [Web](https://github.com/elementary/terminal)
- Tilix - [Web](https://gnunn1.github.io/tilix-web/)
- XFCE4 - [Web](https://docs.xfce.org/apps/terminal/start)
- Terminator - [Web](https://github.com/gnome-terminator/terminator)

<br/>

Expand Down
3 changes: 2 additions & 1 deletion apply-colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ case "${TERMINAL}" in

* )
printf '%s\n' \
"Unsupported terminal! ${TERMINAL}" \
"Unsupported terminal!" \
"" \
"Supported terminals:" \
" mintty and deriviates" \
Expand All @@ -1159,6 +1159,7 @@ case "${TERMINAL}" in
" kmscon" \
" konsole" \
" linux" \
" terminator" \
"" \
"If you believe you have received this message in error," \
"try manually setting \`TERMINAL', hint: ps -h -o comm -p \$PPID"
Expand Down
48 changes: 39 additions & 9 deletions apply-terminator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,51 @@

from configobj import ConfigObj

def get_conf_path():
def main(gogh_conf_theme):
terminator_conf_file_path = get_terminator_conf_path()
profile_options = choose_profile()
update_terminator_conf(terminator_conf_file_path, gogh_conf_theme, profile_options)



def get_terminator_conf_path():
try:
configdir = os.environ['XDG_CONFIG_HOME']
except KeyError:
configdir = os.path.join(os.path.expanduser('~'), '.config')
return(os.path.join(configdir, 'terminator/config'))
# end


conf_path = get_conf_path()
def update_terminator_conf(terminator_conf_file_path,gogh_conf_theme,profile_options):
js = json.loads(gogh_conf_theme)

config = ConfigObj(terminator_conf_file_path)

if profile_options["copy_default_config"] == 'yes':
config['profiles'][profile_options["profile"]] = config['profiles']['default']
elif profile_options["copy_default_config"] == 'no':
config['profiles'][profile_options["profile"]] = {}

use_theme_colors = False
config['profiles'][profile_options["profile"]]['foreground_color'] = js['colors']['primary']['foreground']
config['profiles'][profile_options["profile"]]['background_color'] = js['colors']['primary']['background']
config['profiles'][profile_options["profile"]]['palette'] = js['colors']['pallete']
config.write()


def choose_profile():
profile_answer = ''
copy_default_config_answer = ''
profile_answer = input("Enter profile to update/create [default]: ")
if profile_answer.lower() in ['', 'default']:
profile_answer = 'default'
else:
copy_default_config_answer = input("Do you want to copy your config from default profile? [Y]: (Y/N) ")
if copy_default_config_answer.lower() in ['', 'yes', 'y']:
copy_default_config_answer = 'yes'
else:
copy_default_config_answer = 'no'
return {"profile": profile_answer, "copy_default_config": copy_default_config_answer}

js = json.loads(sys.argv[1])

config = ConfigObj(conf_path)
config['profiles']['default']['foreground_color'] = js['colors']['primary']['foreground']
config['profiles']['default']['background_color'] = js['colors']['primary']['background']
config['profiles']['default']['palette'] = js['colors']['pallete']
config.write()
main(sys.argv[1])

0 comments on commit 11cbbf0

Please sign in to comment.