diff options
Diffstat (limited to 'scripts/gen-default-cfg.py')
-rwxr-xr-x | scripts/gen-default-cfg.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/gen-default-cfg.py b/scripts/gen-default-cfg.py index c27b482..afcaed2 100755 --- a/scripts/gen-default-cfg.py +++ b/scripts/gen-default-cfg.py @@ -26,6 +26,27 @@ def writeItem(node, file): node = node.next +def writeConfigPaths(file): + # -1: invalid + # 0: $HOME + # 1: $XDG_CONFIG_HOME + + locations = [ + "$HOME/.poirc", + "$XDG_CONFIG_HOME/smolbote.conf", + "$XDG_CONFIG_HOME/smolbote/config", + "$HOME/.config/smolbote.conf", + "$HOME/.config/smolbote/config", + "/etc/smolbote/config"] + + for item in locations: + if item.startswith("$HOME/"): + print('\t\tstd::make_pair(0, "{}"),'.format(item[len("$HOME/"):]), file=file) + elif item.startswith("$XDG_CONFIG_HOME/"): + print('\t\tstd::make_pair(1, "{}"),'.format(item[len("$XDG_CONFIG_HOME/"):]), file=file) + else: + print('\t\tstd::make_pair(-1, "{}"),'.format(item), file=file) + if __name__ == "__main__": parser = argparse.ArgumentParser() @@ -47,5 +68,7 @@ if __name__ == "__main__": for line in args.input: if "@__DEFAULT_CFG__" in line: writeItem(kconf.top_node.list, file=args.output) + elif "@__CONFIG_PATHS__" in line: + writeConfigPaths(file=args.output) else: print(line, end='', file=args.output) |