macOS support (code only, no build yet)

This commit is contained in:
sarah committed 2026-10-14 13:18:20 +02:00
1 parent 1feb6d4336
commit ca04dcd4a7
17 files changed
+572 -126

No files matched your search

+18 -8
View File
@@ -1,11 +1,13 @@
"""Shared app-wide constants: paths, palette, theme.
Paths follow each system's own per-user conventions (no admin needed):
Linux Windows
~/.config %APPDATA% (settings; roams with the user)
~/.local/share %LOCALAPPDATA% (installed programs, SaraSuite's data)
~/.cache %LOCALAPPDATA% (caches, in a Cache/Downloads subfolder)
so the SaraSuite layout below them (SaraSuite/<Program>/...) is the same on both.
Linux Windows macOS
~/.config %APPDATA% ~/Library/Application Support (settings)
~/.local/share %LOCALAPPDATA% ~/Library/Application Support (programs, SaraSuite's data)
~/.cache %LOCALAPPDATA% ~/Library/Caches (caches)
so the SaraSuite layout below them (SaraSuite/<Program>/...) is the same on all
three. (On macOS settings and data share one folder, as Mac apps' do: the
programs' config folders and SaraSuite's Programs, Receipts, ... sit side by side.)
The palette and theming mirror SaraFem's Core.py (which mirrors SaraView's),
and read the same shared ~/.config/SaraSuite/Themes/*.toml files, so a theme
@@ -28,7 +30,10 @@ AppName = "SaraSuite"
AppVersion = "1.2.5"
IsFrozen = bool(getattr(sys, "frozen", False)) # running from the AppImage / .exe
IsWindows = sys.platform == "win32"
Platform = "Windows" if IsWindows else "Linux" # matches manifests' Platforms / Platform
IsMac = sys.platform == "darwin"
IsLinux = not IsWindows and not IsMac
# Matches manifests' Platforms / Platform.
Platform = "Windows" if IsWindows else "macOS" if IsMac else "Linux"
# Bundled in assets/fonts and always registered, so it works as FontFamily
# without being installed. Any other FontFamily is looked up among the
# system's installed fonts.
@@ -44,6 +49,10 @@ if IsWindows:
# stand-in for a systemd user service).
StartMenuDir = ConfigHome / "Microsoft" / "Windows" / "Start Menu" / "Programs"
StartupDir = StartMenuDir / "Startup"
elif IsMac:
ConfigHome = DataHome = Home / "Library" / "Application Support"
CacheHome = Home / "Library" / "Caches"
StartMenuDir = StartupDir = None
else:
ConfigHome = Path(os.environ.get("XDG_CONFIG_HOME") or Home / ".config")
DataHome = Path(os.environ.get("XDG_DATA_HOME") or Home / ".local" / "share")
@@ -71,8 +80,9 @@ ServicesDir = DataDir / "Services"
# Linux: whether systemd runs the system, and so --user services. Without it
# (runit on Void, OpenRC, s6, dinit, ...) services run the way they do on
# Windows (Services.py), started at login from AutostartDir.
HasSystemd = not IsWindows and Path("/run/systemd/system").is_dir() and shutil.which("systemctl") is not None
# Windows (Services.py), started at login from AutostartDir. macOS runs them
# that way too, started at login by a LaunchAgent (MacSupport.py).
HasSystemd = IsLinux and Path("/run/systemd/system").is_dir() and shutil.which("systemctl") is not None
AutostartDir = ConfigHome / "autostart"
# Bundled read-only files (program manifests, fonts). Inside a PyInstaller