Compare commits

..

No commits in common. "56f61bcb35f8d95887a8b6f0c9afa7198bdc4d52" and "d034b9bb155b4c3023672a587bd066b38a9f5950" have entirely different histories.

View File

@ -90,15 +90,6 @@ data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"
# .config subdirectory # .config subdirectory
conf_subdir="starcitizen-lug" conf_subdir="starcitizen-lug"
# Flatpak lutris directory
lutris_flatpak_dir="$HOME/.var/app/net.lutris.Lutris"
# Lutris native game configs directory
lutris_native_conf_dir="$conf_dir/lutris/games"
# Lutris flatpak game configs directory
lutris_flatpak_conf_dir="$lutris_flatpak_dir/config/lutris/games"
# Helper directory # Helper directory
helper_dir="$(realpath "$0" | xargs -0 dirname)" helper_dir="$(realpath "$0" | xargs -0 dirname)"
@ -143,7 +134,7 @@ shaders_subdir="shaders"
# Lutris native wine runners directory # Lutris native wine runners directory
runners_dir_native="$data_dir/lutris/runners/wine" runners_dir_native="$data_dir/lutris/runners/wine"
# Lutris flatpak wine runners directory # Lutris flatpak wine runners directory
runners_dir_flatpak="$lutris_flatpak_dir/data/lutris/runners/wine" runners_dir_flatpak="$HOME/.var/app/net.lutris.Lutris/data/lutris/runners/wine"
# URLs for downloading Lutris runners # URLs for downloading Lutris runners
# Elements in this array must be added in quoted pairs of: "description" "url" # Elements in this array must be added in quoted pairs of: "description" "url"
@ -161,7 +152,7 @@ runner_sources=(
# Lutris native dxvk directory # Lutris native dxvk directory
dxvk_dir_native="$data_dir/lutris/runtime/dxvk" dxvk_dir_native="$data_dir/lutris/runtime/dxvk"
# Lutris flatpak dxvk directory # Lutris flatpak dxvk directory
dxvk_dir_flatpak="$lutris_flatpak_dir/data/lutris/runtime/dxvk" dxvk_dir_flatpak="$HOME/.var/app/net.lutris.Lutris/data/lutris/runtime/dxvk"
# URLs for downloading dxvk versions # URLs for downloading dxvk versions
# Elements in this array must be added in quoted pairs of: "description" "url" # Elements in this array must be added in quoted pairs of: "description" "url"
@ -1022,20 +1013,25 @@ preflight_check() {
######## begin download functions ########################################## ######## begin download functions ##########################################
############################################################################ ############################################################################
# Detect which version of Lutris is running and restart it # Restart lutris if necessary
lutris_restart() { lutris_restart() {
# Detect the installed versions of Lutris
lutris_detect lutris_detect
if [ "$lutris_native" = "true" ] && pgrep -f lutris | xargs ps -fp | grep -Eq "[/]usr/bin/lutris|[/]usr/games/lutris"; then if [ "$lutris_needs_restart" = "true" ] && [ "$(pgrep -f lutris)" ]; then
# Native Lutris is running if message question "Lutris must be restarted to detect the changes.\nWould you like this Helper to restart it for you?"; then
debug_print continue "Restarting native Lutris..." # Detect which version of Lutris is running and restart it
pkill -f -SIGTERM lutris && nohup lutris </dev/null &>/dev/null & if [ "$lutris_native" = "true" ] && pgrep -f lutris | xargs ps -fp | grep -q "[/]usr/bin/lutris"; then
fi # Native Lutris is running
if [ "$lutris_flatpak" = "true" ] && pgrep -f lutris | xargs ps -fp | grep -q "[/]app/bin/lutris"; then debug_print continue "Restarting native Lutris..."
# Flatpak Lutris is running pkill -f -SIGTERM lutris && nohup lutris </dev/null &>/dev/null &
debug_print continue "Restarting flatpak Lutris..." fi
pkill -f -SIGTERM lutris && nohup flatpak run net.lutris.Lutris </dev/null &>/dev/null & if [ "$lutris_flatpak" = "true" ] && pgrep -f lutris | xargs ps -fp | grep -q "[/]app/bin/lutris"; then
# Flatpak Lutris is running
debug_print continue "Restarting flatpak Lutris..."
pkill -f -SIGTERM lutris && nohup flatpak run net.lutris.Lutris </dev/null &>/dev/null &
fi
fi
fi fi
lutris_needs_restart="false"
} }
# Get an array of directories used by Lutris # Get an array of directories used by Lutris
@ -1082,88 +1078,46 @@ get_lutris_dirs() {
esac esac
} }
# Perform post-download actions or display a message/instructions # Perform post-download actions, display messages or instructions
# # Expects the variables message_heading, post_download_msg_text,
# Expects the following variables to be set: # post_download_msg_italics, and downloaded_item_name
# post_download_type ("info", or "configure-lutris") # Optional: post_download_msg_more_info and post_download_msg_link
# post_download_msg_heading
# post_download_msg
# post_download_sed_string (for type question only)
# downloaded_item_name (set in download_install function)
# deleted_item_names (set in download_delete function)
#
# Details for post_download_sed_string:
# This is the string sed will match against when editing Lutris yml configs
# It will be used to detect the appropriate yml key and replace its value
# with the name of the downloaded item. Example: "dxvk_version: "
#
# Message display format:
# A header is automatically displayed that reads: Download Complete
# post_download_msg is displayed below the header
post_download() { post_download() {
# Configure the message heading and format it for zenity # Check if lutris needs to be restarted after making changes
if [ "$use_zenity" -eq 1 ]; then lutris_restart
post_download_msg_heading="<b>$post_download_msg_heading</b>"
fi
# Display appropriate post-download message if [ "$display_post_download_msg" = "true" ]; then
if [ "$post_download_type" = "info" ]; then message_heading="Download Complete"
# Just displaying an informational message
message info "$post_download_msg_heading\n\n$post_download_msg"
elif [ "$post_download_type" = "configure-lutris" ]; then
# We need to configure and restart Lutris
unset lutris_game_ymls
# Build an array of all Lutris Star Citizen yml files
while IFS= read -rd ''; do
lutris_game_ymls+=("$REPLY")
done < <(grep -RlZ --include="*.yml" "Roberts Space Industries/RSI Launcher/RSI Launcher.exe" "$lutris_native_conf_dir" "$lutris_flatpak_conf_dir" 2>/dev/null)
# We handle installs and deletions differently # Format some variables for zenity
if [ "$download_action_success" = "installed" ]; then if [ "$use_zenity" -eq 1 ]; then
# We are installing something for Lutris message_heading="<b>$message_heading</b>"
if message question "$post_download_msg_heading\n\n$post_download_msg"; then post_download_msg_italics="<i>$post_download_msg_italics</i>"
# Cylce through all Lutris config files for Star Citizen and configure the downloaded item
for (( i=0; i<"${#lutris_game_ymls[@]}"; i++ )); do
# Replace the appropriate key:value line if it exists
sed -Ei "/^wine:/,/^[^[:blank:]]/ {/^[[:blank:]]*${post_download_sed_string}/s/${post_download_sed_string}.*/${post_download_sed_string}${downloaded_item_name}/}" "${lutris_game_ymls[i]}"
# If it doesn't exist, add it at the start of the wine: grouping # If we have a link to provide, format it as well
if ! grep -q "${post_download_sed_string}${downloaded_item_name}" "${lutris_game_ymls[i]}"; then if [ -n "$post_download_msg_link" ]; then
# This assumes an indent of two spaces before the key:value pair post_download_msg_link="<a href='$post_download_msg_link'>$post_download_msg_link</a>"
sed -i -e '/^wine:/a\' -e " ${post_download_sed_string}${downloaded_item_name}" "${lutris_game_ymls[i]}"
fi
done
# Lutris needs to be restarted after making changes
if [ "$(pgrep -f lutris)" ]; then
# For installations, we ask the user if we can configure and restart Lutris in the post_download_msg
lutris_restart
fi
fi fi
elif [ "$download_action_success" = "deleted" ]; then
# Find all Star Citizen Lutris configs and delete the matching key:value line
for (( i=0; i<"${#deleted_item_names[@]}"; i++ )); do
# Cylce through all Lutris config files for Star Citizen and remove the item
for (( j=0; j<"${#lutris_game_ymls[@]}"; j++ )); do
sed -Ei "/^wine:/,/^[^[:blank:]]/ {/${post_download_sed_string}${deleted_item_names[i]}/d}" "${lutris_game_ymls[j]}"
done
done
# Lutris needs to be restarted after making changes
if [ "$(pgrep -f lutris)" ] && message question "Lutris must be restarted to detect the changes.\nWould you like this Helper to restart it for you?"; then
# For deletions, we ask the user if it's okay to restart Lutris here
lutris_restart
fi
else
debug_print exit "Script error: Unknown download_action_success value in post_download function. Aborting."
fi fi
else
debug_print exit "Script error: Unknown post_download_type value in post_download function. Aborting." # Add newlines to the optional variables if set
if [ -n "$post_download_msg_more_info" ]; then
post_download_msg_more_info="\n\n$post_download_msg_more_info"
fi
if [ -n "$post_download_msg_link" ]; then
post_download_msg_link="\n$post_download_msg_link"
fi
# Display the info
message info "$message_heading\n\n$post_download_msg_text\n$post_download_msg_italics\n\n$downloaded_item_name$post_download_msg_more_info$post_download_msg_link"
fi fi
# Reset
display_post_download_msg="false"
} }
# Uninstall the selected item. Called by download_select_install() # Uninstall the selected item. Called by download_select_install()
# Note: The arrays installed_items and installed_item_names are expected to be set before calling this function # Note: The array installed_items is expected to be set before calling this function
download_delete() { download_delete() {
# This function expects an index number for the array installed_items to be passed in as an argument # This function expects an index number for the array installed_items to be passed in as an argument
if [ -z "$1" ]; then if [ -z "$1" ]; then
@ -1173,7 +1127,6 @@ download_delete() {
# Capture arguments and format a list of items # Capture arguments and format a list of items
item_to_delete=("$@") item_to_delete=("$@")
unset list_to_delete unset list_to_delete
unset deleted_item_names
for (( i=0; i<"${#item_to_delete[@]}"; i++ )); do for (( i=0; i<"${#item_to_delete[@]}"; i++ )); do
list_to_delete+="\n${installed_items[${item_to_delete[i]}]}" list_to_delete+="\n${installed_items[${item_to_delete[i]}]}"
done done
@ -1183,12 +1136,8 @@ download_delete() {
for (( i=0; i<"${#item_to_delete[@]}"; i++ )); do for (( i=0; i<"${#item_to_delete[@]}"; i++ )); do
rm -r "${installed_items[${item_to_delete[i]}]}" rm -r "${installed_items[${item_to_delete[i]}]}"
debug_print continue "Deleted ${installed_items[${item_to_delete[i]}]}" debug_print continue "Deleted ${installed_items[${item_to_delete[i]}]}"
# Store the names of deleted items for post_download() processing
deleted_item_names+=("${installed_item_names[${item_to_delete[i]}]}")
done done
# Mark success for triggering post-deletion actions lutris_needs_restart="true"
download_action_success="deleted"
fi fi
} }
@ -1376,10 +1325,12 @@ download_install() {
fi fi
done done
# We need to restart Lutris for the download to be detected
lutris_needs_restart="true"
# Store the final name of the downloaded directory # Store the final name of the downloaded directory
downloaded_item_name="$download_name" downloaded_item_name="$download_name"
# Mark success for triggering post-download actions # Trigger the post_download() function
download_action_success="installed" display_post_download_msg="true"
elif [ "$num_dirs" -gt 1 ] || [ "$num_files" -gt 0 ]; then elif [ "$num_dirs" -gt 1 ] || [ "$num_files" -gt 0 ]; then
# If the archive contains more than one directory or # If the archive contains more than one directory or
# one or more files, we must create a subdirectory # one or more files, we must create a subdirectory
@ -1403,10 +1354,12 @@ download_install() {
fi fi
done done
# We need to restart Lutris for the download to be detected
lutris_needs_restart="true"
# Store the final name of the downloaded directory # Store the final name of the downloaded directory
downloaded_item_name="$download_name" downloaded_item_name="$download_name"
# Mark success for triggering post-download actions # Trigger the post_download() function
download_action_success="installed" display_post_download_msg="true"
else else
# Some unexpected combination of directories and files # Some unexpected combination of directories and files
debug_print exit "Script error: Unexpected archive contents in download_install function. Aborting" debug_print exit "Script error: Unexpected archive contents in download_install function. Aborting"
@ -1666,9 +1619,6 @@ download_manage() {
unset menu_options unset menu_options
unset menu_actions unset menu_actions
# Initialize success
unset download_action_success
# Loop through the download_sources array and create a menu item # Loop through the download_sources array and create a menu item
# for each one. Even numbered elements will contain the item name # for each one. Even numbered elements will contain the item name
for (( i=0; i<"${#download_sources[@]}"; i=i+2 )); do for (( i=0; i<"${#download_sources[@]}"; i=i+2 )); do
@ -1691,18 +1641,16 @@ download_manage() {
# Call the menu function. It will use the options as configured above # Call the menu function. It will use the options as configured above
menu menu
# Perform post-download actions and display messages or instructions # Perform post-download actions and display messages or instructions
if [ -n "$download_action_success" ] && [ "$post_download_type" != "none" ]; then post_download
post_download
fi
done done
} }
# Configure the download_manage function for runners # Configure the download_manage function for runners
runner_manage() { runner_manage() {
# Lutris will need to be configured and restarted after modifying runners # Set some defaults
post_download_type="configure-lutris" lutris_needs_restart="false"
display_post_download_msg="false"
# Use indirect expansion to point download_sources # Use indirect expansion to point download_sources
# to the runner_sources array set at the top of the script # to the runner_sources array set at the top of the script
@ -1735,16 +1683,18 @@ runner_manage() {
download_menu_description="The runners listed below are wine builds created for Star Citizen" download_menu_description="The runners listed below are wine builds created for Star Citizen"
download_menu_height="140" download_menu_height="140"
# Configure the post download message # Set the post download instructions
# Format: # Format:
# A header is automatically displayed that reads: Download Complete # A header is automatically displayed that reads: Download Complete
# post_download_msg is displayed below the header # msg_text is displayed below the header
post_download_msg_heading="Download Complete" # msg_italics is displayed below that in italics when zenity is in use
post_download_msg="Would you like to automatically configure Lutris to use this runner?\n\nLutris will be restarted if necessary." # Then, the downloaded directory name is automatically displayed
# Set the string sed will match against when editing Lutris yml configs # Optional variables post_download_msg_more_info and
# This will be used to detect the appropriate yml key and replace its value # post_download_msg_link will be displayed if set
# with the name of the downloaded item post_download_msg_text="Select the following runner in Lutris from the dropdown menu under:"
post_download_sed_string="version: " post_download_msg_italics="Configure->Runner Options->Wine version"
post_download_msg_more_info=""
post_download_msg_link=""
# Call the download_manage function with the above configuration # Call the download_manage function with the above configuration
# The argument passed to the function is used for special handling # The argument passed to the function is used for special handling
@ -1754,8 +1704,9 @@ runner_manage() {
# Configure the download_manage function for dxvks # Configure the download_manage function for dxvks
dxvk_manage() { dxvk_manage() {
# Lutris will need to be configured and restarted after modifying dxvks # Set some defaults
post_download_type="configure-lutris" lutris_needs_restart="false"
display_post_download_msg="false"
# Use indirect expansion to point download_sources # Use indirect expansion to point download_sources
# to the dxvk_sources array set at the top of the script # to the dxvk_sources array set at the top of the script
@ -1785,19 +1736,21 @@ dxvk_manage() {
# Configure the text displayed in the menus # Configure the text displayed in the menus
download_menu_heading="Lutris DXVK Versions" download_menu_heading="Lutris DXVK Versions"
download_menu_description="The DXVK versions below may improve performance" download_menu_description="The DXVK versions below may help reduce stuttering"
download_menu_height="140" download_menu_height="140"
# Configure the post download message # Set the post download instructions
# Format: # Format:
# A header is automatically displayed that reads: Download Complete # A header is automatically displayed that reads: Download Complete
# post_download_msg is displayed below the header # msg_text is displayed below the header
post_download_msg_heading="Download Complete" # msg_italics is displayed below that in italics when zenity is in use
post_download_msg="Would you like to automatically configure Lutris to use this DXVK?\n\nLutris will be restarted if necessary." # Then, the downloaded directory name is automatically displayed
# Set the string sed will match against when editing Lutris yml configs # Optional variables post_download_msg_more_info and
# This will be used to detect the appropriate yml key and replace its value # post_download_msg_link will be displayed if set
# with the name of the downloaded item post_download_msg_text="Type the following DXVK name into your Lutris settings under:"
post_download_sed_string="dxvk_version: " post_download_msg_italics="Configure->Runner Options->DXVK version"
post_download_msg_more_info="See our wiki for instructions on setting the DXVK_ASYNC environment variable in Lutris:"
post_download_msg_link="https://github.com/starcitizen-lug/information-howtos/wiki/Performance-Tuning#dxvk-async"
# Call the download_manage function with the above configuration # Call the download_manage function with the above configuration
# The argument passed to the function is used for special handling # The argument passed to the function is used for special handling