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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
import decky # Old-style Decky import
import os
import subprocess
import json
from pathlib import Path
class Plugin:
async def _main(self):
decky.logger.info("Framegen plugin loaded")
async def _unload(self):
decky.logger.info("Framegen plugin unloaded.")
# # Public method: front end can call this via callable("get_installed_games")
# async def get_installed_games(self) -> str:
# library_file = "/home/deck/.steam/steam/steamapps/libraryfolders.vdf"
# libraries = []
# # Find library folders
# if os.path.exists(library_file):
# with open(library_file, "r") as f:
# lines = f.readlines()
# for line in lines:
# if '"path"' in line:
# folder_path = line.split('"')[3]
# libraries.append(os.path.join(folder_path, "steamapps"))
# # Gather installed games
# games = []
# for library in libraries:
# if os.path.exists(library):
# manifest_files = [
# f for f in os.listdir(library)
# if f.startswith("appmanifest_")
# ]
# for manifest in manifest_files:
# manifest_path = os.path.join(library, manifest)
# with open(manifest_path, "r") as mf:
# lines = mf.readlines()
# appid = ""
# name = ""
# for line in lines:
# if '"appid"' in line:
# appid = line.split('"')[3]
# elif '"name"' in line:
# name = line.split('"')[3]
# if appid and name:
# games.append({"appid": appid, "name": name})
# return json.dumps(games)
# Public method: front end can call this via callable("run_install_fgmod")
async def run_install_fgmod(self) -> dict:
try:
assets_dir = Path("/home/deck/homebrew/plugins/Decky-Framegen/assets")
downloads_dir = Path.home() / "Downloads"
if not assets_dir.exists():
decky.logger.error(f"Assets directory not found: {assets_dir}")
return {
"status": "error",
"message": f"Assets directory not found: {assets_dir}"
}
downloads_dir.mkdir(parents=True, exist_ok=True)
files_to_copy = ["prepare.sh", "fgmod.sh", "fgmod-uninstaller.sh"]
for file_name in files_to_copy:
src = assets_dir / file_name
if not src.exists():
decky.logger.error(f"Required file missing: {src}")
return {
"status": "error",
"message": f"Required file missing: {file_name}"
}
dest = downloads_dir / file_name
dest.write_bytes(src.read_bytes())
dest.chmod(0o755)
prepare_script = downloads_dir / "prepare.sh"
process = subprocess.run(
[str(prepare_script)],
capture_output=True,
text=True,
timeout=300
)
fgmod_path = Path("/home/deck/fgmod")
fgmod_path.mkdir(parents=True, exist_ok=True)
decky.logger.info(f"Script output:\n{process.stdout}")
decky.logger.error(f"Script errors:\n{process.stderr}")
if "All done!" not in process.stdout:
decky.logger.error("Installation did not complete successfully")
return {
"status": "error",
"message": process.stdout + process.stderr
}
return {
"status": "success",
"output": "in the games' launch options, add: /home/deck/fgmod/fgmod %COMMAND%"
}
except subprocess.TimeoutExpired:
decky.logger.error("Installation script timed out")
return {
"status": "error",
"message": "Installation timed out"
}
except subprocess.CalledProcessError as e:
decky.logger.error(f"Script error: {e.stderr}")
return {
"status": "error",
"message": e.stderr
}
except Exception as e:
decky.logger.error(f"Unexpected error: {str(e)}")
return {
"status": "error",
"message": str(e)
}
|