From 00d16976e6ff5257066c24fe819d479f324db215 Mon Sep 17 00:00:00 2001 From: Grimbakor Date: Thu, 30 Jan 2025 17:11:32 +0000 Subject: * Move assets/ to defaults/assets so .vscode/build.sh and decky-cli packages correctly (#28) * Changed all paths to use environment variables from decky as base paths * Remove alwaysRender from front-end so setInterval does not run in the background during a game session --- assets/fgmod-remover.sh | 18 ------ assets/fgmod-uninstaller.sh | 105 -------------------------------- assets/fgmod.sh | 113 ----------------------------------- assets/prepare.sh | 110 ---------------------------------- deck.json | 7 +++ defaults/assets/fgmod-remover.sh | 18 ++++++ defaults/assets/fgmod-uninstaller.sh | 105 ++++++++++++++++++++++++++++++++ defaults/assets/fgmod.sh | 113 +++++++++++++++++++++++++++++++++++ defaults/assets/prepare.sh | 110 ++++++++++++++++++++++++++++++++++ main.py | 18 +++--- src/index.tsx | 72 +--------------------- 11 files changed, 364 insertions(+), 425 deletions(-) delete mode 100644 assets/fgmod-remover.sh delete mode 100755 assets/fgmod-uninstaller.sh delete mode 100755 assets/fgmod.sh delete mode 100755 assets/prepare.sh create mode 100644 deck.json create mode 100644 defaults/assets/fgmod-remover.sh create mode 100755 defaults/assets/fgmod-uninstaller.sh create mode 100755 defaults/assets/fgmod.sh create mode 100755 defaults/assets/prepare.sh diff --git a/assets/fgmod-remover.sh b/assets/fgmod-remover.sh deleted file mode 100644 index 1d12a18..0000000 --- a/assets/fgmod-remover.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -# Remove ~/fgmod directory if it exists -if [[ -d "$HOME/fgmod" ]]; then - rm -rf "$HOME/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/assets/fgmod-uninstaller.sh b/assets/fgmod-uninstaller.sh deleted file mode 100755 index 7bff63a..0000000 --- a/assets/fgmod-uninstaller.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env bash - -set -x # Enable debugging -exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors - -error_exit() { - echo "$1" - if [[ -n $STEAM_ZENITY ]]; then - $STEAM_ZENITY --error --text "$1" - else - zenity --error --text "$1" - fi - exit 1 -} - -if [ "$#" -lt 1 ]; then - echo "Usage: $0 program [program_arguments...]" - exit 1 -fi - -game_path="" -mod_path="/usr/share/fgmod" - -# Locate the game folder based on the first argument -if [[ "$1" == *.exe ]]; then - exe_folder_path=$(dirname "$1") -else - for arg in "$@"; do - if [[ "$arg" == *.exe ]]; then - # Handle special cases for specific games - [[ "$arg" == *"Cyberpunk 2077"* ]] && arg=${arg//REDprelauncher.exe/bin/x64/Cyberpunk2077.exe} - [[ "$arg" == *"Witcher 3"* ]] && arg=${arg//REDprelauncher.exe/bin/x64_dx12/witcher3.exe} - [[ "$arg" == *"HITMAN 3"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe} - [[ "$arg" == *"HITMAN World of Assassination"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe} - [[ "$arg" == *"SYNCED"* ]] && arg=${arg//Launcher\/sop_launcher.exe/SYNCED.exe} - [[ "$arg" == *"2KLauncher"* ]] && arg=${arg//2KLauncher\/LauncherPatcher.exe/DoesntMatter.exe} - [[ "$arg" == *"Warhammer 40,000 DARKTIDE"* ]] && arg=${arg//launcher\/Launcher.exe/binaries/Darktide.exe} - [[ "$arg" == *"Warhammer Vermintide 2"* ]] && arg=${arg//launcher\/Launcher.exe/binaries_dx12/vermintide2_dx12.exe} - [[ "$arg" == *"Satisfactory"* ]] && arg=${arg//FactoryGameSteam.exe/Engine/Binaries/Win64/FactoryGameSteam-Win64-Shipping.exe} - exe_folder_path=$(dirname "$arg") - break - fi - done -fi - -# Fallback to STEAM_COMPAT_INSTALL_PATH when no path was found -if [[ ! -d $exe_folder_path ]] && [[ -n ${STEAM_COMPAT_INSTALL_PATH} ]]; then - exe_folder_path=${STEAM_COMPAT_INSTALL_PATH} -fi - -# Check for Unreal Engine game paths -if [[ -d "$exe_folder_path/Engine" ]]; then - ue_exe_path=$(find "$exe_folder_path" -maxdepth 4 -mindepth 4 -path "*Binaries/Win64/*.exe" -not -path "*/Engine/*" | head -1) - exe_folder_path=$(dirname "$ue_exe_path") -fi - -# Verify the game folder exists -if [[ ! -d $exe_folder_path ]]; then - error_exit "Unable to locate the game folder. Ensure the game is installed and the path is correct." -fi - -# Avoid operating on the uninstaller's own directory -script_dir=$(dirname "$(realpath "$0")") -if [[ "$(realpath "$exe_folder_path")" == "$script_dir" ]]; then - error_exit "The target directory matches the script's directory. Aborting to prevent accidental deletion." -fi - -# Change to the game directory -cd "$exe_folder_path" || error_exit "Failed to change directory to $exe_folder_path" - -# Verify current directory before proceeding -if [[ "$(pwd)" != "$exe_folder_path" ]]; then - error_exit "Unexpected working directory: $(pwd)" -fi - -# Log the resolved exe_folder_path for debugging -echo "Resolved exe_folder_path: $exe_folder_path" >> /tmp/fgmod-uninstaller.log - -# Perform uninstallation -rm -f "dlss-enabler.dll" "dxgi.dll" "nvngx-wrapper.dll" "_nvngx.dll" -rm -f "dlssg_to_fsr3_amd_is_better.dll" "dlssg_to_fsr3_amd_is_better-3.0.dll" -rm -f "dlss-enabler-upscaler.dll" "nvngx.ini" "libxess.dll" -rm -f "d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll" -rm -f "nvapi64.dll" "fakenvapi.ini" "OptiScaler.log" -rm -f "dlss-enabler.log" "dlssg_to_fsr3.log" "fakenvapi.log" - -# Restore original DLLs if they exist -mv -f "libxess.dll.b" "libxess.dll" 2>/dev/null -mv -f "d3dcompiler_47.dll.b" "d3dcompiler_47.dll" 2>/dev/null -mv -f "amd_fidelityfx_dx12.dll.b" "amd_fidelityfx_dx12.dll" 2>/dev/null -mv -f "amd_fidelityfx_vk.dll.b" "amd_fidelityfx_vk.dll" 2>/dev/null - -# Self-remove uninstaller (now optional for safety) -echo "Uninstaller self-removal skipped for safety. Remove manually if needed." - -echo "fgmod removed from this game." - -if [[ $# -gt 1 ]]; then - echo "Launching the game..." - export SteamDeck=0 - export WINEDLLOVERRIDES="${WINEDLLOVERRIDES},dxgi=n,b" - exec "$@" -else - echo "Uninstallation complete. No game specified to run." -fi \ No newline at end of file diff --git a/assets/fgmod.sh b/assets/fgmod.sh deleted file mode 100755 index dad2a41..0000000 --- a/assets/fgmod.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env bash - -error_exit() { - echo "$1" - if [[ -n $STEAM_ZENITY ]]; then - $STEAM_ZENITY --error --text "$1" - else - zenity --error --text "$1" - fi - exit 1 -} - -mod_path="/usr/share/fgmod" - -if [ "$#" -lt 1 ]; then - echo "Usage: $0 program [program_arguments...]" - exit 1 -fi - -# One arg means the command is ran standalone -if [[ $# -eq 1 ]]; then - if [[ "$1" == *.exe ]]; then - exe_folder_path=$(dirname "$1") - else - exe_folder_path=$1 - fi -else - for arg in "$@"; do - if [[ "$arg" == *.exe ]]; then - # Special cases, only FG-supported games - [[ "$arg" == *"Cyberpunk 2077"* ]] && arg=${arg//REDprelauncher.exe/bin/x64/Cyberpunk2077.exe} - [[ "$arg" == *"Witcher 3"* ]] && arg=${arg//REDprelauncher.exe/bin/x64_dx12/witcher3.exe} - [[ "$arg" == *"HITMAN 3"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe} - [[ "$arg" == *"HITMAN World of Assassination"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe} - [[ "$arg" == *"SYNCED"* ]] && arg=${arg//Launcher\/sop_launcher.exe/SYNCED.exe} # UE with a launcher - [[ "$arg" == *"2KLauncher"* ]] && arg=${arg//2KLauncher\/LauncherPatcher.exe/DoesntMatter.exe} # 2K launcher games - [[ "$arg" == *"Warhammer 40,000 DARKTIDE"* ]] && arg=${arg//launcher\/Launcher.exe/binaries/Darktide.exe} - [[ "$arg" == *"Warhammer Vermintide 2"* ]] && arg=${arg//launcher\/Launcher.exe/binaries_dx12/vermintide2_dx12.exe} - [[ "$arg" == *"Satisfactory"* ]] && arg=${arg//FactoryGameSteam.exe/Engine/Binaries/Win64/FactoryGameSteam-Win64-Shipping.exe} - exe_folder_path=$(dirname "$arg") - break - fi - done -fi - -# Fallback to STEAM_COMPAT_INSTALL_PATH when no path was found -if [[ ! -d $exe_folder_path ]] && [[ -n ${STEAM_COMPAT_INSTALL_PATH} ]]; then - echo "Trying the path from STEAM_COMPAT_INSTALL_PATH" - exe_folder_path=${STEAM_COMPAT_INSTALL_PATH} -fi - -# Check for UE games -if [[ -d "$exe_folder_path/Engine" ]]; then - ue_exe_path=$(find "$exe_folder_path" -maxdepth 4 -mindepth 4 -path "*Binaries/Win64/*.exe" -not -path "*/Engine/*" | head -1) - exe_folder_path=$(dirname "$ue_exe_path") -fi - -if [[ -d $exe_folder_path ]]; then - if [[ ! -w $exe_folder_path ]]; then - error_exit "No write permission to the game folder!" - fi - - original_dlls=("libxess.dll" "d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll") - - # Assume that the mod is not installed when dlss-enabler.dll is not present - if [[ ! -f "$exe_folder_path/dlss-enabler.dll" ]]; then - [[ -f "$exe_folder_path/dxgi.dll" ]] && error_exit 'dxgi.dll is already present in the game folder!\nThis script uses dxgi.dll to load required files.\nRemove the mod using dxgi.dll or install DLSS Enabler manually.' - for dll in "${original_dlls[@]}"; do - if [[ ! -f "$exe_folder_path/${dll}.b" ]]; then - mv -f "$exe_folder_path/$dll" "$exe_folder_path/${dll}.b" 2>/dev/null - fi - done - fi - - cp -f "$mod_path/fgmod-uninstaller.sh" "$exe_folder_path" || - error_exit "Couldn't copy the uninstaller!" - - cp -f "$mod_path/dlss-enabler.dll" "$exe_folder_path" && - cp -f "$mod_path/dxgi.dll" "$exe_folder_path" && - cp -f "$mod_path/nvngx-wrapper.dll" "$exe_folder_path" || - error_exit "Couldn't copy DLSS Enabler files!" - - # File is not preset on Nvidia installs so will fail on some setups on purpose - cp -f "$mod_path/nvapi64.dll" "$exe_folder_path" 2>/dev/null - - cp -f "$mod_path/_nvngx.dll" "$exe_folder_path" || - error_exit "Couldn't copy _nvngx.dll!" - - cp -f "$mod_path/dlssg_to_fsr3_amd_is_better.dll" "$exe_folder_path" && - cp -f "$mod_path/dlssg_to_fsr3_amd_is_better-3.0.dll" "$exe_folder_path" || - error_exit "Couldn't copy dlssg-to-fsr3!" - - cp -f "$mod_path/dlss-enabler-upscaler.dll" "$exe_folder_path" && - cp -f "$mod_path/amd_fidelityfx_dx12.dll" "$exe_folder_path" && - cp -f "$mod_path/amd_fidelityfx_vk.dll" "$exe_folder_path" && - cp -f "$mod_path/libxess.dll" "$exe_folder_path" && - cp -f "$mod_path/d3dcompiler_47.dll" "$exe_folder_path" || - error_exit "Couldn't copy Optiscaler files!" - - cp -n "$mod_path/nvngx.ini" "$exe_folder_path" - cp -n "$mod_path/fakenvapi.ini" "$exe_folder_path" -else - error_exit "Path doesn't exist!" -fi - -if [[ $# -gt 1 ]]; then - # Execute the original command - export SteamDeck=0 - export WINEDLLOVERRIDES="$WINEDLLOVERRIDES,dxgi=n,b" - "$@" -else - echo Done! -fi diff --git a/assets/prepare.sh b/assets/prepare.sh deleted file mode 100755 index a48ffcb..0000000 --- a/assets/prepare.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env bash - -set -x # Enable debugging -exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors - -# Function to test if curl works with a given LD_LIBRARY_PATH -test_curl() { - local lib_path=$1 - export LD_LIBRARY_PATH=$lib_path:$LD_LIBRARY_PATH - echo "Testing curl with LD_LIBRARY_PATH=$LD_LIBRARY_PATH" - curl --version >/dev/null 2>&1 - return $? -} - -# Try library paths and choose the one that works -if test_curl "/usr/lib"; then - echo "Using OpenSSL library path: /usr/lib" - export LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH" -elif test_curl "/usr/lib64"; then - echo "Using OpenSSL library path: /usr/lib64" - export LD_LIBRARY_PATH="/usr/lib64:$LD_LIBRARY_PATH" -elif test_curl "/lib"; then - echo "Using OpenSSL library path: /lib" - export LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH" -elif test_curl "/lib64"; then - echo "Using OpenSSL library path: /lib64" - export LD_LIBRARY_PATH="/usr/lib64:$LD_LIBRARY_PATH" -elif test_curl "/usr/local/lib"; then - echo "Using OpenSSL library path: /usr/local/lib" - export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" -elif test_curl "/usr/local/ssl/lib"; then - echo "Using OpenSSL library path: /usr/local/ssl/lib" - export LD_LIBRARY_PATH="/usr/local/ssl/lib:$LD_LIBRARY_PATH" -else - echo "Failed to configure OpenSSL for curl. Exiting." - exit 1 -fi - -mod_path="$HOME/fgmod" -nvidiaver=555.52.04 -enablerver=3.02.000.0 -fakenvapiver=v1.2.0 -standalone=1 - -if [[ -d "$mod_path" ]] && [[ ! $mod_path == . ]]; then - rm -r "$mod_path" -fi - -# In case script gets ran from a different directory -cd "$(dirname "$0")" - -mkdir -p "$mod_path" -if [[ ! $standalone -eq 0 ]]; then - [[ -f fgmod.sh ]] && cp fgmod.sh "$mod_path/fgmod" || exit 1 - [[ -f fgmod-uninstaller.sh ]] && cp fgmod-uninstaller.sh "$mod_path" || exit 1 -fi -cd "$mod_path" || exit 1 - -curl -OLf https://github.com/artur-graniszewski/DLSS-Enabler/releases/download/$enablerver/dlss-enabler-setup-$enablerver.exe || exit 1 -curl -OLf https://download.nvidia.com/XFree86/Linux-x86_64/$nvidiaver/NVIDIA-Linux-x86_64-$nvidiaver.run || exit 1 -curl -OLf https://raw.githubusercontent.com/mozilla/fxc2/master/dll/d3dcompiler_47.dll || exit 1 -curl -OLf https://github.com/FakeMichau/innoextract/releases/download/6.3.0/innoextract || exit 1 -curl -OLf https://github.com/FakeMichau/fakenvapi/releases/download/$fakenvapiver/fakenvapi.7z || exit 1 -[[ $standalone -eq 0 ]] && curl -o fgmod -Lf https://raw.githubusercontent.com/FakeMichau/fgmod/main/fgmod.sh -[[ $standalone -eq 0 ]] && curl -OL https://raw.githubusercontent.com/FakeMichau/fgmod/main/fgmod-uninstaller.sh - -[[ ! -f dlss-enabler-setup-$enablerver.exe ]] || -[[ ! -f NVIDIA-Linux-x86_64-$nvidiaver.run ]] || -[[ ! -f d3dcompiler_47.dll ]] || -[[ ! -f innoextract ]] || -[[ ! -f fakenvapi.7z ]] || -[[ ! -f fgmod ]] || -[[ ! -f fgmod-uninstaller.sh ]] && exit 1 - -# Extract files -chmod +x NVIDIA-Linux-x86_64-$nvidiaver.run -./NVIDIA-Linux-x86_64-$nvidiaver.run -x - -chmod +x innoextract -./innoextract dlss-enabler-setup-$enablerver.exe - -# Prepare mod files -mv app/* . -rm -r app -[[ -f "$(which 7z 2>/dev/null)" ]] && 7z -y x fakenvapi.7z -cp -f NVIDIA-Linux-x86_64-$nvidiaver/nvngx.dll _nvngx.dll -cp -f NVIDIA-Linux-x86_64-$nvidiaver/LICENSE "licenses/LICENSE (NVIDIA driver)" -chmod +r _nvngx.dll -rm -rf innoextract NVIDIA-Linux-x86_64-$nvidiaver dlss-enabler-setup-$enablerver.exe NVIDIA-Linux-x86_64-$nvidiaver.run fakenvapi.7z -rm -rf plugins nvapi64-proxy.dll dlss-enabler-fsr.dll dlss-enabler-xess.dll dbghelp.dll version.dll winmm.dll nvngx.dll dlss-finder.exe dlss-enabler.log dlssg_to_fsr3.log fakenvapi.log "LICENSE (DLSSG to FSR3 mod).txt" "Readme (DLSS enabler).txt" "READ ME (DLSSG to FSR3 mod).txt" "XESS LICENSE.pdf" -[[ -f "$(which nvidia-smi 2>/dev/null)" ]] && rm -rf nvapi64.dll fakenvapi.ini - -sed -i 's|mod_path="/usr/share/fgmod"|mod_path="'"$mod_path"'"|g' fgmod -chmod +x fgmod - -sed -i 's|mod_path="/usr/share/fgmod"|mod_path="'"$mod_path"'"|g' fgmod-uninstaller.sh -chmod +x fgmod-uninstaller.sh - -echo "" - -# Flatpak doesn't have access to home by default -if flatpak list | grep "com.valvesoftware.Steam" 1>/dev/null; then - echo Flatpak version of Steam detected, adding access to fgmod\'s folder - echo Please restart Steam! - flatpak override --user --filesystem="$mod_path" com.valvesoftware.Steam -fi - -echo For Steam, add this to the launch options: "$mod_path/fgmod" %COMMAND% -echo For Heroic, add this as a new wrapper: "$mod_path/fgmod" -echo All done! \ No newline at end of file diff --git a/deck.json b/deck.json new file mode 100644 index 0000000..2e2491e --- /dev/null +++ b/deck.json @@ -0,0 +1,7 @@ +{ + "deckip": "0.0.0.0", + "deckport": "22", + "deckpass": "ssap", + "deckkey": "-i $HOME/.ssh/id_rsa", + "deckdir": "/home/deck" +} \ No newline at end of file diff --git a/defaults/assets/fgmod-remover.sh b/defaults/assets/fgmod-remover.sh new file mode 100644 index 0000000..1d12a18 --- /dev/null +++ b/defaults/assets/fgmod-remover.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Remove ~/fgmod directory if it exists +if [[ -d "$HOME/fgmod" ]]; then + rm -rf "$HOME/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/defaults/assets/fgmod-uninstaller.sh b/defaults/assets/fgmod-uninstaller.sh new file mode 100755 index 0000000..7bff63a --- /dev/null +++ b/defaults/assets/fgmod-uninstaller.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +set -x # Enable debugging +exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors + +error_exit() { + echo "$1" + if [[ -n $STEAM_ZENITY ]]; then + $STEAM_ZENITY --error --text "$1" + else + zenity --error --text "$1" + fi + exit 1 +} + +if [ "$#" -lt 1 ]; then + echo "Usage: $0 program [program_arguments...]" + exit 1 +fi + +game_path="" +mod_path="/usr/share/fgmod" + +# Locate the game folder based on the first argument +if [[ "$1" == *.exe ]]; then + exe_folder_path=$(dirname "$1") +else + for arg in "$@"; do + if [[ "$arg" == *.exe ]]; then + # Handle special cases for specific games + [[ "$arg" == *"Cyberpunk 2077"* ]] && arg=${arg//REDprelauncher.exe/bin/x64/Cyberpunk2077.exe} + [[ "$arg" == *"Witcher 3"* ]] && arg=${arg//REDprelauncher.exe/bin/x64_dx12/witcher3.exe} + [[ "$arg" == *"HITMAN 3"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe} + [[ "$arg" == *"HITMAN World of Assassination"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe} + [[ "$arg" == *"SYNCED"* ]] && arg=${arg//Launcher\/sop_launcher.exe/SYNCED.exe} + [[ "$arg" == *"2KLauncher"* ]] && arg=${arg//2KLauncher\/LauncherPatcher.exe/DoesntMatter.exe} + [[ "$arg" == *"Warhammer 40,000 DARKTIDE"* ]] && arg=${arg//launcher\/Launcher.exe/binaries/Darktide.exe} + [[ "$arg" == *"Warhammer Vermintide 2"* ]] && arg=${arg//launcher\/Launcher.exe/binaries_dx12/vermintide2_dx12.exe} + [[ "$arg" == *"Satisfactory"* ]] && arg=${arg//FactoryGameSteam.exe/Engine/Binaries/Win64/FactoryGameSteam-Win64-Shipping.exe} + exe_folder_path=$(dirname "$arg") + break + fi + done +fi + +# Fallback to STEAM_COMPAT_INSTALL_PATH when no path was found +if [[ ! -d $exe_folder_path ]] && [[ -n ${STEAM_COMPAT_INSTALL_PATH} ]]; then + exe_folder_path=${STEAM_COMPAT_INSTALL_PATH} +fi + +# Check for Unreal Engine game paths +if [[ -d "$exe_folder_path/Engine" ]]; then + ue_exe_path=$(find "$exe_folder_path" -maxdepth 4 -mindepth 4 -path "*Binaries/Win64/*.exe" -not -path "*/Engine/*" | head -1) + exe_folder_path=$(dirname "$ue_exe_path") +fi + +# Verify the game folder exists +if [[ ! -d $exe_folder_path ]]; then + error_exit "Unable to locate the game folder. Ensure the game is installed and the path is correct." +fi + +# Avoid operating on the uninstaller's own directory +script_dir=$(dirname "$(realpath "$0")") +if [[ "$(realpath "$exe_folder_path")" == "$script_dir" ]]; then + error_exit "The target directory matches the script's directory. Aborting to prevent accidental deletion." +fi + +# Change to the game directory +cd "$exe_folder_path" || error_exit "Failed to change directory to $exe_folder_path" + +# Verify current directory before proceeding +if [[ "$(pwd)" != "$exe_folder_path" ]]; then + error_exit "Unexpected working directory: $(pwd)" +fi + +# Log the resolved exe_folder_path for debugging +echo "Resolved exe_folder_path: $exe_folder_path" >> /tmp/fgmod-uninstaller.log + +# Perform uninstallation +rm -f "dlss-enabler.dll" "dxgi.dll" "nvngx-wrapper.dll" "_nvngx.dll" +rm -f "dlssg_to_fsr3_amd_is_better.dll" "dlssg_to_fsr3_amd_is_better-3.0.dll" +rm -f "dlss-enabler-upscaler.dll" "nvngx.ini" "libxess.dll" +rm -f "d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll" +rm -f "nvapi64.dll" "fakenvapi.ini" "OptiScaler.log" +rm -f "dlss-enabler.log" "dlssg_to_fsr3.log" "fakenvapi.log" + +# Restore original DLLs if they exist +mv -f "libxess.dll.b" "libxess.dll" 2>/dev/null +mv -f "d3dcompiler_47.dll.b" "d3dcompiler_47.dll" 2>/dev/null +mv -f "amd_fidelityfx_dx12.dll.b" "amd_fidelityfx_dx12.dll" 2>/dev/null +mv -f "amd_fidelityfx_vk.dll.b" "amd_fidelityfx_vk.dll" 2>/dev/null + +# Self-remove uninstaller (now optional for safety) +echo "Uninstaller self-removal skipped for safety. Remove manually if needed." + +echo "fgmod removed from this game." + +if [[ $# -gt 1 ]]; then + echo "Launching the game..." + export SteamDeck=0 + export WINEDLLOVERRIDES="${WINEDLLOVERRIDES},dxgi=n,b" + exec "$@" +else + echo "Uninstallation complete. No game specified to run." +fi \ No newline at end of file diff --git a/defaults/assets/fgmod.sh b/defaults/assets/fgmod.sh new file mode 100755 index 0000000..dad2a41 --- /dev/null +++ b/defaults/assets/fgmod.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash + +error_exit() { + echo "$1" + if [[ -n $STEAM_ZENITY ]]; then + $STEAM_ZENITY --error --text "$1" + else + zenity --error --text "$1" + fi + exit 1 +} + +mod_path="/usr/share/fgmod" + +if [ "$#" -lt 1 ]; then + echo "Usage: $0 program [program_arguments...]" + exit 1 +fi + +# One arg means the command is ran standalone +if [[ $# -eq 1 ]]; then + if [[ "$1" == *.exe ]]; then + exe_folder_path=$(dirname "$1") + else + exe_folder_path=$1 + fi +else + for arg in "$@"; do + if [[ "$arg" == *.exe ]]; then + # Special cases, only FG-supported games + [[ "$arg" == *"Cyberpunk 2077"* ]] && arg=${arg//REDprelauncher.exe/bin/x64/Cyberpunk2077.exe} + [[ "$arg" == *"Witcher 3"* ]] && arg=${arg//REDprelauncher.exe/bin/x64_dx12/witcher3.exe} + [[ "$arg" == *"HITMAN 3"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe} + [[ "$arg" == *"HITMAN World of Assassination"* ]] && arg=${arg//Launcher.exe/Retail/HITMAN3.exe} + [[ "$arg" == *"SYNCED"* ]] && arg=${arg//Launcher\/sop_launcher.exe/SYNCED.exe} # UE with a launcher + [[ "$arg" == *"2KLauncher"* ]] && arg=${arg//2KLauncher\/LauncherPatcher.exe/DoesntMatter.exe} # 2K launcher games + [[ "$arg" == *"Warhammer 40,000 DARKTIDE"* ]] && arg=${arg//launcher\/Launcher.exe/binaries/Darktide.exe} + [[ "$arg" == *"Warhammer Vermintide 2"* ]] && arg=${arg//launcher\/Launcher.exe/binaries_dx12/vermintide2_dx12.exe} + [[ "$arg" == *"Satisfactory"* ]] && arg=${arg//FactoryGameSteam.exe/Engine/Binaries/Win64/FactoryGameSteam-Win64-Shipping.exe} + exe_folder_path=$(dirname "$arg") + break + fi + done +fi + +# Fallback to STEAM_COMPAT_INSTALL_PATH when no path was found +if [[ ! -d $exe_folder_path ]] && [[ -n ${STEAM_COMPAT_INSTALL_PATH} ]]; then + echo "Trying the path from STEAM_COMPAT_INSTALL_PATH" + exe_folder_path=${STEAM_COMPAT_INSTALL_PATH} +fi + +# Check for UE games +if [[ -d "$exe_folder_path/Engine" ]]; then + ue_exe_path=$(find "$exe_folder_path" -maxdepth 4 -mindepth 4 -path "*Binaries/Win64/*.exe" -not -path "*/Engine/*" | head -1) + exe_folder_path=$(dirname "$ue_exe_path") +fi + +if [[ -d $exe_folder_path ]]; then + if [[ ! -w $exe_folder_path ]]; then + error_exit "No write permission to the game folder!" + fi + + original_dlls=("libxess.dll" "d3dcompiler_47.dll" "amd_fidelityfx_dx12.dll" "amd_fidelityfx_vk.dll") + + # Assume that the mod is not installed when dlss-enabler.dll is not present + if [[ ! -f "$exe_folder_path/dlss-enabler.dll" ]]; then + [[ -f "$exe_folder_path/dxgi.dll" ]] && error_exit 'dxgi.dll is already present in the game folder!\nThis script uses dxgi.dll to load required files.\nRemove the mod using dxgi.dll or install DLSS Enabler manually.' + for dll in "${original_dlls[@]}"; do + if [[ ! -f "$exe_folder_path/${dll}.b" ]]; then + mv -f "$exe_folder_path/$dll" "$exe_folder_path/${dll}.b" 2>/dev/null + fi + done + fi + + cp -f "$mod_path/fgmod-uninstaller.sh" "$exe_folder_path" || + error_exit "Couldn't copy the uninstaller!" + + cp -f "$mod_path/dlss-enabler.dll" "$exe_folder_path" && + cp -f "$mod_path/dxgi.dll" "$exe_folder_path" && + cp -f "$mod_path/nvngx-wrapper.dll" "$exe_folder_path" || + error_exit "Couldn't copy DLSS Enabler files!" + + # File is not preset on Nvidia installs so will fail on some setups on purpose + cp -f "$mod_path/nvapi64.dll" "$exe_folder_path" 2>/dev/null + + cp -f "$mod_path/_nvngx.dll" "$exe_folder_path" || + error_exit "Couldn't copy _nvngx.dll!" + + cp -f "$mod_path/dlssg_to_fsr3_amd_is_better.dll" "$exe_folder_path" && + cp -f "$mod_path/dlssg_to_fsr3_amd_is_better-3.0.dll" "$exe_folder_path" || + error_exit "Couldn't copy dlssg-to-fsr3!" + + cp -f "$mod_path/dlss-enabler-upscaler.dll" "$exe_folder_path" && + cp -f "$mod_path/amd_fidelityfx_dx12.dll" "$exe_folder_path" && + cp -f "$mod_path/amd_fidelityfx_vk.dll" "$exe_folder_path" && + cp -f "$mod_path/libxess.dll" "$exe_folder_path" && + cp -f "$mod_path/d3dcompiler_47.dll" "$exe_folder_path" || + error_exit "Couldn't copy Optiscaler files!" + + cp -n "$mod_path/nvngx.ini" "$exe_folder_path" + cp -n "$mod_path/fakenvapi.ini" "$exe_folder_path" +else + error_exit "Path doesn't exist!" +fi + +if [[ $# -gt 1 ]]; then + # Execute the original command + export SteamDeck=0 + export WINEDLLOVERRIDES="$WINEDLLOVERRIDES,dxgi=n,b" + "$@" +else + echo Done! +fi diff --git a/defaults/assets/prepare.sh b/defaults/assets/prepare.sh new file mode 100755 index 0000000..a48ffcb --- /dev/null +++ b/defaults/assets/prepare.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +set -x # Enable debugging +exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors + +# Function to test if curl works with a given LD_LIBRARY_PATH +test_curl() { + local lib_path=$1 + export LD_LIBRARY_PATH=$lib_path:$LD_LIBRARY_PATH + echo "Testing curl with LD_LIBRARY_PATH=$LD_LIBRARY_PATH" + curl --version >/dev/null 2>&1 + return $? +} + +# Try library paths and choose the one that works +if test_curl "/usr/lib"; then + echo "Using OpenSSL library path: /usr/lib" + export LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH" +elif test_curl "/usr/lib64"; then + echo "Using OpenSSL library path: /usr/lib64" + export LD_LIBRARY_PATH="/usr/lib64:$LD_LIBRARY_PATH" +elif test_curl "/lib"; then + echo "Using OpenSSL library path: /lib" + export LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH" +elif test_curl "/lib64"; then + echo "Using OpenSSL library path: /lib64" + export LD_LIBRARY_PATH="/usr/lib64:$LD_LIBRARY_PATH" +elif test_curl "/usr/local/lib"; then + echo "Using OpenSSL library path: /usr/local/lib" + export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" +elif test_curl "/usr/local/ssl/lib"; then + echo "Using OpenSSL library path: /usr/local/ssl/lib" + export LD_LIBRARY_PATH="/usr/local/ssl/lib:$LD_LIBRARY_PATH" +else + echo "Failed to configure OpenSSL for curl. Exiting." + exit 1 +fi + +mod_path="$HOME/fgmod" +nvidiaver=555.52.04 +enablerver=3.02.000.0 +fakenvapiver=v1.2.0 +standalone=1 + +if [[ -d "$mod_path" ]] && [[ ! $mod_path == . ]]; then + rm -r "$mod_path" +fi + +# In case script gets ran from a different directory +cd "$(dirname "$0")" + +mkdir -p "$mod_path" +if [[ ! $standalone -eq 0 ]]; then + [[ -f fgmod.sh ]] && cp fgmod.sh "$mod_path/fgmod" || exit 1 + [[ -f fgmod-uninstaller.sh ]] && cp fgmod-uninstaller.sh "$mod_path" || exit 1 +fi +cd "$mod_path" || exit 1 + +curl -OLf https://github.com/artur-graniszewski/DLSS-Enabler/releases/download/$enablerver/dlss-enabler-setup-$enablerver.exe || exit 1 +curl -OLf https://download.nvidia.com/XFree86/Linux-x86_64/$nvidiaver/NVIDIA-Linux-x86_64-$nvidiaver.run || exit 1 +curl -OLf https://raw.githubusercontent.com/mozilla/fxc2/master/dll/d3dcompiler_47.dll || exit 1 +curl -OLf https://github.com/FakeMichau/innoextract/releases/download/6.3.0/innoextract || exit 1 +curl -OLf https://github.com/FakeMichau/fakenvapi/releases/download/$fakenvapiver/fakenvapi.7z || exit 1 +[[ $standalone -eq 0 ]] && curl -o fgmod -Lf https://raw.githubusercontent.com/FakeMichau/fgmod/main/fgmod.sh +[[ $standalone -eq 0 ]] && curl -OL https://raw.githubusercontent.com/FakeMichau/fgmod/main/fgmod-uninstaller.sh + +[[ ! -f dlss-enabler-setup-$enablerver.exe ]] || +[[ ! -f NVIDIA-Linux-x86_64-$nvidiaver.run ]] || +[[ ! -f d3dcompiler_47.dll ]] || +[[ ! -f innoextract ]] || +[[ ! -f fakenvapi.7z ]] || +[[ ! -f fgmod ]] || +[[ ! -f fgmod-uninstaller.sh ]] && exit 1 + +# Extract files +chmod +x NVIDIA-Linux-x86_64-$nvidiaver.run +./NVIDIA-Linux-x86_64-$nvidiaver.run -x + +chmod +x innoextract +./innoextract dlss-enabler-setup-$enablerver.exe + +# Prepare mod files +mv app/* . +rm -r app +[[ -f "$(which 7z 2>/dev/null)" ]] && 7z -y x fakenvapi.7z +cp -f NVIDIA-Linux-x86_64-$nvidiaver/nvngx.dll _nvngx.dll +cp -f NVIDIA-Linux-x86_64-$nvidiaver/LICENSE "licenses/LICENSE (NVIDIA driver)" +chmod +r _nvngx.dll +rm -rf innoextract NVIDIA-Linux-x86_64-$nvidiaver dlss-enabler-setup-$enablerver.exe NVIDIA-Linux-x86_64-$nvidiaver.run fakenvapi.7z +rm -rf plugins nvapi64-proxy.dll dlss-enabler-fsr.dll dlss-enabler-xess.dll dbghelp.dll version.dll winmm.dll nvngx.dll dlss-finder.exe dlss-enabler.log dlssg_to_fsr3.log fakenvapi.log "LICENSE (DLSSG to FSR3 mod).txt" "Readme (DLSS enabler).txt" "READ ME (DLSSG to FSR3 mod).txt" "XESS LICENSE.pdf" +[[ -f "$(which nvidia-smi 2>/dev/null)" ]] && rm -rf nvapi64.dll fakenvapi.ini + +sed -i 's|mod_path="/usr/share/fgmod"|mod_path="'"$mod_path"'"|g' fgmod +chmod +x fgmod + +sed -i 's|mod_path="/usr/share/fgmod"|mod_path="'"$mod_path"'"|g' fgmod-uninstaller.sh +chmod +x fgmod-uninstaller.sh + +echo "" + +# Flatpak doesn't have access to home by default +if flatpak list | grep "com.valvesoftware.Steam" 1>/dev/null; then + echo Flatpak version of Steam detected, adding access to fgmod\'s folder + echo Please restart Steam! + flatpak override --user --filesystem="$mod_path" com.valvesoftware.Steam +fi + +echo For Steam, add this to the launch options: "$mod_path/fgmod" %COMMAND% +echo For Heroic, add this as a new wrapper: "$mod_path/fgmod" +echo All done! \ No newline at end of file diff --git a/main.py b/main.py index 3b05808..6f15132 100644 --- a/main.py +++ b/main.py @@ -14,7 +14,7 @@ class Plugin: async def run_uninstall_fgmod(self) -> dict: try: result = subprocess.run( - ["/bin/bash", Path.home() / "homebrew" / "plugins" / "Decky-Framegen" / "assets" / "fgmod-remover.sh"], + ["/bin/bash", Path(decky.DECKY_PLUGIN_DIR) / "assets" / "fgmod-remover.sh"], capture_output=True, text=True, check=True @@ -25,8 +25,8 @@ class Plugin: async def run_install_fgmod(self) -> dict: try: - assets_dir = Path.home() / "homebrew" / "plugins" / "Decky-Framegen" / "assets" - downloads_dir = Path.home() / "Downloads" + assets_dir = Path(decky.DECKY_PLUGIN_DIR) / "assets" + downloads_dir = Path(decky.HOME) / "Downloads" if not assets_dir.exists(): decky.logger.error(f"Assets directory not found: {assets_dir}") @@ -59,7 +59,7 @@ class Plugin: timeout=300 ) - fgmod_path = Path.home() / "fgmod" + fgmod_path = Path(decky.HOME) / "fgmod" fgmod_path.mkdir(parents=True, exist_ok=True) decky.logger.info(f"Script output:\n{process.stdout}") @@ -97,7 +97,7 @@ class Plugin: } async def check_fgmod_path(self) -> dict: - path = Path.home() / "fgmod" + path = Path(decky.HOME) / "fgmod" required_files = [ "amd_fidelityfx_dx12.dll", "dlssg_to_fsr3_amd_is_better.dll", "libxess.dll", "amd_fidelityfx_vk.dll", "dlssg_to_fsr3.ini", "licenses", @@ -108,9 +108,9 @@ class Plugin: "dlssg_to_fsr3_amd_is_better-3.0.dll", "fgmod-uninstaller.sh", "RestoreNvidiaSignatureChecks.reg" ] - if os.path.exists(path): + if path.exists(): for file_name in required_files: - if not os.path.exists(os.path.join(path, file_name)): + if not path.joinpath(file_name).exists(): return {"exists": False} return {"exists": True} else: @@ -119,7 +119,7 @@ class Plugin: # New method to list installed Steam games async def list_installed_games(self) -> dict: try: - steam_root = Path.home() / ".steam" / "steam" + steam_root = Path(decky.HOME) / ".steam" / "steam" library_file = Path(steam_root) / "steamapps" / "libraryfolders.vdf" if not library_file.exists(): @@ -156,4 +156,4 @@ class Plugin: return {"status": "success", "games": filtered_games} except Exception as e: - return {"status": "error", "message": str(e)} \ No newline at end of file + return {"status": "error", "message": str(e)} diff --git a/src/index.tsx b/src/index.tsx index 7152951..851e003 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -162,74 +162,6 @@ function FGModInstallerSection() { ); } -// function MainRunningApp() { -// const mainRunningApp = Router.MainRunningApp; -// const [result, setResult] = useState(null); -// const [isPatched, setIsPatched] = useState(false); - -// const checkLaunchOptions = async () => { -// if (mainRunningApp) { -// try { -// const currentOptions = await SteamClient.Apps.GetLaunchOptionsForApp(mainRunningApp.appid); -// setIsPatched(currentOptions.includes('~/fgmod/fgmod %COMMAND%')); -// } catch (error) { -// console.error('Error checking launch options:', error); -// } -// } -// }; - -// useEffect(() => { -// if (mainRunningApp) { -// checkLaunchOptions(); -// } -// }, [mainRunningApp]); - -// const handleSetLaunchOptions = async () => { -// if (mainRunningApp) { -// try { -// if (isPatched) { -// await SteamClient.Apps.SetAppLaunchOptions(mainRunningApp.appid, ''); -// setResult(`Launch options cleared successfully. Restart the game to restore DLSS default files`); -// } else { -// await SteamClient.Apps.SetAppLaunchOptions(mainRunningApp.appid, '~/fgmod/fgmod %COMMAND%'); -// setResult(`Launch options set successfully, restart the game to use FSR upscaling and frame gen via DLSS options.`); -// } -// setIsPatched(!isPatched); -// } catch (error) { -// if (error instanceof Error) { -// setResult(`Error setting launch options: ${error.message}`); -// } else { -// setResult('Error setting launch options'); -// } -// } -// } -// }; - -// return ( -// -// -//
-// {mainRunningApp ? ( -// <> -// {isPatched ? `UnPatch: ${mainRunningApp.display_name}` : `Patch: ${mainRunningApp.display_name}`} -// -// {isPatched ? `UnPatch: ${mainRunningApp.display_name}` : `Patch: ${mainRunningApp.display_name}`} -// -// -// ) : ( -// No game is currently open. -// )} -//
-//
-// {result && ( -// -//
{result}
-//
-// )} -//
-// ); -// } - function InstalledGamesSection() { const [games, setGames] = useState<{ appid: number; name: string }[]>([]); const [clickedGame, setClickedGame] = useState<{ appid: number; name: string } | null>(null); @@ -319,7 +251,7 @@ function InstalledGamesSection() { export default definePlugin(() => ({ name: "Framegen Plugin", titleView:
Decky Framegen
, - alwaysRender: true, + alwaysRender: false, content: ( <> @@ -339,4 +271,4 @@ function MainContent() { {} ); -} \ No newline at end of file +} -- cgit v1.2.3