mirror of
https://github.com/the-sane/lug-helper.git
synced 2025-01-16 08:00:36 +00:00
Compare commits
No commits in common. "6ddf8e6532393fcdf16510b4af064811a138b7e4" and "56f61bcb35f8d95887a8b6f0c9afa7198bdc4d52" have entirely different histories.
6ddf8e6532
...
56f61bcb35
157
lug-helper.sh
157
lug-helper.sh
@ -72,20 +72,11 @@ fi
|
||||
# exit 1
|
||||
#fi
|
||||
if [ ! -x "$(command -v mktemp)" ] || [ ! -x "$(command -v sort)" ] || [ ! -x "$(command -v basename)" ] || [ ! -x "$(command -v realpath)" ] || [ ! -x "$(command -v dirname)" ]; then
|
||||
# coreutils
|
||||
# Print to stderr and also try warning the user through notify-send
|
||||
printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that the following coreutils packages are installed:\n- mktemp\n- sort\n- basename\n- realpath\n- dirname\n" 1>&2
|
||||
notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that the following coreutils packages are installed:\n- mktemp\n- sort\n- basename\n- realpath\n- dirname\n" --icon=dialog-warning
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -x "$(command -v xargs)" ]; then
|
||||
# findutils
|
||||
# Print to stderr and also try warning the user through notify-send
|
||||
printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that the following findutils packages are installed:\n- xargs\n" 1>&2
|
||||
notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that the following findutils packages are installed:\n- xargs\n" --icon=dialog-warning
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
######## Config ############################################################
|
||||
|
||||
@ -160,9 +151,9 @@ runners_dir_flatpak="$lutris_flatpak_dir/data/lutris/runners/wine"
|
||||
# The second is expected to contain the github api releases url
|
||||
# ie. "RawFox" "https://api.github.com/repos/rawfoxDE/raw-wine/releases"
|
||||
runner_sources=(
|
||||
"GloriousEggroll" "https://api.github.com/repos/GloriousEggroll/wine-ge-custom/releases"
|
||||
"RawFox" "https://api.github.com/repos/starcitizen-lug/raw-wine/releases"
|
||||
"/dev/null" "https://api.github.com/repos/gort818/wine-sc-lug/releases"
|
||||
"GloriousEggroll" "https://api.github.com/repos/GloriousEggroll/wine-ge-custom/releases"
|
||||
)
|
||||
|
||||
######## DXVK ##############################################################
|
||||
@ -178,10 +169,9 @@ dxvk_dir_flatpak="$lutris_flatpak_dir/data/lutris/runtime/dxvk"
|
||||
# The second is expected to contain the github api releases url
|
||||
# ie. "Sporif Async" "https://api.github.com/repos/Sporif/dxvk-async/releases"
|
||||
dxvk_sources=(
|
||||
"doitsujin (official dxvk)" "https://api.github.com/repos/doitsujin/dxvk/releases"
|
||||
"Sporif Async" "https://api.github.com/repos/Sporif/dxvk-async/releases"
|
||||
"gnusenpai" "https://api.github.com/repos/gnusenpai/dxvk/releases"
|
||||
"/dev/null" "https://api.github.com/repos/gort818/dxvk/releases"
|
||||
"gnusenpai" "https://api.github.com/repos/gnusenpai/dxvk/releases"
|
||||
)
|
||||
|
||||
######## Bundled Files #####################################################
|
||||
@ -315,12 +305,6 @@ message() {
|
||||
margs=("--warning" "--window-icon=\"$lug_logo\"" "--text=")
|
||||
shift 1 # drop the message type argument and shift up to the text
|
||||
;;
|
||||
"error")
|
||||
# error message
|
||||
# call format: message error "text to display"
|
||||
margs=("--error" "--window-icon=\"$lug_logo\"" "--text=")
|
||||
shift 1 # drop the message type argument and shift up to the text
|
||||
;;
|
||||
"question")
|
||||
# question
|
||||
# call format: if message question "question to ask?"; then...
|
||||
@ -361,12 +345,6 @@ message() {
|
||||
printf "\n$2\n\n"
|
||||
read -n 1 -s -p "Press any key..."
|
||||
;;
|
||||
"error")
|
||||
# error message. Does not clear the screen
|
||||
# call format: message error "text to display"
|
||||
printf "\n$2\n\n"
|
||||
read -n 1 -s -p "Press any key..."
|
||||
;;
|
||||
"question")
|
||||
# question
|
||||
# call format: if message question "question to ask?"; then...
|
||||
@ -551,7 +529,7 @@ menu_loop_done() {
|
||||
getdirs() {
|
||||
# Sanity checks
|
||||
if [ ! -d "$conf_dir" ]; then
|
||||
message error "Config directory not found. The Helper is unable to proceed.\n\n$conf_dir"
|
||||
message warning "Config directory not found. The Helper is unable to proceed.\n\n$conf_dir"
|
||||
return 1
|
||||
fi
|
||||
if [ ! -d "$conf_dir/$conf_subdir" ]; then
|
||||
@ -584,7 +562,7 @@ getdirs() {
|
||||
if [ -z "$wine_prefix" ]; then
|
||||
wine_prefix="$(zenity --file-selection --directory --title="Select your Star Citizen WINE prefix directory" --filename="$HOME/Games/star-citizen" 2>/dev/null)"
|
||||
if [ "$?" -eq -1 ]; then
|
||||
message error "An unexpected error has occurred. The Helper is unable to proceed."
|
||||
message warning "An unexpected error has occurred. The Helper is unable to proceed."
|
||||
return 1
|
||||
elif [ -z "$wine_prefix" ]; then
|
||||
# User clicked cancel
|
||||
@ -601,7 +579,7 @@ getdirs() {
|
||||
else
|
||||
while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/$install_path" 2>/dev/null)"; do
|
||||
if [ "$?" -eq -1 ]; then
|
||||
message error "An unexpected error has occurred. The Helper is unable to proceed."
|
||||
message warning "An unexpected error has occurred. The Helper is unable to proceed."
|
||||
return 1
|
||||
elif [ "$(basename "$game_path")" != "$sc_base_dir" ]; then
|
||||
message warning "You must select the base game directory named '$sc_base_dir'\n\nie. [prefix]/drive_c/Program Files/Roberts Space Industries/StarCitizen"
|
||||
@ -1005,7 +983,7 @@ preflight_check() {
|
||||
# Try to execute the actions as root
|
||||
try_exec "$preflight_actions_string"
|
||||
if [ "$?" -eq 1 ]; then
|
||||
message error "Authentication failed or there was an error.\nSee terminal for more information.\n\nReturning to main menu."
|
||||
message info "Authentication failed or there was an error.\nSee terminal for more information.\n\nReturning to main menu."
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
@ -1060,10 +1038,10 @@ lutris_restart() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Create an array of directories used by Lutris
|
||||
# Array will be formatted in pairs of ("[type]" "[directory]")
|
||||
# Get an array of directories used by Lutris
|
||||
# Supports native install and flatpak
|
||||
# Takes an argument to specify the type to return: "runner" or "dxvk"
|
||||
# Array must be formatted in pairs of ("[type]" "[directory]")
|
||||
# Takes an argument to specify the type to return, ie "runner" or "dxvk"
|
||||
get_lutris_dirs() {
|
||||
# Sanity check
|
||||
if [ "$#" -lt 1 ]; then
|
||||
@ -1106,14 +1084,13 @@ get_lutris_dirs() {
|
||||
|
||||
# Perform post-download actions or display a message/instructions
|
||||
#
|
||||
# The following variables are expected to be set before calling this function:
|
||||
# - post_download_type (string. "none", "info", or "configure-lutris")
|
||||
# - post_download_msg_heading (string)
|
||||
# - post_download_msg (string)
|
||||
# - post_download_sed_string (string. For type configure-lutris)
|
||||
# - download_action_success (string. Set automatically in install/delete functions)
|
||||
# - downloaded_item_name (string. For installs only. Set automatically in download_install function)
|
||||
# - deleted_item_names (array. For deletions only. Set automatically in download_delete function)
|
||||
# Expects the following variables to be set:
|
||||
# post_download_type ("info", or "configure-lutris")
|
||||
# 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
|
||||
@ -1124,17 +1101,6 @@ get_lutris_dirs() {
|
||||
# A header is automatically displayed that reads: Download Complete
|
||||
# post_download_msg is displayed below the header
|
||||
post_download() {
|
||||
# Sanity checks
|
||||
if [ -z "$post_download_type" ]; then
|
||||
debug_print exit "Script error: The string 'post_download_type' was not set\nbefore calling the post_download function. Aborting."
|
||||
elif [ -z "$post_download_msg_heading" ]; then
|
||||
debug_print exit "Script error: The string 'post_download_msg_heading' was not set\nbefore calling the post_download function. Aborting."
|
||||
elif [ -z "$post_download_msg" ]; then
|
||||
debug_print exit "Script error: The string 'post_download_msg' was not set\nbefore calling the post_download function. Aborting."
|
||||
elif [ -z "$post_download_sed_string" ] && [ "$post_download_type" = "configure-lutris" ]; then
|
||||
debug_print exit "Script error: The string 'post_download_sed_string' was not set\nbefore calling the post_download function. Aborting."
|
||||
fi
|
||||
|
||||
# Configure the message heading and format it for zenity
|
||||
if [ "$use_zenity" -eq 1 ]; then
|
||||
post_download_msg_heading="<b>$post_download_msg_heading</b>"
|
||||
@ -1196,28 +1162,14 @@ post_download() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Uninstall the selected item(s). Called by download_select_install()
|
||||
# Accepts array index numbers as an argument
|
||||
#
|
||||
# The following variables are expected to be set before calling this function:
|
||||
# - download_type (string)
|
||||
# - installed_items (array)
|
||||
# - installed_item_names (array)
|
||||
# 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
|
||||
download_delete() {
|
||||
# This function expects at least one 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
|
||||
debug_print exit "Script error: The download_delete function expects an argument. Aborting."
|
||||
fi
|
||||
|
||||
# Sanity checks
|
||||
if [ -z "$download_type" ]; then
|
||||
debug_print exit "Script error: The string 'download_type' was not set\nbefore calling the download_delete function. Aborting."
|
||||
elif [ "${#installed_items[@]}" -eq 0 ]; then
|
||||
debug_print exit "Script error: The array 'installed_items' was not set\nbefore calling the download_delete function. Aborting."
|
||||
elif [ "${#installed_item_names[@]}" -eq 0 ]; then
|
||||
debug_print exit "Script error: The array 'installed_item_names' was not set\nbefore calling the download_delete function. Aborting."
|
||||
fi
|
||||
|
||||
|
||||
# Capture arguments and format a list of items
|
||||
item_to_delete=("$@")
|
||||
unset list_to_delete
|
||||
@ -1241,18 +1193,7 @@ download_delete() {
|
||||
}
|
||||
|
||||
# List installed items for deletion. Called by download_manage()
|
||||
#
|
||||
# The following variables are expected to be set before calling this function:
|
||||
# - download_type (string)
|
||||
# - download_dirs (array)
|
||||
download_select_delete() {
|
||||
# Sanity checks
|
||||
if [ -z "$download_type" ]; then
|
||||
debug_print exit "Script error: The string 'download_type' was not set\nbefore calling the download_select_delete function. Aborting."
|
||||
elif [ "${#download_dirs[@]}" -eq 0 ]; then
|
||||
debug_print exit "Script error: The array 'download_dirs' was not set\nbefore calling the download_select_delete function. Aborting."
|
||||
fi
|
||||
|
||||
# Configure the menu
|
||||
menu_text_zenity="Select the $download_type(s) you want to remove:"
|
||||
menu_text_terminal="Select the $download_type you want to remove:"
|
||||
@ -1306,13 +1247,7 @@ download_select_delete() {
|
||||
}
|
||||
|
||||
# Download and install the selected item. Called by download_select_install()
|
||||
#
|
||||
# The following variables are expected to be set before calling this function:
|
||||
# - download_versions (array)
|
||||
# - contributor_url (string)
|
||||
# - download_url_type (string)
|
||||
# - download_type (string)
|
||||
# - download_dirs (array)
|
||||
# Note: The variables download_versions, contributor_url, and download_url_type are expected to be set before calling this function
|
||||
download_install() {
|
||||
# This function expects an index number for the array
|
||||
# download_versions to be passed in as an argument
|
||||
@ -1320,19 +1255,6 @@ download_install() {
|
||||
debug_print exit "Script error: The download_install function expects a numerical argument. Aborting."
|
||||
fi
|
||||
|
||||
# Sanity checks
|
||||
if [ "${#download_versions[@]}" -eq 0 ]; then
|
||||
debug_print exit "Script error: The array 'download_versions' was not set\nbefore calling the download_install function. Aborting."
|
||||
elif [ -z "$contributor_url" ]; then
|
||||
debug_print exit "Script error: The string 'contributor_url' was not set\nbefore calling the download_install function. Aborting."
|
||||
elif [ -z "$download_url_type" ]; then
|
||||
debug_print exit "Script error: The string 'download_url_type' was not set\nbefore calling the download_install function. Aborting."
|
||||
elif [ -z "$download_type" ]; then
|
||||
debug_print exit "Script error: The string 'download_type' was not set\nbefore calling the download_install function. Aborting."
|
||||
elif [ "${#download_dirs[@]}" -eq 0 ]; then
|
||||
debug_print exit "Script error: The array 'download_dirs' was not set\nbefore calling the download_install function. Aborting."
|
||||
fi
|
||||
|
||||
# Get the filename including file extension
|
||||
download_file="${download_versions[$1]}"
|
||||
|
||||
@ -1497,26 +1419,12 @@ download_install() {
|
||||
}
|
||||
|
||||
# List available items for download. Called by download_manage()
|
||||
#
|
||||
# The following variables are expected to be set before calling this function:
|
||||
# - download_sources (array)
|
||||
# - download_type (string)
|
||||
# - download_dirs (array)
|
||||
download_select_install() {
|
||||
# This function expects an element number for the sources array
|
||||
# to be passed in as an argument
|
||||
if [ -z "$1" ]; then
|
||||
debug_print exit "Script error: The download_select_install function expects a numerical argument. Aborting."
|
||||
fi
|
||||
|
||||
# Sanity checks
|
||||
if [ "${#download_sources[@]}" -eq 0 ]; then
|
||||
debug_print exit "Script error: The array 'download_sources' was not set\nbefore calling the download_select_install function. Aborting."
|
||||
elif [ -z "$download_type" ]; then
|
||||
debug_print exit "Script error: The string 'download_type' was not set\nbefore calling the download_select_install function. Aborting."
|
||||
elif [ "${#download_dirs[@]}" -eq 0 ]; then
|
||||
debug_print exit "Script error: The array 'download_dirs' was not set\nbefore calling the download_select_install function. Aborting."
|
||||
fi
|
||||
|
||||
# Store info from the selected contributor
|
||||
contributor_name="${download_sources[$1]}"
|
||||
@ -1740,19 +1648,6 @@ download_manage() {
|
||||
debug_print exit "Script error: The download_manage function expects a string argument. Aborting."
|
||||
fi
|
||||
|
||||
# Sanity checks
|
||||
if [ -z "$download_sources" ]; then
|
||||
debug_print exit "Script error: The string 'download_sources' was not set\nbefore calling the download_manage function. Aborting."
|
||||
elif [ "${#download_dirs[@]}" -eq 0 ]; then
|
||||
debug_print exit "Script error: The array 'download_dirs' was not set\nbefore calling the download_manage function. Aborting."
|
||||
elif [ -z "$download_menu_heading" ]; then
|
||||
debug_print exit "Script error: The string 'download_menu_heading' was not set\nbefore calling the download_manage function. Aborting."
|
||||
elif [ -z "$download_menu_description" ]; then
|
||||
debug_print exit "Script error: The string 'download_menu_description' was not set\nbefore calling the download_manage function. Aborting."
|
||||
elif [ -z "$download_menu_height" ]; then
|
||||
debug_print exit "Script error: The string 'download_menu_height' was not set\nbefore calling the download_manage function. Aborting."
|
||||
fi
|
||||
|
||||
# Get the type of item we're downloading from the function arguments
|
||||
download_type="$1"
|
||||
|
||||
@ -1807,7 +1702,6 @@ download_manage() {
|
||||
# Configure the download_manage function for runners
|
||||
runner_manage() {
|
||||
# Lutris will need to be configured and restarted after modifying runners
|
||||
# Valid options are "none", "info", or "configure-lutris"
|
||||
post_download_type="configure-lutris"
|
||||
|
||||
# Use indirect expansion to point download_sources
|
||||
@ -1827,7 +1721,8 @@ runner_manage() {
|
||||
missing_dir="false"
|
||||
for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do
|
||||
if [ ! -d "${download_dirs[i]}" ]; then
|
||||
message error "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
|
||||
message warning "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
|
||||
debug_print continue "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
|
||||
missing_dir="true"
|
||||
fi
|
||||
done
|
||||
@ -1860,7 +1755,6 @@ runner_manage() {
|
||||
# Configure the download_manage function for dxvks
|
||||
dxvk_manage() {
|
||||
# Lutris will need to be configured and restarted after modifying dxvks
|
||||
# Valid options are "none", "info", or "configure-lutris"
|
||||
post_download_type="configure-lutris"
|
||||
|
||||
# Use indirect expansion to point download_sources
|
||||
@ -1880,7 +1774,8 @@ dxvk_manage() {
|
||||
missing_dir="false"
|
||||
for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do
|
||||
if [ ! -d "${download_dirs[i]}" ]; then
|
||||
message error "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
|
||||
message warning "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
|
||||
debug_print continue "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
|
||||
missing_dir="true"
|
||||
fi
|
||||
done
|
||||
@ -2237,7 +2132,7 @@ eac_workaround() {
|
||||
# Try to modify /etc/hosts as root
|
||||
try_exec "printf '\n$eac_hosts #Star Citizen EAC workaround\n' >> /etc/hosts"
|
||||
if [ "$?" -eq 1 ]; then
|
||||
message error "Authentication failed or there was an error modifying /etc/hosts.\nSee terminal for more information.\n\nReturning to main menu."
|
||||
message info "Authentication failed or there was an error modifying /etc/hosts.\nSee terminal for more information.\n\nReturning to main menu."
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user