[alacritty] Screenshot mode
This commit is contained in:
@@ -3,10 +3,9 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
SCHEME_FILE_NAME = "schemes.yml"
|
||||||
CONFIG_FILE_NAME = "schemes.yml"
|
|
||||||
CONFIG_FILE_DIR = os.path.expanduser("~/.config/alacritty/")
|
CONFIG_FILE_DIR = os.path.expanduser("~/.config/alacritty/")
|
||||||
CONFIG_FILE_PATH = os.path.join(CONFIG_FILE_DIR, CONFIG_FILE_NAME)
|
SCHEME_FILE_PATH = os.path.join(CONFIG_FILE_DIR, SCHEME_FILE_NAME)
|
||||||
|
|
||||||
COLOR_SCHEME_LINE_SEARCH = "colors: \*(\S+)"
|
COLOR_SCHEME_LINE_SEARCH = "colors: \*(\S+)"
|
||||||
COLOR_SCHEME_LINE_TEMPLATE = "colors: *{}\n"
|
COLOR_SCHEME_LINE_TEMPLATE = "colors: *{}\n"
|
||||||
@@ -19,9 +18,9 @@ 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():
|
||||||
with open(CONFIG_FILE_PATH, "r") as config_file:
|
with open(SCHEME_FILE_PATH, "r") as scheme_file:
|
||||||
config_file.seek(0)
|
scheme_file.seek(0)
|
||||||
lines = config_file.readlines()
|
lines = scheme_file.readlines()
|
||||||
|
|
||||||
colors_line_index = -1
|
colors_line_index = -1
|
||||||
for i, line in enumerate(lines):
|
for i, line in enumerate(lines):
|
||||||
@@ -30,7 +29,6 @@ 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 current_color_scheme == "dark_mode":
|
if current_color_scheme == "dark_mode":
|
||||||
new_scheme = "solarized_light"
|
new_scheme = "solarized_light"
|
||||||
else:
|
else:
|
||||||
@@ -38,10 +36,10 @@ def change_alacritty_theme():
|
|||||||
|
|
||||||
lines[colors_line_index] = COLOR_SCHEME_LINE_TEMPLATE.format(
|
lines[colors_line_index] = COLOR_SCHEME_LINE_TEMPLATE.format(
|
||||||
new_scheme)
|
new_scheme)
|
||||||
|
with open(SCHEME_FILE_PATH, "w") as scheme_file:
|
||||||
with open(CONFIG_FILE_PATH, "w") as config_file:
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
config_file.write(line)
|
scheme_file.write(line)
|
||||||
|
|
||||||
return new_scheme
|
return new_scheme
|
||||||
|
|
||||||
def change_vim_theme(light_mode=False):
|
def change_vim_theme(light_mode=False):
|
||||||
|
|||||||
40
.config/alacritty/screenshot_mode.py
Normal file
40
.config/alacritty/screenshot_mode.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#! /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
|
||||||
|
|
||||||
|
CONFIG_FILE_NAME = "alacritty.yml"
|
||||||
|
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 "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")
|
||||||
|
|
||||||
Reference in New Issue
Block a user