[alacritty] Fix some color stuff
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
SCHEME_FILE_NAME = "schemes.yml"
|
SCHEME_FILE_NAME = "schemes.yml"
|
||||||
CONFIG_FILE_DIR = os.path.expanduser("~/.config/alacritty/")
|
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_SEARCH = "set background=(\S+)\ncolorscheme (\S+)"
|
||||||
NVIM_COLOR_SCHEME_LINE_TEMPLATE = "set background={}\ncolorscheme {}"
|
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:
|
with open(SCHEME_FILE_PATH, "r") as scheme_file:
|
||||||
scheme_file.seek(0)
|
scheme_file.seek(0)
|
||||||
lines = scheme_file.readlines()
|
lines = scheme_file.readlines()
|
||||||
@@ -29,10 +30,15 @@ def change_alacritty_theme():
|
|||||||
current_color_scheme = match.group(1)
|
current_color_scheme = match.group(1)
|
||||||
colors_line_index = i
|
colors_line_index = i
|
||||||
|
|
||||||
|
if light_mode is None:
|
||||||
if current_color_scheme == "dark_mode":
|
if current_color_scheme == "dark_mode":
|
||||||
new_scheme = "solarized_light"
|
new_scheme = "solarized_light"
|
||||||
else:
|
else:
|
||||||
new_scheme = "dark_mode"
|
new_scheme = "dark_mode"
|
||||||
|
elif light_mode == True:
|
||||||
|
new_scheme = "solarized_light"
|
||||||
|
else:
|
||||||
|
new_scheme = "dark_mode"
|
||||||
|
|
||||||
lines[colors_line_index] = COLOR_SCHEME_LINE_TEMPLATE.format(
|
lines[colors_line_index] = COLOR_SCHEME_LINE_TEMPLATE.format(
|
||||||
new_scheme)
|
new_scheme)
|
||||||
@@ -55,10 +61,13 @@ def change_vim_theme(light_mode=False):
|
|||||||
config = config_file.write(res)
|
config = config_file.write(res)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(light_mode=None):
|
||||||
new_theme = change_alacritty_theme()
|
new_theme = change_alacritty_theme(light_mode)
|
||||||
change_vim_theme(new_theme == "solarized_light")
|
change_vim_theme(new_theme == "solarized_light")
|
||||||
|
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
main(sys.argv == "light")
|
||||||
|
else:
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import color_switcher
|
||||||
|
|
||||||
CONFIG_FILE_NAME = "alacritty.yml"
|
CONFIG_FILE_NAME = "alacritty.yml"
|
||||||
CONFIG_FILE_DIR = os.path.expanduser("~/.config/alacritty/")
|
CONFIG_FILE_DIR = os.path.expanduser("~/.config/alacritty/")
|
||||||
@@ -37,4 +38,4 @@ def main(turn_on=False):
|
|||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
main(len(sys.argv) == 2 and sys.argv[1] == "on")
|
main(len(sys.argv) == 2 and sys.argv[1] == "on")
|
||||||
|
color_switcher.main(len(sys.argv) == 2 and sys.argv[1] == "on")
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
*.swp
|
*.swp
|
||||||
tags
|
tags
|
||||||
.DS_STORE
|
.DS_STORE
|
||||||
|
__pycache__
|
||||||
|
|||||||
Reference in New Issue
Block a user