#! /usr/bin/env python3
# vim:fenc=utf-8
#
# Copyright © 2023 ising <ising@mac-nurmi>
#
# Distributed under terms of the MIT license.

"""

"""
import os
import sys
import color_switcher

CONFIG_FILE_NAME = "alacritty.toml"
CONFIG_FILE_DIR = os.path.expanduser("~/.config/alacritty/")
CONFIG_FILE_PATH = os.path.join(CONFIG_FILE_DIR, CONFIG_FILE_NAME)

def main(turn_on=False):
    padding_line = None
    with open(CONFIG_FILE_PATH, "r") as config_file:
        config_file.seek(0)
        config_lines = config_file.readlines()
        for i, line in enumerate(config_lines):
            if "[window.padding]" in line and "x =" in config_lines[i+1]:
                padding_line = i
    if padding_line is None:
        return
    if turn_on:
        config_lines[padding_line+1] = "x = 10\n"
        config_lines[padding_line+2] = "y = 10\n"
    else:
        config_lines[padding_line+1] = "x = 0\n"
        config_lines[padding_line+2] = "y = 0\n"
    with open(CONFIG_FILE_PATH, "w") as config_file:
        for line in config_lines:
            config_file.write(line)

if __name__=="__main__":
    main(len(sys.argv) == 2 and sys.argv[1] == "on")
    #color_switcher.main(len(sys.argv) == 2 and sys.argv[1] == "on")
