Improve lutris install and restart functions

This commit is contained in:
the-sane 2022-10-21 23:39:48 -04:00
parent 02d8f4b685
commit bd119c4ce8

View File

@ -957,26 +957,16 @@ lutris_restart() {
lutris_detect
if [ "$lutris_needs_restart" = "true" ] && [ "$(pgrep -f lutris)" ]; then
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 Lutris..."
# Detect which version of Lutris is installed
if [ "$lutris_native" = "true" ] && [ "$lutris_flatpak" = "true" ]; then
# Both versions of Lutris are installed so ask the user
if zenity --question --cancel-label="Flatpak" --ok-label="Native" --window-icon="$lug_logo" --text="This Helper has detected both the Native and Flatpak versions of Lutris\nWhich version would you like to use?" --width="400" --title="Star Citizen LUG Helper" 2>/dev/null; then
# Native version
# Detect which version of Lutris is running and restart it
if [ "$lutris_native" = "true" ] && pgrep -f lutris | xargs ps -fp | grep -q "/usr/bin/lutris"; then
# Native Lutris is running
debug_print continue "Restarting native Lutris..."
pkill -f -SIGTERM lutris && nohup lutris </dev/null &>/dev/null &
else
# Flatpak version
pkill -f -SIGTERM lutris && nohup flatpak run net.lutris.Lutris </dev/null &>/dev/null &
fi
elif [ "$lutris_native" = "true" ]; then
# Native version only
pkill -f -SIGTERM lutris && nohup lutris </dev/null &>/dev/null &
elif [ "$lutris_flatpak" = "true" ]; then
# Flatpak version only
if [ "$lutris_flatpak" = "true" ] && pgrep -f lutris | xargs ps -fp | grep -q "lutris-wrapper"; 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 &
else
# We shouldn't get here
debug_print exit "Script error: Unknown condition in lutris_restart function. Aborting."
fi
fi
fi
@ -1717,20 +1707,30 @@ install_game() {
# Both versions of Lutris are installed so ask the user
if zenity --question --cancel-label="Flatpak" --ok-label="Native" --window-icon="$lug_logo" --text="This Helper has detected both the Native and Flatpak versions of Lutris\nWhich version would you like to use?" --width="400" --title="Star Citizen LUG Helper" 2>/dev/null; then
# Native version
lutris --install "$install_script" &
install_version="native"
else
# Flatpak version
flatpak run net.lutris.Lutris --install "$install_script" &
install_version="flatpak"
fi
elif [ "$lutris_native" = "true" ]; then
# Native version only
lutris --install "$install_script" &
install_version="native"
elif [ "$lutris_flatpak" = "true" ]; then
# Flatpak version only
install_version="flatpak"
else
# We shouldn't get here
debug_print exit "Script error: Unable to detect Lutris version in install_game function. Aborting."
fi
# Run the appropriate installer
if [ "$install_version" = "native" ]; then
lutris --install "$install_script" &
elif [ "$install_version" = "flatpak" ]; then
flatpak run net.lutris.Lutris --install "$install_script" &
else
# We shouldn't get here
debug_print exit "Script error: Unknown condition in install_game function. Aborting."
debug_print exit "Script error: Unknown condition for install_version in install_game() function. Aborting."
fi
message info "The installation will continue in Lutris"
fi