-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·72 lines (57 loc) · 2.12 KB
/
Copy pathrun
File metadata and controls
executable file
·72 lines (57 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
import os
import shutil
import sys
from pathlib import Path
ROOT_DIR = Path(__file__).resolve().parent
SRC_DIR = ROOT_DIR / "src"
DESKTOP_DIR = Path.home() / ".local/share/applications"
ICON_SIZES = (32, 64, 128, 256, 512, 1024)
APP_ID = "io.github.henriquejsza.farmmod-hub"
ICON_NAME = APP_ID
ICON_MASTER = ROOT_DIR / "data" / "logo" / f"{ICON_NAME}.png"
def _install_local_icon_theme_files():
icons_root = Path.home() / ".local/share/icons/hicolor"
if not ICON_MASTER.exists():
return
for size in ICON_SIZES:
target_dir = icons_root / f"{size}x{size}" / "apps"
target_dir.mkdir(parents=True, exist_ok=True)
target_icon = target_dir / f"{ICON_NAME}.png"
if not target_icon.exists() or target_icon.read_bytes() != ICON_MASTER.read_bytes():
shutil.copy2(ICON_MASTER, target_icon)
def _install_local_desktop_entry():
DESKTOP_DIR.mkdir(parents=True, exist_ok=True)
desktop_path = DESKTOP_DIR / f"{APP_ID}.desktop"
legacy_desktops = [
DESKTOP_DIR / "io.github.farmmodhub.desktop",
DESKTOP_DIR / "io.github.henriquejsza.FarmModHub.desktop",
]
for legacy_desktop in legacy_desktops:
if legacy_desktop.exists():
legacy_desktop.unlink()
desktop_text = "\n".join(
[
"[Desktop Entry]",
"Type=Application",
"Version=1.0",
"Name=FarmMod",
f"Exec={ROOT_DIR / 'run'}",
f"Icon={ICON_NAME}",
"Terminal=false",
"Categories=Game;Utility;",
"StartupNotify=true",
"X-KDE-StartupNotify=true",
f"StartupWMClass={APP_ID}",
]
)
if not desktop_path.exists() or desktop_path.read_text() != desktop_text:
desktop_path.write_text(desktop_text)
os.environ["GIO_LAUNCHED_DESKTOP_FILE"] = str(desktop_path)
os.environ["GIO_LAUNCHED_DESKTOP_FILE_PID"] = str(os.getpid())
if str(SRC_DIR) not in sys.path:
sys.path.insert(0, str(SRC_DIR))
_install_local_icon_theme_files()
_install_local_desktop_entry()
from farmmod_hub.presentation.gtk.app import main
sys.exit(main())