[alacritty] Update config to toml

This commit is contained in:
Fabian Ising
2024-01-03 14:18:39 +01:00
parent d27b3c1101
commit fbac99c3c5
7 changed files with 122 additions and 1573 deletions

View File

@@ -0,0 +1,51 @@
import = ["/Users/ising/.config/alacritty/solarized_light.toml"]
live_config_reload = true
[env]
TERM = "alacritty"
[font]
size = 12
[font.bold]
family = "Fira Mono for Powerline"
style = "Bold"
[font.italic]
family = "Fira Mono for Powerline"
style = "Regular"
[font.normal]
family = "Fira Mono for Powerline"
style = "Medium"
[[keyboard.bindings]]
key = "F"
mods = "Control"
[keyboard.bindings.command]
args = ["-c", "python3 ~/.config/alacritty/color_switcher.py"]
program = "zsh"
[[keyboard.bindings]]
key = "T"
mods = "Command"
[keyboard.bindings.command]
args = ["-e", "zsh"]
program = "alacritty"
[scrolling]
history = 0
[shell]
args = ["-c", "$HOME/.tmux/tmux_attach.sh"]
program = "/bin/zsh"
[window]
dynamic_title = true
option_as_alt = "None"
[window.padding]
x = 0
y = 0

View File

@@ -1,44 +0,0 @@
import:
- ~/.config/alacritty/schemes.yml
env:
TERM: alacritty
font:
scale_with_dpi: true
# The size to use.
size: 12
# The normal (roman) font face to use.
normal:
family: "Fira Mono for Powerline"
# Style can be specified to pick a specific face.
style: Medium
bold:
family: "Fira Mono for Powerline"
# Style can be specified to pick a specific face.
style: Bold
italics:
family: "Fira Mono for Powerline"
# Style can be specified to pick a specific face.
style: Regular
window:
dynamic_title: true
padding:
x: 0
y: 0
option_as_alt: None
scrolling:
history: 0
shell:
program: /bin/zsh
args:
- "-c"
- "$HOME/.tmux/tmux_attach.sh"
live_config_reload: true
key_bindings:
- { key: F, mods: Control, command: {program: "zsh", args: ["-c","python3 ~/.config/alacritty/color_switcher.py"]} }
- { key: T, mods: Command, command: {program: "alacritty", args: ["-e","zsh"]} } # Spawn alacritty without tmux

View File

@@ -4,12 +4,13 @@ import os
import re
import sys
SCHEME_FILE_NAME = "schemes.yml"
ALACRITTY_CONFIG_FILE_NAME = "alacritty.toml"
CONFIG_FILE_DIR = os.path.expanduser("~/.config/alacritty/")
SCHEME_FILE_PATH = os.path.join(CONFIG_FILE_DIR, SCHEME_FILE_NAME)
ALACRITTY_CONFIG_FILE_PATH = os.path.join(CONFIG_FILE_DIR, ALACRITTY_CONFIG_FILE_NAME)
COLOR_SCHEME_LINE_SEARCH = "colors: \*(\S+)"
COLOR_SCHEME_LINE_TEMPLATE = "colors: *{}\n"
COLOR_SCHEME_LINE_SEARCH = r'import = \[.*\]'
ALACRITTY_LIGHT_THEME="solarized_light.toml"
ALACRITTY_DARK_THEME="dark_mode.toml"
NVIM_CONFIG_FILE_DIR = os.path.expanduser("~/.config/nvim/")
NVIM_CONFIG_FILE_NAME = "scheme.vim"
@@ -19,30 +20,31 @@ NVIM_COLOR_SCHEME_LINE_SEARCH = "set background=(\S+)\ncolorscheme (\S+)"
NVIM_COLOR_SCHEME_LINE_TEMPLATE = "set background={}\ncolorscheme {}"
def change_alacritty_theme(light_mode=None):
with open(SCHEME_FILE_PATH, "r") as scheme_file:
with open(ALACRITTY_CONFIG_FILE_PATH, "r") as scheme_file:
scheme_file.seek(0)
lines = scheme_file.readlines()
colors_line_index = -1
for i, line in enumerate(lines):
print(line)
match = re.search(COLOR_SCHEME_LINE_SEARCH, line)
print(match)
if match is not None:
current_color_scheme = match.group(1)
colors_line_index = i
color_line = lines[i]
break
if light_mode is None:
if current_color_scheme == "dark_mode":
new_scheme = "solarized_light"
if ALACRITTY_DARK_THEME in color_line:
color_line = color_line.replace(ALACRITTY_DARK_THEME, ALACRITTY_LIGHT_THEME)
else:
new_scheme = "dark_mode"
color_line = color_line.replace(ALACRITTY_LIGHT_THEME, ALACRITTY_DARK_THEME)
elif light_mode == True:
new_scheme = "solarized_light"
color_line = color_line.replace(ALACRITTY_DARK_THEME, ALACRITTY_LIGHT_THEME)
else:
new_scheme = "dark_mode"
lines[colors_line_index] = COLOR_SCHEME_LINE_TEMPLATE.format(
new_scheme)
with open(SCHEME_FILE_PATH, "w") as scheme_file:
color_line = color_line.replace(ALACRITTY_LIGHT_THEME, ALACRITTY_DARK_THEME)
lines[colors_line_index] = color_line
with open(ALACRITTY_CONFIG_FILE_PATH, "w") as scheme_file:
for line in lines:
scheme_file.write(line)

View File

@@ -0,0 +1,23 @@
[colors.bright]
black = "0x555753"
blue = "0x729fcf"
cyan = "0x34e2e2"
green = "0x8ae234"
magenta = "0xad7fa8"
red = "0xef2929"
white = "0xeeeeec"
yellow = "0xfce94f"
[colors.normal]
black = "0x2e3436"
blue = "0x3465a4"
cyan = "0x06989a"
green = "0x4e9a06"
magenta = "0x75507b"
red = "0xcc0000"
white = "0xd3d7cf"
yellow = "0xc4a000"
[colors.primary]
background = "0x323232"
foreground = "0xeeeeec"

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@ import os
import sys
import color_switcher
CONFIG_FILE_NAME = "alacritty.yml"
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)
@@ -22,20 +22,20 @@ def main(turn_on=False):
config_file.seek(0)
config_lines = config_file.readlines()
for i, line in enumerate(config_lines):
if "padding:" in line and "x:" in config_lines[i+1]:
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"
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"
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")
#color_switcher.main(len(sys.argv) == 2 and sys.argv[1] == "on")

View File

@@ -0,0 +1,23 @@
[colors.bright]
black = "0x002b36"
blue = "0x839496"
cyan = "0x93a1a1"
green = "0x586e75"
magenta = "0x6c71c4"
red = "0xcb4b16"
white = "0xfdf6e3"
yellow = "0x657b83"
[colors.normal]
black = "0x073642"
blue = "0x268bd2"
cyan = "0x2aa198"
green = "0x859900"
magenta = "0xd33682"
red = "0xdc322f"
white = "0xeee8d5"
yellow = "0xb58900"
[colors.primary]
background = "0xfdf6e3"
foreground = "0x586e75"