mirror of
https://git.srhtnin.garden/sarah/SaraTag.git
synced 2026-10-14 18:38:11 +02:00
Create the shared themes folder with the built-in themes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8eb9943a30
commit
f2e8f620bd
2 files changed
+46
-2
No files matched your search
@@ -44,8 +44,8 @@ ConfigPath = ConfigDir / "Config.toml"
|
||||
ProgramDir = Path(__file__).resolve().parent
|
||||
AssetsDir = ProgramDir / "assets"
|
||||
|
||||
# Themes SaraFem seeds into ThemesDir. Only other themes travel with an
|
||||
# export as full palettes (same rule as SaraFem's ExportSettings).
|
||||
# Only themes other than these travel with an export as full palettes (same
|
||||
# rule as SaraFem's ExportSettings).
|
||||
BuiltinThemeNames = {"CatppuccinMocha", "Forest", "Gruvbox"}
|
||||
|
||||
|
||||
@@ -77,10 +77,49 @@ _ThemeRoleMap = {
|
||||
}
|
||||
|
||||
|
||||
# The themes every SaraSuite program seeds into ThemesDir if they're missing
|
||||
# (same values as SaraFem's and SaraView's), so whichever program is installed
|
||||
# first, the folder and these three are there to choose from.
|
||||
BuiltinThemes: dict[str, dict[str, str]] = {
|
||||
"CatppuccinMocha": {
|
||||
"Background": "#1e1e2e", "Surface": "#181825", "SurfaceAlt": "#313244", "Border": "#45475a",
|
||||
"Text": "#cdd6f4", "TextMuted": "#6c7086", "Black": "#11111b", "White": "#cdd6f4",
|
||||
"Red": "#f38ba8", "Orange": "#fab387", "Yellow": "#f9e2af", "Green": "#a6e3a1",
|
||||
"Blue": "#89b4fa", "Purple": "#cba6f7",
|
||||
},
|
||||
"Forest": {
|
||||
"Background": "#1b2420", "Surface": "#141b17", "SurfaceAlt": "#243029", "Border": "#334539",
|
||||
"Text": "#d6e5d0", "TextMuted": "#7c9184", "Black": "#0d120f", "White": "#eef5ea",
|
||||
"Red": "#e0685a", "Orange": "#e0a458", "Yellow": "#e0c458", "Green": "#7fb069",
|
||||
"Blue": "#5c9e8f", "Purple": "#9b7fb0",
|
||||
},
|
||||
"Gruvbox": {
|
||||
"Background": "#282828", "Surface": "#1d2021", "SurfaceAlt": "#3c3836", "Border": "#504945",
|
||||
"Text": "#ebdbb2", "TextMuted": "#a89984", "Black": "#1d2021", "White": "#fbf1c7",
|
||||
"Red": "#fb4934", "Orange": "#fe8019", "Yellow": "#fabd2f", "Green": "#b8bb26",
|
||||
"Blue": "#83a598", "Purple": "#d3869b",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def EnsureSharedThemes() -> None:
|
||||
"""Create ThemesDir with the built-in themes that aren't there yet
|
||||
(never overwriting one: it may have been edited)."""
|
||||
try:
|
||||
ThemesDir.mkdir(parents=True, exist_ok=True)
|
||||
for Name, RoleValues in BuiltinThemes.items():
|
||||
ThemeFile = ThemesDir / f"{Name}.toml"
|
||||
if not ThemeFile.exists():
|
||||
ThemeFile.write_text(tomlkit.dumps({"Palette": RoleValues}))
|
||||
except OSError:
|
||||
pass # read-only or full: the built-in Catppuccin Mocha values still apply
|
||||
|
||||
|
||||
def ApplyTheme(ThemeName: str) -> None:
|
||||
"""Mutate Palette in place from ~/.config/SaraSuite/Themes/<ThemeName>.toml.
|
||||
Keeps the built-in Catppuccin Mocha values if the file is missing. Must
|
||||
run before any control reads Palette.X."""
|
||||
EnsureSharedThemes()
|
||||
ThemeFile = ThemesDir / f"{ThemeName}.toml"
|
||||
if not ThemeFile.exists():
|
||||
return
|
||||
@@ -94,6 +133,7 @@ def ApplyTheme(ThemeName: str) -> None:
|
||||
|
||||
|
||||
def AvailableThemes() -> list[str]:
|
||||
EnsureSharedThemes()
|
||||
Names = {ThemePath.stem for ThemePath in ThemesDir.glob("*.toml")} if ThemesDir.is_dir() else set()
|
||||
Names.add("CatppuccinMocha")
|
||||
return sorted(Names)
|
||||
|
||||
@@ -4,5 +4,9 @@
|
||||
# matches the window to {Name}.desktop (StartupWMClass) instead of showing it
|
||||
# as "com.appveyor.flet". Empty if that fails: Flet then uses its own client.
|
||||
export FLET_VIEW_PATH="$("{Python}" "{ProgramDir}/FletIdentity.py" "srhtnin.{Name}")"
|
||||
# Libraries Flet's window needs that this system lacks (libsecret), from
|
||||
# SaraSuite: FletIdentity.py puts them beside the client copy.
|
||||
Fallback="$FLET_VIEW_PATH/../fallback-libs"
|
||||
[ -n "$FLET_VIEW_PATH" ] && [ -d "$Fallback" ] && export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$Fallback"
|
||||
cd "{AppDir}" || exit 1
|
||||
exec "{Python}" Main.py "$@"
|
||||
Reference in new issue
Block a user