From cf2f9b9315a379fabbd6546c8818f771fc9bae1d Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Thu, 5 Sep 2024 22:47:06 -0400 Subject: [PATCH] Add wine launch script --- lib/sc-launch.sh | 38 ++++++++++++++++++++++++++++++++++++++ lug-helper.sh | 44 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 77 insertions(+), 5 deletions(-) create mode 100755 lib/sc-launch.sh diff --git a/lib/sc-launch.sh b/lib/sc-launch.sh new file mode 100755 index 0000000..9472175 --- /dev/null +++ b/lib/sc-launch.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# This script configures and launches Star Citizen +# It is installed by the LUG Helper when the game is installed with Wine (not Lutris) +# +# The following .desktop files are added by wine during installation and then modified by the LUG Helper to call this script +# They are automatically detected by most desktop environments for easy game launching +# +############################################################################################# +# $HOME/Desktop/RSI Launcher.desktop +# $HOME/.local/share/applications/wine/Programs/Roberts Space Industries/RSI Launcher.desktop +############################################################################################# +# +# IMPORTANT NOTE about using the above .desktop files: +# The RSI Launcher currently requires a terminal. Without this step, you will see a javascript error! +# To use the above .desktop files, modify the last line of this script as detailed in its comment +# +# If you do not wish to use the above .desktop files, then simply run this script from your terminal + +# Configure the environment +# Add additional environment variables here as needed +export WINEPREFIX="$HOME/Games/star-citizen" +export EOS_USE_ANTICHEATCLIENTNULL=1 +export DXVK_HUD=0 +export __GL_SHADER_DISK_CACHE=1 +export __GL_SHADER_DISK_CACHE_SIZE=1073741824 +export WINE_HIDE_NVIDIA_GPU=1 +export radv_zero_vram="true" +#export MANGOHUD=1 + +# Launch the game +# If you wish to launch the game from the .desktop files as mentioned above, +# modify this line to open your preferred terminal and then call wine. For example: +# +# gnome-terminal -- sh -c 'wine "C:\Program Files\Roberts Space Industries\RSI Launcher\RSI Launcher.exe"' +# +# If you do not wish to use the above .desktop files, then no modifications are required. +wine "C:\Program Files\Roberts Space Industries\RSI Launcher\RSI Launcher.exe" diff --git a/lug-helper.sh b/lug-helper.sh index 3680d17..0985e99 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -164,7 +164,7 @@ else lug_logo="info" fi -# Use Lutris install script installed by a packaged version of this script if available +# Use Lutris install json installed by a packaged version of this script if available # Otherwise, default to the json in the lib directory if [ -f "$(dirname "$helper_dir")/share/lug-helper/lutris-starcitizen.json" ]; then install_script="$(dirname "$helper_dir")/share/lug-helper/lutris-starcitizen.json" @@ -172,6 +172,14 @@ else install_script="$helper_dir/lib/lutris-starcitizen.json" fi +# Use game launch script installed by a packaged version of this script if available +# Otherwise, default to the launch script in the lib directory +if [ -f "$(dirname "$helper_dir")/share/lug-helper/sc-launch.sh" ]; then + launch_script="$(dirname "$helper_dir")/share/lug-helper/sc-launch.sh" +else + launch_script="$helper_dir/lib/sc-launch.sh" +fi + ######## Runners ########################################################### # Lutris native wine runners directory @@ -2453,11 +2461,37 @@ install_game_wine() { fi # Run the installer - WINEPREFIX="$install_dir" winecfg -v win10 && - WINEPREFIX="$install_dir" winetricks powershell - WINEPREFIX="$install_dir" wine "$tmp_dir/$rsi_installer" + debug_print continue "Preparing the wine prefix and launching the RSI Installer..." + WINEPREFIX="$install_dir" winecfg -v win10 2>/tmp/sc-install.log && + WINEPREFIX="$install_dir" winetricks powershell 2>>/tmp/sc-install.log + WINEPREFIX="$install_dir" wine "$tmp_dir/$rsi_installer" 2>>/tmp/sc-install.log - message info "Installation has finished.\n\nNote: Wine may have created the following launcher files on your system\nYou may remove or edit these if desired:\n\n$HOME/Desktop/RSI Launcher.destop\n$HOME/.local/share/applications/wine/Programs/Roberts Space Industries/RSI Launcher.desktop\n\nAfter making changes, update the database by running:\nupdate-desktop-database \$HOME/.local/share/applications" + # Copy game launch script to the wine prefix root directory + debug_print continue "Copying game launch script to ${install_dir}..." + cp "$launch_script" "$install_dir" + installed_launch_script="$install_dir/$(basename $launch_script)" + + # Update WINEPREFIX in game launch script + sed -i "s|^export WINEPREFIX.*|export WINEPREFIX=$install_dir|" "$install_dir/$(basename "$launch_script")" + + # Modify the .desktop files installed by wine to exec the game launch script + debug_print continue "Updating .desktop files..." + if [ -f "$HOME/Desktop/RSI Launcher.desktop" ]; then + sed -i "s|^Exec=env.*|Exec=$installed_launch_script|" "$HOME/Desktop/RSI Launcher.desktop" + debug_print continue "Updated $HOME/Desktop/RSI Launcher.desktop" + fi + if [ -f "$HOME/.local/share/applications/wine/Programs/Roberts Space Industries/RSI Launcher.desktop" ]; then + sed -i "s|^Exec=env.*|Exec=$installed_launch_script|" "$HOME/.local/share/applications/wine/Programs/Roberts Space Industries/RSI Launcher.desktop" + debug_print continue "Updated $HOME/.local/share/applications/wine/Programs/Roberts Space Industries/RSI Launcher.desktop" + fi + + # Update the .desktop file database if the command is available + if [ -x "$(command -v update-desktop-database)" ]; then + debug_print continue "Running update-desktop-database..." + update-desktop-database "$HOME/.local/share/applications" + fi + + message info "Installation has finished. The log can be found in /tmp/sc-install.log\n\nTo launch the game, run the following launch script in a terminal:\n$installed_launch_script\n\nWine may have installed the following .desktop files:\n$HOME/Desktop/RSI Launcher.desktop\n$HOME/.local/share/applications/wine/Programs/Roberts Space Industries/RSI Launcher.desktop\n\nTo use these .destop files, the above launch script must be modified to start the game in a terminal!\nYou'll find instructions in comments within the launch script" fi }