mirror of
https://git.srhtnin.garden/sarah/SaraSuite.git
synced 2026-10-15 02:33:17 +02:00
Per-program Flet client app IDs so the dock shows the right icons
This commit is contained in:
1 parent
19bbad33a4
commit
56f10885de
12 files changed
+114
-18
No files matched your search
@@ -1,6 +1,7 @@
|
||||
"""SaraSuite entry point: installs, updates and removes Sara programs.
|
||||
With arguments it runs the command-line mode instead (see Cli.py)."""
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
@@ -11,7 +12,7 @@ import flet as ft
|
||||
|
||||
from Core import (
|
||||
AppName, ApplyAppearance, AssetsDir, BuildTheme, BundledFontFamily, ChipButtonStyle, DataDir,
|
||||
DataHome, EffectiveSettings, LoadConfig, Palette,
|
||||
DataHome, EffectiveSettings, LoadConfig, ManifestsDir, Palette,
|
||||
)
|
||||
from Dialogs import ShowInstallDialog, ShowOptionsDialog, ShowRemoveDialog, ShowUpdateDialog
|
||||
from Installer import Apply, Fetch, FetchCommit, GetStatus, PlanConfigs, PlanRemoval, Remove, SourceVersion
|
||||
@@ -27,6 +28,15 @@ _MenuEntry = DataHome / "applications" / "SaraSuite.desktop"
|
||||
_MenuIcon = DataDir / "SaraSuite.png"
|
||||
|
||||
|
||||
def _LoadFletIdentity():
|
||||
# Lives in Programs/ (bundled as data) because installed programs get a
|
||||
# copy of the same file next to them.
|
||||
Spec = importlib.util.spec_from_file_location("FletIdentity", ManifestsDir / "FletIdentity.py")
|
||||
Module = importlib.util.module_from_spec(Spec)
|
||||
Spec.loader.exec_module(Module)
|
||||
return Module
|
||||
|
||||
|
||||
def _SetMenuEntry(Enabled: bool) -> None:
|
||||
if not Enabled:
|
||||
_MenuEntry.unlink(missing_ok=True)
|
||||
@@ -39,7 +49,7 @@ def _SetMenuEntry(Enabled: bool) -> None:
|
||||
"[Desktop Entry]\nType=Application\nName=SaraSuite\n"
|
||||
"Comment=Install, update and remove Sara programs\n"
|
||||
f"Exec={_AppImage}\nIcon={_MenuIcon}\nTerminal=false\n"
|
||||
f"Categories=System;\nStartupNotify=true\nStartupWMClass={AppName}\n"
|
||||
f"Categories=System;\nStartupNotify=true\nStartupWMClass=srhtnin.{AppName}\n"
|
||||
)
|
||||
|
||||
|
||||
@@ -234,7 +244,8 @@ if __name__ == "__main__":
|
||||
from Cli import Run
|
||||
|
||||
sys.exit(Run(sys.argv[1:]))
|
||||
# The window's app ID, so the desktop matches it to SaraSuite.desktop
|
||||
# (icon, name) instead of showing it as Flet's generic "com.appveyor.flet".
|
||||
os.environ.setdefault("FLET_APP_ID", AppName)
|
||||
# A Flet client copy with the window app ID srhtnin.SaraSuite, so the
|
||||
# desktop matches the window to SaraSuite.desktop (StartupWMClass) instead
|
||||
# of showing it as "com.appveyor.flet". See Programs/FletIdentity.py.
|
||||
os.environ.setdefault("FLET_VIEW_PATH", _LoadFletIdentity().ClientFor(f"srhtnin.{AppName}"))
|
||||
ft.run(Main, assets_dir=str(AssetsDir))
|
||||
Reference in new issue
Block a user