From 2303f6f7f35bdb4d87f780e81bcc1c3ac04808b1 Mon Sep 17 00:00:00 2001 From: Fabian Ising Date: Mon, 18 Sep 2023 10:26:30 +0200 Subject: [PATCH] [alacritty] Fix some color stuff --- .config/alacritty/color_switcher.py | 19 ++++++++++++++----- .config/alacritty/screenshot_mode.py | 3 ++- .gitignore | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.config/alacritty/color_switcher.py b/.config/alacritty/color_switcher.py index 568032b..e4c44c8 100755 --- a/.config/alacritty/color_switcher.py +++ b/.config/alacritty/color_switcher.py @@ -2,6 +2,7 @@ import os import re +import sys SCHEME_FILE_NAME = "schemes.yml" CONFIG_FILE_DIR = os.path.expanduser("~/.config/alacritty/") @@ -17,7 +18,7 @@ NVIM_CONFIG_FILE_PATH = os.path.join(NVIM_CONFIG_FILE_DIR, NVIM_CONFIG_FILE_NAME NVIM_COLOR_SCHEME_LINE_SEARCH = "set background=(\S+)\ncolorscheme (\S+)" NVIM_COLOR_SCHEME_LINE_TEMPLATE = "set background={}\ncolorscheme {}" -def change_alacritty_theme(): +def change_alacritty_theme(light_mode=None): with open(SCHEME_FILE_PATH, "r") as scheme_file: scheme_file.seek(0) lines = scheme_file.readlines() @@ -29,7 +30,12 @@ def change_alacritty_theme(): current_color_scheme = match.group(1) colors_line_index = i - if current_color_scheme == "dark_mode": + if light_mode is None: + if current_color_scheme == "dark_mode": + new_scheme = "solarized_light" + else: + new_scheme = "dark_mode" + elif light_mode == True: new_scheme = "solarized_light" else: new_scheme = "dark_mode" @@ -55,10 +61,13 @@ def change_vim_theme(light_mode=False): config = config_file.write(res) -def main(): - new_theme = change_alacritty_theme() +def main(light_mode=None): + new_theme = change_alacritty_theme(light_mode) change_vim_theme(new_theme == "solarized_light") if __name__=="__main__": - main() + if len(sys.argv) == 2: + main(sys.argv == "light") + else: + main() diff --git a/.config/alacritty/screenshot_mode.py b/.config/alacritty/screenshot_mode.py index b94123f..955d542 100644 --- a/.config/alacritty/screenshot_mode.py +++ b/.config/alacritty/screenshot_mode.py @@ -10,6 +10,7 @@ """ import os import sys +import color_switcher CONFIG_FILE_NAME = "alacritty.yml" CONFIG_FILE_DIR = os.path.expanduser("~/.config/alacritty/") @@ -37,4 +38,4 @@ def main(turn_on=False): 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") diff --git a/.gitignore b/.gitignore index 3ced92b..ed97d19 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.swp tags .DS_STORE +__pycache__