X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=blobdiff_plain;f=rainbowstream%2Frainbow.py;h=84aff931b5318c2321d43d7c095acccf9b0368b8;hp=71957448716fe6bcd05f3207d215125dd49de888;hb=bb03272e3286e31f09e30a72159d3b683fefb7fb;hpb=a5301bc04171f5a7cb1a928ced38e912628cfa85 diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 7195744..84aff93 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -139,8 +139,9 @@ def get_decorated_name(): files = os.listdir('rainbowstream/colorset') themes = [f.split('.')[0] for f in files if f.split('.')[-1] == 'json'] - themes += ['user'] + themes += ['custom'] g['themes'] = themes + db.theme_store(c['theme']) def switch(): @@ -769,37 +770,50 @@ def theme(): """ if not g['stuff']: # List themes - line = ' ' * 2 + light_yellow('* ') for theme in g['themes']: + line = '' # Detect custom config - if theme == 'user': + if theme == 'custom': line += light_magenta('custom') - exists = db.theme_query() - themes = [t.theme_name for t in exists] - if themes[0] == 'user': - line += light_magenta(' (applied)') + custom_path = os.environ.get( + 'HOME', + os.environ.get('USERPROFILE', + '')) + os.sep + '.rainbow_config.json' + if not os.path.exists(custom_path): + line += light_magenta(' (create your own config at ~/.rainbow_config.json)') else: - line += light_magenta(' (not specified)') + line += light_magenta(' (loaded)') else: line += light_magenta(theme) + if c['theme'] == theme : + line = ' '*2 + light_yellow('* ') + line + else: + line = ' '*4 + line printNicely(line) else: # Change theme try: # Load new config - new_config = 'rainbowstream/colorset/' + g['stuff'] + '.json' + c['theme'] = g['stuff'] + if g['stuff'] != 'custom': + new_config = 'rainbowstream/colorset/' + g['stuff'] + '.json' + else: + new_config = os.environ.get( + 'HOME',os.environ.get( + 'USERPROFILE', + '')) + os.sep + '.rainbow_config.json' new_config = load_config(new_config) - if new_config + if new_config: for nc in new_config: c[nc] = new_config[nc] - # Update db - theme_update(g['stuff']) + # Update db and reset colors + db.theme_update(g['stuff']) g['decorated_name'] = color_func( c['DECORATED_NAME'])( '[@' + g['original_name'] + ']: ') printNicely(green('Theme changed.')) except: - printNicely(red('Sorry, config file is broken!')) + printNicely(red('Sorry, can not load config file!')) def help():