macOS support

This commit is contained in:
sarah committed 2026-10-14 13:18:18 +02:00
1 parent 5613f4f8fe
commit 1bd37db1ba
8 files changed
+113 -29

No files matched your search

+14 -8
View File
@@ -21,21 +21,26 @@ BundledFontFamily = "Fixedsys Excelsior"
ActiveFontFamily = BundledFontFamily # set by ApplyAppearance, read by BuildTheme
IsWindows = sys.platform == "win32"
IsMac = sys.platform == "darwin"
IsLinux = not IsWindows and not IsMac
# Each system's own per-user folders, like SaraSuite's: ~/.config and
# ~/.local/share on Linux, %APPDATA% and %LOCALAPPDATA% on Windows.
# ~/.local/share on Linux, %APPDATA% and %LOCALAPPDATA% on Windows,
# ~/Library/Application Support (both) on macOS.
Home = Path.home()
if IsWindows:
ConfigHome = Path(os.environ.get("APPDATA") or Home / "AppData" / "Roaming")
DataHome = Path(os.environ.get("LOCALAPPDATA") or Home / "AppData" / "Local")
elif IsMac:
ConfigHome = DataHome = Home / "Library" / "Application Support"
else:
ConfigHome = Path(os.environ.get("XDG_CONFIG_HOME") or Home / ".config")
DataHome = Path(os.environ.get("XDG_DATA_HOME") or Home / ".local" / "share")
# Linux: whether systemd runs the system (and so SaraSortd's --user unit),
# the same check as SaraSuite's. Without it (runit on Void, OpenRC, ...),
# SaraSuite runs SaraSortd itself, the way it does on Windows (Service.py).
HasSystemd = not IsWindows and Path("/run/systemd/system").is_dir() and shutil.which("systemctl") is not None
# SaraSuite runs SaraSortd itself, the way it does on Windows and macOS (Service.py).
HasSystemd = IsLinux and Path("/run/systemd/system").is_dir() and shutil.which("systemctl") is not None
RunBySaraSuite = IsWindows or not HasSystemd
AutostartDir = ConfigHome / "autostart"
@@ -157,12 +162,13 @@ class AppConfig:
# Where SaraSuite installs SaraSortd: GlobalConf.toml and the two
# directory config templates live in SortdConfigDir, SaraSortd.py in
# SortdAppDir, and it runs as a systemd user unit (Linux) or a background
# service started from the Startup folder (Windows; see Service.py).
SortdConfigDir: str = (str(ConfigHome / "SaraSuite" / "SaraSortd") if IsWindows
# service started at login from the Startup folder (Windows) or a
# LaunchAgent (macOS; see Service.py).
SortdConfigDir: str = (str(ConfigHome / "SaraSuite" / "SaraSortd") if not IsLinux
else "~/.config/SaraSuite/SaraSortd")
SortdAppDir: str = (str(DataHome / "SaraSuite" / "Programs" / "SaraSortd" / "App") if IsWindows
SortdAppDir: str = (str(DataHome / "SaraSuite" / "Programs" / "SaraSortd" / "App") if not IsLinux
else "~/.local/share/SaraSuite/Programs/SaraSortd/App")
ServiceName: str = "SaraSortd" if IsWindows else "SaraSortd.service"
ServiceName: str = "SaraSortd.service" if IsLinux else "SaraSortd"
# SaraSortd only reads GlobalConf.toml when it starts.
AutoRestart: bool = True
RefreshSeconds: int = 5 # status and log refresh on the Service page
@@ -380,6 +386,6 @@ def Heading(Text: str) -> ft.Text:
def DisplayPath(PathText: str) -> str:
"""/home/sarah/Sorting -> ~/Sorting, for labels."""
HomeText = str(Home)
if PathText == HomeText or PathText.startswith(HomeText + "/"):
if PathText == HomeText or PathText.startswith((HomeText + "/", HomeText + os.sep)):
return "~" + PathText[len(HomeText):]
return PathText