From 23b4d45c34bdf2211cb74ac19b36d8086eccbb89 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Thu, 23 Jan 2025 00:08:36 -0500 Subject: add uninstaller button and script --- assets/fgmod-remover.sh | 18 ++++++++++++++++++ main.py | 48 +++++++++++------------------------------------- src/index.tsx | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 37 deletions(-) create mode 100644 assets/fgmod-remover.sh diff --git a/assets/fgmod-remover.sh b/assets/fgmod-remover.sh new file mode 100644 index 0000000..32d4f71 --- /dev/null +++ b/assets/fgmod-remover.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Remove /home/deck/fgmod directory if it exists +if [[ -d "/home/deck/fgmod" ]]; then + rm -rf "/home/deck/fgmod" +fi + +# Remove specific files from ~/Downloads if they exist +downloads_dir="$HOME/Downloads" +files_to_remove=("prepare.sh" "fgmod.sh" "fgmod-uninstaller.sh") + +for file in "${files_to_remove[@]}"; do + if [[ -f "$downloads_dir/$file" ]]; then + rm "$downloads_dir/$file" + fi +done + +echo "FGmod removed" \ No newline at end of file diff --git a/main.py b/main.py index bfe1ca9..ab7e856 100644 --- a/main.py +++ b/main.py @@ -11,43 +11,17 @@ class Plugin: 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) + async def run_uninstall_fgmod(self) -> dict: + try: + result = subprocess.run( + ["/bin/bash", "/home/deck/homebrew/plugins/Decky-Framegen/assets/fgmod-remover.sh"], + capture_output=True, + text=True, + check=True + ) + return {"status": "success", "output": result.stdout} + except subprocess.CalledProcessError as e: + return {"status": "error", "message": str(e), "output": e.output} # Public method: front end can call this via callable("run_install_fgmod") async def run_install_fgmod(self) -> dict: diff --git a/src/index.tsx b/src/index.tsx index b5211ea..aa2c55e 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -12,6 +12,11 @@ const runInstallFGMod = callable< { status: string; message?: string; output?: string } >("run_install_fgmod"); +const runUninstallFGMod = callable< + [], + { status: string; message?: string; output?: string } +>("run_uninstall_fgmod"); + const checkFGModPath = callable< [], { exists: boolean } @@ -19,11 +24,17 @@ const checkFGModPath = callable< function FGModInstallerSection() { const [installing, setInstalling] = useState(false); + const [uninstalling, setUninstalling] = useState(false); const [installResult, setInstallResult] = useState<{ status: string; output?: string; message?: string; } | null>(null); + const [uninstallResult, setUninstallResult] = useState<{ + status: string; + output?: string; + message?: string; + } | null>(null); const [pathExists, setPathExists] = useState(null); useEffect(() => { @@ -46,6 +57,13 @@ function FGModInstallerSection() { setInstallResult(result); }; + const handleUninstallClick = async () => { + setUninstalling(true); + const result = await runUninstallFGMod(); + setUninstalling(false); + setUninstallResult(result); + }; + return ( @@ -53,6 +71,11 @@ function FGModInstallerSection() { {installing ? "Installing..." : "Install FG Mod"} + + + {uninstalling ? "Uninstalling..." : "Uninstall FG Mod"} + + {installResult && (
@@ -73,6 +96,26 @@ function FGModInstallerSection() {
)} + {uninstallResult && ( + +
+ Status:{" "} + {uninstallResult.status === "success" ? "Success" : "Error"} +
+ {uninstallResult.output && ( + <> + Output: +
{uninstallResult.output}
+ + )} + {uninstallResult.message && ( + <> + Error: {uninstallResult.message} + + )} +
+
+ )} {pathExists !== null && (
-- cgit v1.2.3