53 lines
1.6 KiB
Python
Executable File
53 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import subprocess
|
|
from argparse import ArgumentParser
|
|
from pathlib import Path
|
|
|
|
if __name__ == "__main__":
|
|
parser = ArgumentParser(description="Alacritty theme switcher")
|
|
parser.add_argument(
|
|
"mode",
|
|
help="The mode to switch the Alacritty theme to (e.g., 'dark' or 'light')",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
if args.mode not in ["dark", "light"]:
|
|
print("Invalid mode. Please choose 'dark' or 'light'.")
|
|
exit(1)
|
|
|
|
"""
|
|
The Alacritty config directory should contain the following files:
|
|
└── themes
|
|
├── current.toml -> dark/default.toml
|
|
├── dark
|
|
│ └── default.toml
|
|
└── light
|
|
└── default.toml
|
|
|
|
The default.toml files can be symlinks to the actual theme files, so you can easily switch between
|
|
different themes by changing the symlink target.
|
|
|
|
To change the light/dark theme, we can simply change the current.toml symlink to point to the
|
|
appropriate theme file.
|
|
"""
|
|
|
|
alacritty_config = Path.home() / ".config/alacritty"
|
|
themes_dir = alacritty_config / "themes"
|
|
current_theme = themes_dir / "current.toml"
|
|
target_theme = themes_dir / args.mode / "default.toml"
|
|
|
|
if not target_theme.exists():
|
|
print(f"Target theme file not found at {target_theme}")
|
|
exit(1)
|
|
|
|
if current_theme.exists() and not current_theme.is_symlink():
|
|
print(f"Current theme file {current_theme} is not a symlink. Please fix this manually.")
|
|
exit(1)
|
|
|
|
if current_theme.exists():
|
|
current_theme.unlink()
|
|
|
|
current_theme.symlink_to(target_theme)
|
|
|
|
print("Done!") |