Add wine launch script

This commit is contained in:
the-sane 2024-09-05 22:47:06 -04:00
parent f10844face
commit cf2f9b9315
2 changed files with 77 additions and 5 deletions

38
lib/sc-launch.sh Executable file
View File

@ -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"

View File

@ -164,7 +164,7 @@ else
lug_logo="info" lug_logo="info"
fi 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 # Otherwise, default to the json in the lib directory
if [ -f "$(dirname "$helper_dir")/share/lug-helper/lutris-starcitizen.json" ]; then if [ -f "$(dirname "$helper_dir")/share/lug-helper/lutris-starcitizen.json" ]; then
install_script="$(dirname "$helper_dir")/share/lug-helper/lutris-starcitizen.json" install_script="$(dirname "$helper_dir")/share/lug-helper/lutris-starcitizen.json"
@ -172,6 +172,14 @@ else
install_script="$helper_dir/lib/lutris-starcitizen.json" install_script="$helper_dir/lib/lutris-starcitizen.json"
fi 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 ########################################################### ######## Runners ###########################################################
# Lutris native wine runners directory # Lutris native wine runners directory
@ -2453,11 +2461,37 @@ install_game_wine() {
fi fi
# Run the installer # Run the installer
WINEPREFIX="$install_dir" winecfg -v win10 && debug_print continue "Preparing the wine prefix and launching the RSI Installer..."
WINEPREFIX="$install_dir" winetricks powershell WINEPREFIX="$install_dir" winecfg -v win10 2>/tmp/sc-install.log &&
WINEPREFIX="$install_dir" wine "$tmp_dir/$rsi_installer" 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 fi
} }