summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxXJSONDeruloXx <danielhimebauch@gmail.com>2025-01-23 00:08:36 -0500
committerxXJSONDeruloXx <danielhimebauch@gmail.com>2025-01-23 00:08:36 -0500
commit23b4d45c34bdf2211cb74ac19b36d8086eccbb89 (patch)
tree610a33a1693048c828d1bcbe1bd9283c8d85e3a5
parent52cbb5022f0d6b8b27d7537316630c02982a6bf9 (diff)
downloadDecky-Framegen-23b4d45c34bdf2211cb74ac19b36d8086eccbb89.tar.gz
Decky-Framegen-23b4d45c34bdf2211cb74ac19b36d8086eccbb89.zip
add uninstaller button and script
-rw-r--r--assets/fgmod-remover.sh18
-rw-r--r--main.py48
-rwxr-xr-xsrc/index.tsx43
3 files changed, 72 insertions, 37 deletions
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<boolean | null>(null);
useEffect(() => {
@@ -46,6 +57,13 @@ function FGModInstallerSection() {
setInstallResult(result);
};
+ const handleUninstallClick = async () => {
+ setUninstalling(true);
+ const result = await runUninstallFGMod();
+ setUninstalling(false);
+ setUninstallResult(result);
+ };
+
return (
<PanelSection title="FG Mod Installer">
<PanelSectionRow>
@@ -53,6 +71,11 @@ function FGModInstallerSection() {
{installing ? "Installing..." : "Install FG Mod"}
</ButtonItem>
</PanelSectionRow>
+ <PanelSectionRow>
+ <ButtonItem layout="below" onClick={handleUninstallClick} disabled={uninstalling}>
+ {uninstalling ? "Uninstalling..." : "Uninstall FG Mod"}
+ </ButtonItem>
+ </PanelSectionRow>
{installResult && (
<PanelSectionRow>
<div>
@@ -73,6 +96,26 @@ function FGModInstallerSection() {
</div>
</PanelSectionRow>
)}
+ {uninstallResult && (
+ <PanelSectionRow>
+ <div>
+ <strong>Status:</strong>{" "}
+ {uninstallResult.status === "success" ? "Success" : "Error"}
+ <br />
+ {uninstallResult.output && (
+ <>
+ <strong>Output:</strong>
+ <pre style={{ whiteSpace: "pre-wrap" }}>{uninstallResult.output}</pre>
+ </>
+ )}
+ {uninstallResult.message && (
+ <>
+ <strong>Error:</strong> {uninstallResult.message}
+ </>
+ )}
+ </div>
+ </PanelSectionRow>
+ )}
{pathExists !== null && (
<PanelSectionRow>
<div style={{ color: pathExists ? "green" : "red" }}>