vacuum-tube/config.py

34 lines
1.0 KiB
Python

import os
import toml
if 'XDG_CONFIG_HOME' in os.environ:
config_dir = os.environ['XDG_CONFIG_HOME']
else:
config_dir = os.path.join(os.environ['HOME'], '.config')
# if the config dir doesn't exist, create it
config_dir = os.path.join(config_dir, 'vacuum-tube')
os.makedirs(config_dir, exist_ok=True)
# create an example config file if it doesn't already exist
if not os.path.exists(config_dir + '/config.toml'):
with open(config_dir + '/config.toml', 'a+') as f:
f.write('''# Disable ascii art if you're using a screen reader or want smaller output
ascii_art = true
[repo]
# Example: `~/backups/backup.borg` or `ssh://agatha@some.place:22/~/backups/backup.borg`
path = ""
# Leave empty if none
# If repo is encrypted and no passphrase is provided, the program will ask you for one.
passphrase = ""
[disk]
# Example: `/dev/sda1`
partition = ""
# If the backup disk is remote, provide an ssh command.
# Otherwise, leave empty.
# Example: `ssh -p 22 agatha@some.place`
ssh = ""''')
config = toml.load(config_dir + '/config.toml')