X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=rainbowstream%2Frainbow.py;h=6b88c501c8dcd109c7ac000516f62f6751c91c97;hb=b84845b9062cd783bea1d206bc7355156550d45a;hp=ce5d99898171f1230bbc691782efb0782b3bd91f;hpb=c075e6dcf76153c0209b16e12771ae491f4b175a;p=rainbowstream.git diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index ce5d998..6b88c50 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -139,7 +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 += ['custom'] g['themes'] = themes + db.theme_store(c['theme']) def switch(): @@ -769,26 +771,53 @@ def theme(): if not g['stuff']: # List themes for theme in g['themes']: - line = ' ' * 2 + light_yellow('* ' + theme) + line = '' + # Detect custom config + if theme == 'custom': + line += light_magenta('custom') + 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 file at ~/.rainbow_config.json)') + else: + 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' + 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) - for nc in new_config: - c[nc] = new_config[nc] - # Reset stream - g['stuff'] = 'mine' - g['ascii_art'] = False - switch() + if new_config: + for nc in new_config: + c[nc] = new_config[nc] + # Update db and reset colors + db.theme_update(g['stuff']) + c['theme'] = g['stuff'] + notify_cycle() g['decorated_name'] = color_func( c['DECORATED_NAME'])( '[@' + g['original_name'] + ']: ') printNicely(green('Theme changed.')) except: - printNicely(red('Sorry, config file is broken!')) + if g['stuff'] == 'custom': + printNicely(red('~/.rainbow_config.json is not exists!')) + else: + printNicely(red('No such theme exists.')) def help():