mirror of
https://github.com/the-sane/lug-helper.git
synced 2024-12-29 08:54:18 +00:00
Refactor post_download
This commit is contained in:
parent
514b176e14
commit
04819899fc
@ -1085,7 +1085,8 @@ get_lutris_dirs() {
|
|||||||
# Perform post-download actions or display a message/instructions
|
# Perform post-download actions or display a message/instructions
|
||||||
#
|
#
|
||||||
# Expects the following variables to be set:
|
# Expects the following variables to be set:
|
||||||
# post_download_type ("none", "info", or "question")
|
# post_download_type ("info", or "configure-lutris")
|
||||||
|
# post_download_msg_heading
|
||||||
# post_download_msg
|
# post_download_msg
|
||||||
# post_download_sed_string (for type question only)
|
# post_download_sed_string (for type question only)
|
||||||
# downloaded_item_name (set in download_install function)
|
# downloaded_item_name (set in download_install function)
|
||||||
@ -1100,19 +1101,20 @@ get_lutris_dirs() {
|
|||||||
# 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
|
# post_download_msg is displayed below the header
|
||||||
post_download() {
|
post_download() {
|
||||||
# Display appropriate post-install message
|
|
||||||
if [ "$download_action_success" = "installed" ]; then
|
|
||||||
message_heading="Download Complete"
|
|
||||||
# Configure the message heading and format it for zenity
|
# Configure the message heading and format it for zenity
|
||||||
if [ "$use_zenity" -eq 1 ]; then
|
if [ "$use_zenity" -eq 1 ]; then
|
||||||
message_heading="<b>$message_heading</b>"
|
post_download_msg_heading="<b>$post_download_msg_heading</b>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Display appropriate post-download message
|
||||||
if [ "$post_download_type" = "info" ]; then
|
if [ "$post_download_type" = "info" ]; then
|
||||||
# Just displaying an informational message
|
# Just displaying an informational message
|
||||||
message info "$message_heading\n\n$post_download_msg"
|
message info "$post_download_msg_heading\n\n$post_download_msg"
|
||||||
elif [ "$post_download_type" = "question" ]; then
|
elif [ "$post_download_type" = "configure-lutris" ]; then
|
||||||
# We have an action we want to perform
|
# We need to configure and restart Lutris
|
||||||
if message question "$message_heading\n\n$post_download_msg"; then
|
if [ "$download_action_success" = "installed" ]; then
|
||||||
|
# We are installing something for Lutris
|
||||||
|
if message question "$post_download_msg_heading\n\n$post_download_msg"; then
|
||||||
# Find all Star Citizen Lutris configs and replace the appropriate key
|
# Find all Star Citizen Lutris configs and replace the appropriate key
|
||||||
# to configure the downloaded item
|
# to configure the downloaded item
|
||||||
unset lutris_game_ymls
|
unset lutris_game_ymls
|
||||||
@ -1132,15 +1134,12 @@ post_download() {
|
|||||||
sed -i -e '/^wine:/a\' -e " ${post_download_sed_string}${downloaded_item_name}" "${lutris_game_ymls[i]}"
|
sed -i -e '/^wine:/a\' -e " ${post_download_sed_string}${downloaded_item_name}" "${lutris_game_ymls[i]}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if lutris needs to be restarted after making changes
|
# Lutris needs to be restarted after making changes
|
||||||
if [ "$lutris_needs_restart" = "true" ] && [ "$(pgrep -f lutris)" ]; then
|
if [ "$(pgrep -f lutris)" ]; then
|
||||||
# For installations, we ask the user if we can configure and restart Lutris in the post_download_msg
|
# For installations, we ask the user if we can configure and restart Lutris in the post_download_msg
|
||||||
lutris_restart
|
lutris_restart
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
debug_print exit "Script error: Unknown post_download_type value in post_download function. Aborting."
|
|
||||||
fi
|
fi
|
||||||
elif [ "$download_action_success" = "deleted" ]; then
|
elif [ "$download_action_success" = "deleted" ]; then
|
||||||
# Find all Star Citizen Lutris configs and delete the matching key:value line
|
# Find all Star Citizen Lutris configs and delete the matching key:value line
|
||||||
@ -1148,15 +1147,17 @@ post_download() {
|
|||||||
grep -RlZ --include="*.yml" "Roberts Space Industries/RSI Launcher/RSI Launcher.exe" "$lutris_native_conf_dir" "$lutris_flatpak_conf_dir" 2>/dev/null | xargs -0 sed -Ei "/^wine:/,/^[^[:blank:]]/ {/${post_download_sed_string}${deleted_item_names[i]}/d}"
|
grep -RlZ --include="*.yml" "Roberts Space Industries/RSI Launcher/RSI Launcher.exe" "$lutris_native_conf_dir" "$lutris_flatpak_conf_dir" 2>/dev/null | xargs -0 sed -Ei "/^wine:/,/^[^[:blank:]]/ {/${post_download_sed_string}${deleted_item_names[i]}/d}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if lutris needs to be restarted after making changes
|
# Lutris needs to be restarted after making changes
|
||||||
if [ "$lutris_needs_restart" = "true" ] && [ "$(pgrep -f lutris)" ] &&
|
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
|
||||||
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
|
# For deletions, we ask the user if it's okay to restart Lutris here
|
||||||
lutris_restart
|
lutris_restart
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
debug_print exit "Script error: Unknown download_action_success value in post_download function. Aborting."
|
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."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Uninstall the selected item. Called by download_select_install()
|
# Uninstall the selected item. Called by download_select_install()
|
||||||
@ -1698,10 +1699,8 @@ download_manage() {
|
|||||||
|
|
||||||
# Configure the download_manage function for runners
|
# Configure the download_manage function for runners
|
||||||
runner_manage() {
|
runner_manage() {
|
||||||
# Lutris will need to be restarted after modifying runners
|
# Lutris will need to be configured and restarted after modifying runners
|
||||||
lutris_needs_restart="true"
|
post_download_type="configure-lutris"
|
||||||
# We will get permission from the user to configure and restart Lutris
|
|
||||||
post_download_type="question"
|
|
||||||
|
|
||||||
# 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
|
||||||
@ -1738,6 +1737,7 @@ runner_manage() {
|
|||||||
# 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
|
# post_download_msg is displayed below the header
|
||||||
|
post_download_msg_heading="Download Complete"
|
||||||
post_download_msg="Would you like to automatically configure Lutris to use this runner?\n\nLutris will be restarted to detect the changes."
|
post_download_msg="Would you like to automatically configure Lutris to use this runner?\n\nLutris will be restarted to detect the changes."
|
||||||
# Set the string sed will match against when editing Lutris yml configs
|
# Set the string sed will match against when editing Lutris yml configs
|
||||||
# This will be used to detect the appropriate yml key and replace its value
|
# This will be used to detect the appropriate yml key and replace its value
|
||||||
@ -1752,10 +1752,8 @@ 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 restarted after modifying dxvks
|
# Lutris will need to be configured and restarted after modifying dxvks
|
||||||
lutris_needs_restart="true"
|
post_download_type="configure-lutris"
|
||||||
# We will get permission from the user to configure and restart Lutris
|
|
||||||
post_download_type="question"
|
|
||||||
|
|
||||||
# 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
|
||||||
@ -1792,6 +1790,7 @@ dxvk_manage() {
|
|||||||
# 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
|
# post_download_msg is displayed below the header
|
||||||
|
post_download_msg_heading="Download Complete"
|
||||||
post_download_msg="Would you like to automatically configure Lutris to use this DXVK?\n\nLutris will be restarted to detect the changes."
|
post_download_msg="Would you like to automatically configure Lutris to use this DXVK?\n\nLutris will be restarted to detect the changes."
|
||||||
# Set the string sed will match against when editing Lutris yml configs
|
# Set the string sed will match against when editing Lutris yml configs
|
||||||
# This will be used to detect the appropriate yml key and replace its value
|
# This will be used to detect the appropriate yml key and replace its value
|
||||||
|
Loading…
Reference in New Issue
Block a user