54 Commits

Author SHA1 Message Date
fdfd512bfc These are numbers, not strings 2022-10-31 14:58:07 -04:00
8f86d37b88 Handle errors in pkexec and sudo 2022-10-31 14:54:17 -04:00
677a789ab5 Merge pull request #47 from starcitizen-lug/flatpak
Merge Flatpak branch
2022-10-31 13:52:40 -04:00
1fe9af78b1 Change flatpak process grep 2022-10-30 18:02:22 -04:00
03cf7a9aa0 Cosmetic: Update function group headers 2022-10-22 22:49:22 -04:00
7d342416f7 Make install json available to flatpak lutris 2022-10-22 14:56:44 -04:00
1a1c3cf0b8 New message type, dialog with two options 2022-10-22 10:07:17 -04:00
5cfb306289 Rearrange main 2022-10-22 00:04:37 -04:00
80017b848e Add show-wiki to command line arguments 2022-10-22 00:00:58 -04:00
80db33be07 Add EAC workaround to command line arguments 2022-10-21 23:58:52 -04:00
c497f8e1d8 Improve runner/dxvk in display_dirs() 2022-10-21 23:56:15 -04:00
eedb5de460 Change counter variable
i gets used by some of the functions being called
2022-10-21 23:51:13 -04:00
3a7e0996b5 Print error to console as well 2022-10-21 23:48:54 -04:00
402b22ea45 Change message type to warning 2022-10-21 23:45:15 -04:00
10812a622d Don't return 0 here 2022-10-21 23:44:08 -04:00
f5abb87cb5 Return 0 2022-10-21 23:42:52 -04:00
bd119c4ce8 Improve lutris install and restart functions 2022-10-21 23:39:48 -04:00
02d8f4b685 Fix restarting flatpak lutris 2022-10-21 19:29:15 -04:00
bef1c34491 Ask the user which lutris to install with 2022-10-21 19:19:52 -04:00
7090acf1eb Fix launching flatpak lutris during game install 2022-10-21 19:09:11 -04:00
883163843e Fix flatpak lutris detection 2022-10-21 18:44:53 -04:00
6a665bceac Add support for Flatpak Lutris 2022-10-21 18:29:58 -04:00
1844bfda13 Detect flatpak lutris 2022-10-18 11:45:24 -04:00
f78f54ddf7 Put lutris detection in its own function
Preparation for flatpak support
2022-10-18 11:12:14 -04:00
167edab6ec Comment out zstd dependency (TKG runners removed) 2022-10-18 11:10:21 -04:00
1b334db7cc Check if it's already been installed 2022-10-17 17:17:21 -04:00
dc648a8f6f Clean up extracted directories too 2022-10-17 16:48:11 -04:00
7426d0ffb3 Update formatting 2022-10-16 11:20:13 -04:00
1cb9eb6488 Update README.md 2022-10-16 11:16:44 -04:00
a8c4257430 Bump version 2022-10-16 11:04:15 -04:00
b2f542e029 Remove TKG from runner sources
They've switched to CI builds, which we don't currently support
2022-10-16 11:03:44 -04:00
17b1bfe140 Rename function 2022-10-16 11:00:16 -04:00
f19faa8235 Refactor rm_shaders() 2022-10-16 10:57:01 -04:00
7cc4cca62d Fix error message (variable not yet set) 2022-10-16 00:08:02 -04:00
8f857476d0 Quiet grep in eac_workaround() 2022-10-15 16:00:18 -04:00
652c2fa4a0 Add shaders path to display directories feature
...in the maintenance & troubleshooting menu
2022-10-15 15:46:09 -04:00
6e4feecc85 Update phrasing 2022-10-15 15:06:02 -04:00
0e5fe688eb Quote zenity window icon path to handle spaces 2022-10-15 14:57:00 -04:00
8d130668d6 Fix pgrep/pkill commands to auto-restart Lutris 2022-10-15 14:41:31 -04:00
142e09800f Refactor download_select_install() function 2022-10-15 14:24:31 -04:00
1ae94e9b50 Add a referral code
Closes #43
2022-07-10 14:14:17 -06:00
747c799a8b more general message on zstd dependency check 2022-06-23 10:01:59 +02:00
ba907c44bf check if EAC-Workaround is commented out 2022-06-20 15:00:35 +02:00
e7a3b30564 check if zstd is installed 2022-06-20 14:44:42 +02:00
38e646578a format README.md - damn markdown newlines ;) 2022-06-16 09:02:39 +02:00
d0dc44dcd9 format README.md again 2022-06-16 08:57:11 +02:00
9986f1fe8c format README.md 2022-06-16 08:55:46 +02:00
bc11c184d2 Merge branch 'master' of github.com:starcitizen-lug/lug-helper 2022-06-16 08:48:51 +02:00
02a79aa859 added dependencies to Readme and glibc check to TKG 2022-06-16 08:48:02 +02:00
2eabf019a6 Merge pull request #40 from snatella/remove-molotov-releases
Remove snatella/molotov runners for now
2022-06-08 11:12:29 +02:00
bdb71475a8 Remove snatella/molotov runners for now 2022-06-07 09:15:44 +01:00
c627666705 added download option for TKG runners 2022-05-18 12:51:11 +02:00
65ac8ae4cd fixed if statement in rm_shaders 2022-05-16 18:37:32 +02:00
b4d9598fe5 simplified if statement for shader removal 2022-05-16 15:52:51 +02:00
2 changed files with 477 additions and 161 deletions

View File

@ -43,8 +43,8 @@ Keybinds are backed up to *$XDG_CONFIG_HOME/starcitizen-lug/keybinds/*
- To re-import your keybinds from within the game, select them from the list: - To re-import your keybinds from within the game, select them from the list:
- *Options->Keybindings->Control Profiles* - *Options->Keybindings->Control Profiles*
- `Delete my shaders folder only` - `Delete my shaders`
- Sometimes all you need to do between major version updates is delete your shaders directory. - It is recommended to delete your shaders directory after each game update.
- `Delete my DXVK cache` - `Delete my DXVK cache`
- A troubleshooting step that sometimes helps fix various issues and crashes. - A troubleshooting step that sometimes helps fix various issues and crashes.
@ -55,6 +55,9 @@ Keybinds are backed up to *$XDG_CONFIG_HOME/starcitizen-lug/keybinds/*
- `Reset Helper configs` - `Reset Helper configs`
- Delete the configs saved by the helper in *$XDG_CONFIG_HOME/starcitizen-lug/* - Delete the configs saved by the helper in *$XDG_CONFIG_HOME/starcitizen-lug/*
- `Show the LUG Wiki`
- Display a link to the LUG Wiki for help with installation and troubleshooting
`Get a random Penguin's Star Citizen referral code` `Get a random Penguin's Star Citizen referral code`
- Display a referral code for a random member of the Star Citizen Linux Users Group. - Display a referral code for a random member of the Star Citizen Linux Users Group.
@ -69,6 +72,9 @@ From Source:
Arch Linux: https://aur.archlinux.org/packages/lug-helper/ Arch Linux: https://aur.archlinux.org/packages/lug-helper/
_Dependencies: **bash**, **coreutils**, **curl**, **polkit** (these should be installed by default on most distributions)_
_Optional Dependencies: **zenity** (for GUI), **zstd** (to extract some runners)_
## Contributors: ## Contributors:
- https://github.com/Termuellinator - https://github.com/Termuellinator
- https://github.com/pstn - https://github.com/pstn

View File

@ -65,6 +65,12 @@ if [ ! -x "$(command -v curl)" ]; then
notify-send "lug-helper" "The required package 'curl' was not found on this system.\n" --icon=dialog-warning notify-send "lug-helper" "The required package 'curl' was not found on this system.\n" --icon=dialog-warning
exit 1 exit 1
fi fi
#if [ ! -x "$(command -v zstd)" ]; then
# Print to stderr and also try warning the user through notify-send
# printf "lug-helper.sh: The package 'zstd' was not found on this system. It is required for extracting some runner packages.\n" 1>&2
# notify-send "lug-helper" "The package 'zstd' was not found on this system. It is required for extracting some runner packages.\n" --icon=dialog-warning
# 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 if [ ! -x "$(command -v mktemp)" ] || [ ! -x "$(command -v sort)" ] || [ ! -x "$(command -v basename)" ] || [ ! -x "$(command -v realpath)" ] || [ ! -x "$(command -v dirname)" ]; then
# Print to stderr and also try warning the user through notify-send # 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 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
@ -102,14 +108,21 @@ install_path="drive_c/Program Files/Roberts Space Industries/$sc_base_dir"
live_dir="LIVE" live_dir="LIVE"
ptu_dir="PTU" ptu_dir="PTU"
# AppData directory # Location in the WINE prefix where shaders are stored
appdata_path="drive_c/users/$USER/AppData/Local/Star Citizen" appdata_path="drive_c/users/$USER/AppData/Local/Star Citizen"
# The shaders subdirectory name
shaders_subdir="shaders"
# Remaining directory paths are set at the end of the getdirs() function # Remaining directory paths are set at the end of the getdirs() function
######## Runners ########################################################### ######## Runners ###########################################################
# Lutris wine runners directory # Lutris native wine runners directory
runners_dir="$data_dir/lutris/runners/wine" runners_dir_native="$data_dir/lutris/runners/wine"
# Lutris flatpak wine runners directory
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"
# The first string in the pair is expected to contain the runner description # The first string in the pair is expected to contain the runner description
@ -117,15 +130,17 @@ runners_dir="$data_dir/lutris/runners/wine"
# ie. "RawFox" "https://api.github.com/repos/rawfoxDE/raw-wine/releases" # ie. "RawFox" "https://api.github.com/repos/rawfoxDE/raw-wine/releases"
runner_sources=( runner_sources=(
"RawFox" "https://api.github.com/repos/starcitizen-lug/raw-wine/releases" "RawFox" "https://api.github.com/repos/starcitizen-lug/raw-wine/releases"
"Molotov/Snatella" "https://api.github.com/repos/snatella/wine-runner-sc/releases"
"/dev/null" "https://api.github.com/repos/gort818/wine-sc-lug/releases" "/dev/null" "https://api.github.com/repos/gort818/wine-sc-lug/releases"
"GloriousEggroll" "https://api.github.com/repos/GloriousEggroll/wine-ge-custom/releases" "GloriousEggroll" "https://api.github.com/repos/GloriousEggroll/wine-ge-custom/releases"
) )
######## DXVK ############################################################## ######## DXVK ##############################################################
# Lutris dxvk directory # Lutris native dxvk directory
dxvk_dir="$data_dir/lutris/runtime/dxvk" dxvk_dir_native="$data_dir/lutris/runtime/dxvk"
# Lutris flatpak dxvk directory
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"
# The first string in the pair is expected to contain the runner description # The first string in the pair is expected to contain the runner description
@ -172,10 +187,11 @@ lug_wiki="https://github.com/starcitizen-lug/information-howtos/wiki"
# Github repo and script version info # Github repo and script version info
repo="starcitizen-lug/lug-helper" repo="starcitizen-lug/lug-helper"
releases_url="https://github.com/$repo/releases" releases_url="https://github.com/$repo/releases"
current_version="v1.20" current_version="v1.22"
############################################################################ ############################################################################
############################################################################ ############################################################################
############################################################################
# Echo a formatted debug message to the terminal and optionally exit # Echo a formatted debug message to the terminal and optionally exit
@ -208,6 +224,39 @@ debug_print() {
esac esac
} }
# Try to execute a supplied command as root
# Expects one string argument
try_exec() {
# This function expects one string arguments
if [ "$#" -lt 1 ]; then
printf "\nScript error: The try_exec() function expects an argument. Aborting.\n"
read -n 1 -s -p "Press any key..."
exit 0
fi
retval=0
# Use pollkit's pkexec for gui authentication with a fallback to sudo
if [ -x "$(command -v pkexec)" ]; then
pkexec sh -c "$1"
# Check the return value
if [ "$?" -eq 126 ] || [ "$?" -eq 127 ]; then
# User cancel or error
retval=1
fi
else
sudo sh -c "$1"
# Check the return value
if [ "$?" -eq 1 ]; then
# Error
retval=1
fi
fi
return "$retval"
}
# Display a message to the user. # Display a message to the user.
# Expects the first argument to indicate the message type, followed by # Expects the first argument to indicate the message type, followed by
# a string of arguments that will be passed to zenity or echoed to the user. # a string of arguments that will be passed to zenity or echoed to the user.
@ -226,17 +275,30 @@ message() {
"info") "info")
# info message # info message
# call format: message info "text to display" # call format: message info "text to display"
margs=("--info" "--window-icon=$lug_logo" "--no-wrap" "--text=") margs=("--info" "--window-icon=\"$lug_logo\"" "--no-wrap" "--text=")
shift 1 # drop the message type argument and shift up to the text
;; ;;
"warning") "warning")
# warning message # warning message
# call format: message warning "text to display" # call format: message warning "text to display"
margs=("--warning" "--window-icon=$lug_logo" "--text=") margs=("--warning" "--window-icon=\"$lug_logo\"" "--text=")
shift 1 # drop the message type argument and shift up to the text
;; ;;
"question") "question")
# question # question
# call format: if message question "question to ask?"; then... # call format: if message question "question to ask?"; then...
margs=("--question" "--window-icon=$lug_logo" "--text=") margs=("--question" "--window-icon=\"$lug_logo\"" "--text=")
shift 1 # drop the message type argument and shift up to the text
;;
"options")
# formats the buttons with two custom options
# call format: if message options left_button_name right_button_name "which one do you want?"; then...
# The right button returns 0 (ok), the left button returns 1 (cancel)
if [ "$#" -lt 4 ]; then
debug_print exit "Script error: The options type in the message function expects four arguments. Aborting."
fi
margs=("--question" "--cancel-label=$2" "--ok-label=$3" "--window-icon=\"$lug_logo\"" "--text=")
shift 3 # drop the type and button label arguments and shift up to the text
;; ;;
*) *)
debug_print exit "Script Error: Invalid message type passed to the message function. Aborting." debug_print exit "Script Error: Invalid message type passed to the message function. Aborting."
@ -244,7 +306,6 @@ message() {
esac esac
# Display the message # Display the message
shift 1 # drop the first argument and shift the remaining up one
zenity "${margs[@]}""$@" --width="400" --title="Star Citizen LUG Helper" 2>/dev/null zenity "${margs[@]}""$@" --width="400" --title="Star Citizen LUG Helper" 2>/dev/null
else else
# Fall back to text-based messages when zenity is not available # Fall back to text-based messages when zenity is not available
@ -262,7 +323,6 @@ message() {
clear clear
printf "\n$2\n\n" printf "\n$2\n\n"
read -n 1 -s -p "Press any key..." read -n 1 -s -p "Press any key..."
return 0
;; ;;
"question") "question")
# question # question
@ -527,7 +587,7 @@ getdirs() {
# The location within the USER directory to which the game exports keybinds # The location within the USER directory to which the game exports keybinds
keybinds_dir="$user_dir/Controls/Mappings" keybinds_dir="$user_dir/Controls/Mappings"
# Shaders directory # Shaders directory
shaders_dir="$wine_prefix/$appdata_path/shaders" shaders_dir="$wine_prefix/$appdata_path"
# dxvk cache file # dxvk cache file
dxvk_cache="$game_path/$live_or_ptu/StarCitizen.dxvk-cache" dxvk_cache="$game_path/$live_or_ptu/StarCitizen.dxvk-cache"
# Where to store backed up keybinds # Where to store backed up keybinds
@ -536,6 +596,8 @@ getdirs() {
# Display all directories currently used by this helper and Star Citizen # Display all directories currently used by this helper and Star Citizen
display_dirs() { display_dirs() {
unset dirs_list
# Helper configs and keybinds # Helper configs and keybinds
if [ -d "$conf_dir/$conf_subdir" ]; then if [ -d "$conf_dir/$conf_subdir" ]; then
dirs_list+=("\n\nHelper configuration:\n$conf_dir/$conf_subdir\n\nKeybind backups:\n$conf_dir/$conf_subdir/keybinds") dirs_list+=("\n\nHelper configuration:\n$conf_dir/$conf_subdir\n\nKeybind backups:\n$conf_dir/$conf_subdir/keybinds")
@ -551,17 +613,34 @@ display_dirs() {
dirs_list+="\n\nStar Citizen game directory:\n$(cat "$conf_dir/$conf_subdir/$game_conf")" dirs_list+="\n\nStar Citizen game directory:\n$(cat "$conf_dir/$conf_subdir/$game_conf")"
fi fi
# Star Citizen shaders path
if [ -f "$conf_dir/$conf_subdir/$wine_conf" ]; then
dirs_list+="\n\nStar Citizen shaders:\n$(cat "$conf_dir/$conf_subdir/$wine_conf")/$appdata_path"
fi
# Lutris runners # Lutris runners
if [ -d "$runners_dir" ]; then if [ -d "$runners_dir_native" ] || [ -d "$runners_dir_flatpak" ]; then
dirs_list+="\n\nLutris Runners:\n$runners_dir" dirs_list+="\n\nLutris Runners:"
if [ -d "$runners_dir_native" ]; then
dirs_list+="\n$runners_dir_native"
fi
if [ -d "$runners_dir_flatpak" ]; then
dirs_list+="\n$runners_dir_flatpak"
fi
fi fi
# Lutris dxvk # Lutris dxvk
if [ -d "$runners_dir" ]; then if [ -d "$dxvk_dir_native" ] || [ -d "$dxvk_dir_flatpak" ]; then
dirs_list+="\n\nLutris DXVK Versions:\n$dxvk_dir" dirs_list+="\n\nLutris DXVK Versions:"
if [ -d "$dxvk_dir_native" ]; then
dirs_list+="\n$dxvk_dir_native"
fi
if [ -d "$dxvk_dir_flatpak" ]; then
dirs_list+="\n$dxvk_dir_flatpak"
fi
fi fi
# Formatting # Format the info header
message_heading="These directories are currently being used by this Helper and Star Citizen" message_heading="These directories are currently being used by this Helper and Star Citizen"
if [ "$use_zenity" -eq 1 ]; then if [ "$use_zenity" -eq 1 ]; then
message_heading="<b>$message_heading</b>" message_heading="<b>$message_heading</b>"
@ -571,7 +650,7 @@ display_dirs() {
} }
# Save exported keybinds, wipe the USER directory, and restore keybinds # Save exported keybinds, wipe the USER directory, and restore keybinds
sanitize() { rm_userdir() {
# Prompt user to back up the current keybinds in the game # Prompt user to back up the current keybinds in the game
message info "Before proceeding, please be sure you have exported\nyour Star Citizen keybinds from within the game.\n\nTo do this, launch the game and go to:\nOptions->Keybindings->Control Profiles->Save Control Settings\n\nGo on; I'll wait." message info "Before proceeding, please be sure you have exported\nyour Star Citizen keybinds from within the game.\n\nTo do this, launch the game and go to:\nOptions->Keybindings->Control Profiles->Save Control Settings\n\nGo on; I'll wait."
@ -623,8 +702,12 @@ sanitize() {
fi fi
} }
#--------------------- begin preflight check functions -----------------------#
#------------------------- begin mapcount functions --------------------------# ############################################################################
######## begin preflight check functions ###################################
############################################################################
######## begin mapcount functions ##########################################
############################################################################
# Check if setting vm.max_map_count was successful # Check if setting vm.max_map_count was successful
mapcount_confirm() { mapcount_confirm() {
@ -645,11 +728,11 @@ mapcount_set() {
if [ -d "/etc/sysctl.d" ]; then if [ -d "/etc/sysctl.d" ]; then
# Newer versions of sysctl # Newer versions of sysctl
preflight_actions+=('printf "\n# Added by LUG-Helper:\nvm.max_map_count = 16777216\n" > /etc/sysctl.d/20-starcitizen-max_map_count.conf && sysctl --system') preflight_actions+=('printf "\n# Added by LUG-Helper:\nvm.max_map_count = 16777216\n" > /etc/sysctl.d/20-starcitizen-max_map_count.conf && sysctl --system')
preflight_results+=("The vm.max_map_count configuration has been appended to:\n/etc/sysctl.d/20-starcitizen-max_map_count.conf") preflight_results+=("The vm.max_map_count configuration has been added to:\n/etc/sysctl.d/20-starcitizen-max_map_count.conf")
else else
# Older versions of sysctl # Older versions of sysctl
preflight_actions+=('printf "\n# Added by LUG-Helper:\nvm.max_map_count = 16777216" >> /etc/sysctl.conf && sysctl -p') preflight_actions+=('printf "\n# Added by LUG-Helper:\nvm.max_map_count = 16777216" >> /etc/sysctl.conf && sysctl -p')
preflight_results+=("The vm.max_map_count configuration has been appended to:\n/etc/sysctl.conf") preflight_results+=("The vm.max_map_count configuration has been added to:\n/etc/sysctl.conf")
fi fi
# Verify that the setting took effect # Verify that the setting took effect
@ -688,9 +771,13 @@ mapcount_check() {
fi fi
} }
#-------------------------- end mapcount functions ---------------------------# ############################################################################
######## end mapcount functions ############################################
############################################################################
#------------------------ begin filelimit functions --------------------------# ############################################################################
######## begin filelimit functions #########################################
############################################################################
# Check if setting the open file descriptors limit was successful # Check if setting the open file descriptors limit was successful
filelimit_confirm() { filelimit_confirm() {
@ -748,7 +835,9 @@ filelimit_check() {
fi fi
} }
#------------------------- end filelimit functions ---------------------------# ############################################################################
######## end filelimit functions ###########################################
############################################################################
# Check if WINE is installed # Check if WINE is installed
wine_check() { wine_check() {
@ -863,11 +952,11 @@ preflight_check() {
# Execute the actions set by the functions # Execute the actions set by the functions
if [ ! -z "$preflight_actions_string" ]; then if [ ! -z "$preflight_actions_string" ]; then
# Use pollkit's pkexec for gui with a fallback to sudo # Try to execute the actions as root
if [ -x "$(command -v pkexec)" ]; then try_exec "$preflight_actions_string"
pkexec sh -c "$preflight_actions_string" if [ "$?" -eq 1 ]; then
else message info "Authentication failed or there was an error.\nSee terminal for more information.\n\nReturning to main menu."
sudo sh -c "$preflight_actions_string" return 0
fi fi
fi fi
@ -897,21 +986,102 @@ preflight_check() {
fi fi
} }
#------------------------- end preflight check functions ---------------------# ############################################################################
######## end preflight check functions #####################################
############################################################################
#------------------------- begin download functions ----------------------------# ############################################################################
######## begin download functions ##########################################
############################################################################
# Detect if lutris is installed
lutris_detect() {
lutris_installed="false"
lutris_native="false"
lutris_flatpak="false"
# Detect native lutris
if [ -x "$(command -v lutris)" ]; then
# Native Lutris is installed
lutris_installed="true"
lutris_native="true"
fi
# Detect flatpak lutris
if [ -x "$(command -v flatpak)" ]; then
flatpak info net.lutris.Lutris >/dev/null 2>&1
if [ "$?" -eq 0 ]; then
lutris_installed="true"
lutris_flatpak="true"
fi
fi
}
# Restart lutris if necessary # Restart lutris if necessary
lutris_restart() { lutris_restart() {
if [ "$lutris_needs_restart" = "true" ] && [ "$(pgrep lutris)" ]; then 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 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 running and restart it
pkill -SIGTERM lutris && nohup lutris </dev/null &>/dev/null & 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 &
fi
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 fi
lutris_needs_restart="false" lutris_needs_restart="false"
} }
# Get an array of directories used by Lutris
# Supports native install and flatpak
# 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
debug_print exit "Script error: The get_lutris_dirs function expects one argument. Aborting."
fi
# Detect the type of Lutris install
lutris_detect
# Add lutris directories to an array
unset lutris_dirs
case "$1" in
"runner")
# Native Lutris install
if [ "$lutris_native" = "true" ]; then
lutris_dirs+=("native" "$runners_dir_native")
fi
# Flatpak lutris install
if [ "$lutris_flatpak" = "true" ]; then
lutris_dirs+=("flatpak" "$runners_dir_flatpak")
fi
;;
"dxvk")
# Native Lutris install
if [ "$lutris_native" = "true" ]; then
lutris_dirs+=("native" "$dxvk_dir_native")
fi
# Flatpak lutris install
if [ "$lutris_flatpak" = "true" ]; then
lutris_dirs+=("flatpak" "$dxvk_dir_flatpak")
fi
;;
*)
printf "lug-helper.sh: Unknown argument provided to get_lutris_dirs function. Aborting.\n" 1>&2
read -n 1 -s -p "Press any key..."
exit 0
;;
esac
}
# Perform post-download actions, display messages or instructions # Perform post-download actions, display messages or instructions
# Expects the variables message_heading, post_download_msg_text, # Expects the variables message_heading, post_download_msg_text,
# post_download_msg_italics, and downloaded_item_name # post_download_msg_italics, and downloaded_item_name
@ -950,10 +1120,10 @@ post_download() {
display_post_download_msg="false" display_post_download_msg="false"
} }
# Uninstall the selected item # Uninstall the selected item. Called by download_select_install()
# 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 # This function expects an index number for the array installed_items to be passed in as an argument
# installed_items to be passed in as an argument
if [ -z "$1" ]; then if [ -z "$1" ]; then
debug_print exit "Script error: The download_delete function expects an argument. Aborting." debug_print exit "Script error: The download_delete function expects an argument. Aborting."
fi fi
@ -966,7 +1136,7 @@ download_delete() {
fi fi
} }
# List installed items for deletion # List installed items for deletion. Called by download_manage()
download_select_delete() { download_select_delete() {
# Configure the menu # Configure the menu
menu_text_zenity="Select the $download_type you want to remove:" menu_text_zenity="Select the $download_type you want to remove:"
@ -974,19 +1144,31 @@ download_select_delete() {
menu_text_height="65" menu_text_height="65"
goback="Return to the $download_type management menu" goback="Return to the $download_type management menu"
unset installed_items unset installed_items
unset installed_item_names
unset menu_options unset menu_options
unset menu_actions unset menu_actions
# Create an array containing all directories in the download_dir # Find all installed items in the download destinations
for items_list in "$download_dir"/*; do for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do
if [ -d "$items_list" ]; then # Loop through all download destinations
installed_items+=("$items_list") # Odd numbered elements will contain the download destination's path
for item in "${download_dirs[i]}"/*; do
if [ -d "$item" ]; then
if [ "${#download_dirs[@]}" -eq 2 ]; then
# We're deleting from one location
installed_item_names+=("$(basename "$item")")
else
# We're deleting from multiple locations so label each one
installed_item_names+=("$(basename "$item [${download_dirs[i-1]}]")")
fi fi
installed_items+=("$item")
fi
done
done done
# Create menu options for the installed items # Create menu options for the installed items
for (( i=0; i<"${#installed_items[@]}"; i++ )); do for (( i=0; i<"${#installed_items[@]}"; i++ )); do
menu_options+=("$(basename "${installed_items[i]}")") menu_options+=("${installed_item_names[i]}")
menu_actions+=("download_delete $i") menu_actions+=("download_delete $i")
done done
@ -1007,9 +1189,8 @@ download_select_delete() {
menu menu
} }
# Download and install the selected item # Download and install the selected item. Called by download_select_install()
# Note: The variables download_versions, contributor_url, and download_url_type # Note: The variables download_versions, contributor_url, and download_url_type are expected to be set before calling this function
# are expected to be set before calling this function
download_install() { download_install() {
# This function expects an index number for the array # This function expects an index number for the array
# download_versions to be passed in as an argument # download_versions to be passed in as an argument
@ -1037,7 +1218,7 @@ download_install() {
download_name="$(basename "$download_file" .tar.zst)" download_name="$(basename "$download_file" .tar.zst)"
;; ;;
*) *)
debug_print exit "Unknown archive filetype in download_install function. Aborting." debug_print exit "Script error: Unknown archive filetype in download_install function. Aborting."
;; ;;
esac esac
@ -1118,14 +1299,25 @@ download_install() {
# If the archive contains only one directory, install that directory # If the archive contains only one directory, install that directory
# We rename it to the name of the archive in case it is different # We rename it to the name of the archive in case it is different
# so we can easily detect installed items in download_select_install() # so we can easily detect installed items in download_select_install()
debug_print continue "Installing $download_type into $download_dir/$download_name..." for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do
# Loop through all download destinations, installing to each one
# Odd numbered elements will contain the download destination's path
if [ -d "${download_dirs[i]}/$download_name" ]; then
# This item has already been installed. Delete it before reinstalling
debug_print continue "$download_type exists, deleting ${download_dirs[i]}/$download_name..."
rm -r "${download_dirs[i]}/$download_name"
debug_print continue "Reinstalling $download_type into ${download_dirs[i]}/$download_name..."
else
debug_print continue "Installing $download_type into ${download_dirs[i]}/$download_name..."
fi
if [ "$use_zenity" -eq 1 ]; then if [ "$use_zenity" -eq 1 ]; then
# Use Zenity progress bar # Use Zenity progress bar
mkdir -p "$download_dir" && cp -r "$tmp_dir/$download_name/$extracted_dir" "$download_dir/$download_name" | \ mkdir -p "${download_dirs[i]}" && cp -r "$tmp_dir/$download_name/$extracted_dir" "${download_dirs[i]}/$download_name" | \
zenity --progress --pulsate --no-cancel --auto-close --title="Star Citizen LUG Helper" --text="Installing ${download_type}...\n" 2>/dev/null zenity --progress --pulsate --no-cancel --auto-close --title="Star Citizen LUG Helper" --text="Installing ${download_type}...\n" 2>/dev/null
else else
mkdir -p "$download_dir" && cp -r "$tmp_dir/$download_name/$extracted_dir" "$download_dir/$download_name" mkdir -p "${download_dirs[i]}" && cp -r "$tmp_dir/$download_name/$extracted_dir" "${download_dirs[i]}/$download_name"
fi fi
done
# We need to restart Lutris for the download to be detected # We need to restart Lutris for the download to be detected
lutris_needs_restart="true" lutris_needs_restart="true"
@ -1136,14 +1328,25 @@ download_install() {
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
debug_print continue "Installing $download_type into $download_dir/$download_name..." for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do
# Loop through all download destinations, installing to each one
# Odd numbered elements will contain the download destination's path
if [ -d "${download_dirs[i]}/$download_name" ]; then
# This item has already been installed. Delete it before reinstalling
debug_print continue "$download_type exists, deleting ${download_dirs[i]}/$download_name..."
rm -r "${download_dirs[i]}/$download_name"
debug_print continue "Reinstalling $download_type into ${download_dirs[i]}/$download_name..."
else
debug_print continue "Installing $download_type into ${download_dirs[i]}/$download_name..."
fi
if [ "$use_zenity" -eq 1 ]; then if [ "$use_zenity" -eq 1 ]; then
# Use Zenity progress bar # Use Zenity progress bar
mkdir -p "$download_dir/$download_name" && cp -r "$tmp_dir"/"$download_name"/* "$download_dir"/"$download_name" | \ mkdir -p "${download_dirs[i]}/$download_name" && cp -r "$tmp_dir"/"$download_name"/* "${download_dirs[i]}"/"$download_name" | \
zenity --progress --pulsate --no-cancel --auto-close --title="Star Citizen LUG Helper" --text="Installing ${download_type}...\n" 2>/dev/null zenity --progress --pulsate --no-cancel --auto-close --title="Star Citizen LUG Helper" --text="Installing ${download_type}...\n" 2>/dev/null
else else
mkdir -p "$download_dir/$download_name" && cp -r "$tmp_dir"/"$download_name"/* "$download_dir"/"$download_name" mkdir -p "${download_dirs[i]}/$download_name" && cp -r "$tmp_dir"/"$download_name"/* "${download_dirs[i]}"/"$download_name"
fi fi
done
# We need to restart Lutris for the download to be detected # We need to restart Lutris for the download to be detected
lutris_needs_restart="true" lutris_needs_restart="true"
@ -1154,15 +1357,15 @@ download_install() {
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"
exit 0
fi fi
# Cleanup tmp download # Cleanup tmp download
debug_print continue "Cleaning up $tmp_dir/$download_file..." debug_print continue "Cleaning up $tmp_dir/$download_file..."
rm "$tmp_dir/$download_file" rm "$tmp_dir/$download_file"
rm -r "$tmp_dir/$download_name"
} }
# List available items for download # List available items for download. Called by download_manage()
download_select_install() { download_select_install() {
# This function expects an element number for the sources array # This function expects an element number for the sources array
# to be passed in as an argument # to be passed in as an argument
@ -1187,7 +1390,7 @@ download_select_install() {
esac esac
# For runners, check GlibC version against runner requirements # For runners, check GlibC version against runner requirements
if [ "$download_type" = "runner" ] && [ "$contributor_name" = "/dev/null" ]; then if [ "$download_type" = "runner" ] && ( [ "$contributor_name" = "/dev/null" ] || [ "$contributor_name" = "TKG" ] ); then
required_glibc="2.33" required_glibc="2.33"
system_glibc="$(ldd --version | awk '/ldd/{print $NF}')" system_glibc="$(ldd --version | awk '/ldd/{print $NF}')"
@ -1203,7 +1406,7 @@ download_select_install() {
# To add new sources, handle them here, in the if statement # To add new sources, handle them here, in the if statement
# just above, and the download_install function above # just above, and the download_install function above
if [ "$download_url_type" = "github" ]; then if [ "$download_url_type" = "github" ]; then
download_versions=($(curl -s "$contributor_url" | awk '/browser_download_url/ {print $2}' | grep -vE "*.sha512sum" | xargs basename -a)) download_versions=($(curl -s "$contributor_url" | awk '/browser_download_url/ {print $2}' | xargs basename -a))
else else
debug_print exit "Script error: Unknown api/url format in ${download_type}_sources array. Aborting." debug_print exit "Script error: Unknown api/url format in ${download_type}_sources array. Aborting."
fi fi
@ -1226,9 +1429,13 @@ download_select_install() {
# and add them to the menu options # and add them to the menu options
# To add new file extensions, handle them here and in # To add new file extensions, handle them here and in
# the download_install function above # the download_install function above
for (( i=0; i<"$max_download_items" && i<"${#download_versions[@]}"; i++ )); do for (( i=0,num_download_items=0; i<"${#download_versions[@]}" && "$num_download_items"<"$max_download_items"; i++ )); do
# Get the file name minus the extension # Get the file name minus the extension
case "${download_versions[i]}" in case "${download_versions[i]}" in
*.sha*sum | *.ini | proton*)
# Ignore hashes, configs, and proton downloads
continue
;;
*.tar.gz) *.tar.gz)
download_name="$(basename "${download_versions[i]}" .tar.gz)" download_name="$(basename "${download_versions[i]}" .tar.gz)"
;; ;;
@ -1242,17 +1449,54 @@ download_select_install() {
download_name="$(basename "${download_versions[i]}" .tar.zst)" download_name="$(basename "${download_versions[i]}" .tar.zst)"
;; ;;
*) *)
debug_print exit "Unknown archive filetype in download_select_install function. Aborting." # Print a warning and move on to the next item
debug_print continue "Warning: Unknown archive filetype in download_select_install() function. Offending String: ${download_versions[i]}"
continue
;; ;;
esac esac
# Add the file names to the menu # Create a list of locations where the file is already installed
if [ -d "$download_dir/$download_name" ]; then unset installed_types
menu_options+=("$download_name [installed]") for (( j=0; j<"${#download_dirs[@]}"; j=j+2 )); do
else # Loop through all download destinations to get installed types
menu_options+=("$download_name") # Even numbered elements will contain the download destination type (ie. native/flatpak)
if [ -d "${download_dirs[j+1]}/$download_name" ]; then
installed_types+=("${download_dirs[j]}")
fi fi
done
# Build the menu item
unset menu_option_text
if [ "${#download_dirs[@]}" -eq 2 ]; then
# We're only installing to one location
if [ -d "${download_dirs[1]}/$download_name" ]; then
menu_option_text="$download_name [installed]"
else
# The file is not installed
menu_option_text="$download_name"
fi
else
# We're installing to multiple locations
if [ "${#installed_types[@]}" -gt 0 ]; then
# The file is already installed
menu_option_text="$download_name [installed:"
for (( j=0; j<"${#installed_types[@]}"; j++ )); do
# Add labels for each installed location
menu_option_text="$menu_option_text ${installed_types[j]}"
done
# Complete the menu text
menu_option_text="$menu_option_text]"
else
# The file is not installed
menu_option_text="$download_name"
fi
fi
# Add the file names to the menu
menu_options+=("$menu_option_text")
menu_actions+=("download_install $i") menu_actions+=("download_install $i")
# Increment the added items counter
num_download_items="$(($num_download_items+1))"
done done
# Complete the menu by adding the option to go back to the previous menu # Complete the menu by adding the option to go back to the previous menu
@ -1272,7 +1516,7 @@ download_select_install() {
menu menu
} }
# Manage downloads # Manage downloads. Called by a dedicated download type manage function, ie runner_manage() below
# #
# This function expects the following variables to be set: # This function expects the following variables to be set:
# #
@ -1280,8 +1524,8 @@ download_select_install() {
# of items to download. It should be pointed to the appropriate # of items to download. It should be pointed to the appropriate
# array set at the top of the script using indirect expansion. # array set at the top of the script using indirect expansion.
# See runner_sources at the top and runner_manage() below for examples. # See runner_sources at the top and runner_manage() below for examples.
# - The string download_dir should contain the location the downloaded item # - The array download_dirs should contain the locations the downloaded item
# will be installed to. # will be installed to. Must be formatted in pairs of ("[type]" "[directory]")
# - The string "download_menu_heading" should contain the type of item # - The string "download_menu_heading" should contain the type of item
# being downloaded. It will appear in the menu heading. # being downloaded. It will appear in the menu heading.
# - The string "download_menu_description" should contain a description of # - The string "download_menu_description" should contain a description of
@ -1291,21 +1535,12 @@ download_select_install() {
# This function also expects one string argument containing the type of item to # This function also expects one string argument containing the type of item to
# be downloaded. ie. runner or dxvk. # be downloaded. ie. runner or dxvk.
# #
# See runner_manage below for a configuration example. # See runner_manage() below for a configuration example.
download_manage() { download_manage() {
# This function expects a string to be passed as an argument # This function expects a string to be passed as an argument
if [ -z "$1" ]; then if [ -z "$1" ]; then
debug_print exit "Script error: The download_manage function expects a string argument. Aborting." debug_print exit "Script error: The download_manage function expects a string argument. Aborting."
fi fi
# Check if Lutris is installed
if [ ! -x "$(command -v lutris)" ]; then
message info "Lutris does not appear to be installed."
return 0
fi
if [ ! -d "$download_dir" ]; then
message info "Lutris $download_type directory not found. Unable to continue.\n\n$download_dir"
return 0
fi
# Get the type of item we're downloading from the function arguments # Get the type of item we're downloading from the function arguments
download_type="$1" download_type="$1"
@ -1325,7 +1560,7 @@ download_manage() {
unset menu_actions unset menu_actions
# 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 runner 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
# Set the options to be displayed in the menu # Set the options to be displayed in the menu
menu_options+=("Install a $download_type from ${download_sources[i]}") menu_options+=("Install a $download_type from ${download_sources[i]}")
@ -1360,7 +1595,28 @@ runner_manage() {
# 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
declare -n download_sources=runner_sources declare -n download_sources=runner_sources
download_dir="$runners_dir"
# Check if Lutris is installed and get relevant directories
get_lutris_dirs "runner"
if [ "$lutris_installed" = "false" ]; then
message warning "Lutris is required but does not appear to be installed."
return 0
fi
# Point download_dirs to the lutris_dirs array set by get_lutris_dirs
# Must be formatted in pairs of ("[type]" "[directory]")
declare -n download_dirs=lutris_dirs
# Verify the directories actually exist
missing_dir="false"
for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do
if [ ! -d "${download_dirs[i]}" ]; then
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
if [ "$missing_dir" = "true" ]; then
return 0
fi
# Configure the text displayed in the menus # Configure the text displayed in the menus
download_menu_heading="Lutris Runners" download_menu_heading="Lutris Runners"
@ -1395,7 +1651,28 @@ dxvk_manage() {
# 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
declare -n download_sources=dxvk_sources declare -n download_sources=dxvk_sources
download_dir="$dxvk_dir"
# Check if Lutris is installed and get relevant directories
get_lutris_dirs "dxvk"
if [ "$lutris_installed" = "false" ]; then
message warning "Lutris is required but does not appear to be installed."
return 0
fi
# Point download_dirs to the lutris_dirs array set by get_lutris_dirs
# Must be formatted in pairs of ("[type]" "[directory]")
declare -n download_dirs=lutris_dirs
# Verify the directories actually exist
missing_dir="false"
for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do
if [ ! -d "${download_dirs[i]}" ]; then
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
if [ "$missing_dir" = "true" ]; then
return 0
fi
# 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"
@ -1421,7 +1698,9 @@ dxvk_manage() {
download_manage "dxvk" download_manage "dxvk"
} }
#-------------------------- end download functions -----------------------------# ############################################################################
######## end download functions ############################################
############################################################################
# Deploy Easy Anti-Cheat Workaround # Deploy Easy Anti-Cheat Workaround
eac_workaround() { eac_workaround() {
@ -1438,9 +1717,13 @@ eac_workaround() {
eac_hosts="127.0.0.1 modules-cdn.eac-prod.on.epicgames.com" eac_hosts="127.0.0.1 modules-cdn.eac-prod.on.epicgames.com"
# Check if EAC workaround is already applied # Check if EAC workaround is already applied
if grep "$eac_hosts" /etc/hosts; then if grep -q "$eac_hosts" /etc/hosts; then
if grep -q "^$eac_hosts" /etc/hosts; then
message info "The Easy Anti-Cheat workaround has already been applied.\nYou're all set!" message info "The Easy Anti-Cheat workaround has already been applied.\nYou're all set!"
return 1 else
message info "The Easy Anti-Cheat workaround has already been applied, but may be commented out.\nNo changes have been made, please edit /etc/hosts manually."
fi
return 0
fi fi
# Configure message variables # Configure message variables
@ -1456,11 +1739,11 @@ eac_workaround() {
if message question "$eac_title\n\nThe following entry will be added to /etc/hosts:\n$eac_hosts_formatted\n\nThe following directory will be deleted:\n$eac_dir_formatted\n\n\nTo revert these changes, delete the above line from\n/etc/hosts and relaunch the game\n\nDo you want to proceed?"; then if message question "$eac_title\n\nThe following entry will be added to /etc/hosts:\n$eac_hosts_formatted\n\nThe following directory will be deleted:\n$eac_dir_formatted\n\n\nTo revert these changes, delete the above line from\n/etc/hosts and relaunch the game\n\nDo you want to proceed?"; then
debug_print continue "Editing hosts file..." debug_print continue "Editing hosts file..."
# Use pollkit's pkexec for gui with a fallback to sudo # Try to modify /etc/hosts as root
if [ -x "$(command -v pkexec)" ]; then try_exec "printf '\n$eac_hosts #Star Citizen EAC workaround\n' >> /etc/hosts"
pkexec sh -c "echo $eac_hosts '#Star Citizen EAC workaround' >> /etc/hosts" if [ "$?" -eq 1 ]; then
else message info "Something went wrong. Unable to modify /etc/hosts.\n\nReturning to main menu."
sudo sh -c "echo $eac_hosts '#Star Citizen EAC workaround' >> /etc/hosts" return 0
fi fi
# Delete the EAC directory if it exists # Delete the EAC directory if it exists
@ -1476,7 +1759,8 @@ eac_workaround() {
# Install Star Citizen using Lutris # Install Star Citizen using Lutris
install_game() { install_game() {
# Check if Lutris is installed # Check if Lutris is installed
if [ ! -x "$(command -v lutris)" ]; then lutris_detect
if [ "$lutris_installed" = "false" ]; then
message warning "Lutris is required but does not appear to be installed." message warning "Lutris is required but does not appear to be installed."
return 0 return 0
fi fi
@ -1487,7 +1771,36 @@ install_game() {
fi fi
if message question "Before proceeding, please refer to our Quick Start Guide:\n\n$lug_wiki\n\nAre you ready to continue?"; then if message question "Before proceeding, please refer to our Quick Start Guide:\n\n$lug_wiki\n\nAre you ready to continue?"; then
# 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 message options "Flatpak" "Native" "This Helper has detected both the Native and Flatpak versions of Lutris\nWhich version would you like to use?"; then
# Native version
install_version="native"
else
# Flatpak version
install_version="flatpak"
fi
elif [ "$lutris_native" = "true" ]; then
# Native version only
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" & lutris --install "$install_script" &
elif [ "$install_version" = "flatpak" ]; then
flatpak run --file-forwarding net.lutris.Lutris --install @@ "$install_script" @@ &
else
# We shouldn't get here
debug_print exit "Script error: Unknown condition for install_version in install_game() function. Aborting."
fi
message info "The installation will continue in Lutris" message info "The installation will continue in Lutris"
fi fi
} }
@ -1507,29 +1820,18 @@ rm_shaders() {
return 0 return 0
fi fi
# Create an array containing all directories in the appdata_path # Loop through all possible shader directories
for appdata_list in "$wine_prefix/$appdata_path"/*; do for appdata_dir in "$shaders_dir"/*; do
if [ -d "$appdata_list" ]; then if [ -d "$appdata_dir/$shaders_subdir" ]; then
appdata_items+=("$appdata_list") # If a shaders directory is found, delete it
if message question "The following directory will be deleted:\n\n$appdata_dir/$shaders_subdir\n\nDo you want to proceed?"; then
debug_print continue "Deleting $appdata_dir/$shaders_subdir..."
rm -r "$appdata_dir/$shaders_subdir"
fi
fi fi
done done
# Delete shaders directory in every directory beginning with "sc-alpha" message info "All shaders have been deleted"
for (( i=0; i<"${#appdata_items[@]}"; i++ )); do
if [ "${appdata_items[i]}" = "$wine_prefix/$appdata_path"/sc-alpha* ]; then # check if the item in the array begins with sc-alpha
if [ -d "${appdata_items[i]}/shaders" ]; then # check if there is a shaders subfolder
if message question "The following directory will be deleted:\n\n${appdata_items[i]}/shaders\n\nDo you want to proceed?"; then
debug_print continue "Deleting ${appdata_items[i]}/shaders..."
rm -r "${appdata_items[i]}/shaders"
message info "Your shaders have been deleted!"
fi
elif [ $i = $(( "${#appdata_items[@]}" - 1 )) ]; then # display message when end of array is reached and no shaders directories were found
message info "No more shader directories found"
fi
elif [ $i = $(( "${#appdata_items[@]}" - 1 )) ]; then # display message when end of array is reached and no shaders or sc-alpha directories were found
message info "No more shader directories found"
fi
done
} }
# Delete DXVK cache # Delete DXVK cache
@ -1568,8 +1870,8 @@ maintenance_menu() {
# Configure the menu options # Configure the menu options
version_msg="Switch the Helper between LIVE and PTU (Currently: $live_or_ptu)" version_msg="Switch the Helper between LIVE and PTU (Currently: $live_or_ptu)"
sanitize_msg="Delete my Star Citizen USER folder and preserve my keybinds" userdir_msg="Delete my Star Citizen USER folder and preserve my keybinds"
shaders_msg="Delete my shaders folder only (Do this after each game update)" shaders_msg="Delete my shaders (Do this after each game update)"
vidcache_msg="Delete my DXVK cache" vidcache_msg="Delete my DXVK cache"
dirs_msg="Display Helper and Star Citizen directories" dirs_msg="Display Helper and Star Citizen directories"
wiki_msg="Show the LUG Wiki" wiki_msg="Show the LUG Wiki"
@ -1577,9 +1879,9 @@ maintenance_menu() {
quit_msg="Return to the main menu" quit_msg="Return to the main menu"
# Set the options to be displayed in the menu # Set the options to be displayed in the menu
menu_options=("$version_msg" "$sanitize_msg" "$shaders_msg" "$vidcache_msg" "$dirs_msg" "$wiki_msg" "$reset_msg" "$quit_msg") menu_options=("$version_msg" "$userdir_msg" "$shaders_msg" "$vidcache_msg" "$dirs_msg" "$wiki_msg" "$reset_msg" "$quit_msg")
# Set the corresponding functions to be called for each of the options # Set the corresponding functions to be called for each of the options
menu_actions=("set_version" "sanitize" "rm_shaders" "rm_dxvkcache" "display_dirs" "display_wiki" "reset_helper" "menu_loop_done") menu_actions=("set_version" "rm_userdir" "rm_shaders" "rm_dxvkcache" "display_dirs" "display_wiki" "reset_helper" "menu_loop_done")
# Calculate the total height the menu should be # Calculate the total height the menu should be
menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))" menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
@ -1595,7 +1897,7 @@ maintenance_menu() {
# Get a random Penguin's Star Citizen referral code # Get a random Penguin's Star Citizen referral code
referral_randomizer() { referral_randomizer() {
# Populate the referral codes array # Populate the referral codes array
referral_codes=("STAR-4TZD-6KMM" "STAR-4XM2-VM99" "STAR-2NPY-FCR2" "STAR-T9Z9-7W6P" "STAR-VLBF-W2QR" "STAR-BYR6-YHMF" "STAR-3X2H-VZMX" "STAR-BRWN-FB9T" "STAR-FG6Y-N4Q4" "STAR-VLD6-VZRG" "STAR-T9KF-LV77" "STAR-4XHB-R7RF" "STAR-9NVF-MRN7" "STAR-3Q4W-9TC3" "STAR-3SBK-7QTT" "STAR-XFBT-9TTK" "STAR-F3H9-YPHN" "STAR-BYK6-RCCL" "STAR-XCKH-W6T7" "STAR-H292-39WK" "STAR-ZRT5-PJB7" "STAR-GMBP-SH9Y" "STAR-PLWB-LMFY" "STAR-TNZN-H4ZT" "STAR-T5G5-L2GJ" "STAR-6TPV-7QH2" "STAR-THHD-TV3Y" "STAR-7ZFS-PK2L" "STAR-SRQN-43TB" "STAR-9TDG-D4H9" "STAR-BPH3-THJC" "STAR-HL3M-R5KC" "STAR-GBS5-LTVB" "STAR-CJ3Y-KZZ4" "STAR-5GRM-7HBY" "STAR-G2GX-Y2QJ" "STAR-YWY3-H4XX" "STAR-6VGM-PTKC" "STAR-T6MZ-QFHX" "STAR-T2K6-LXFW" "STAR-XN25-9CJJ" "STAR-47V3-4QGB" "STAR-YD4Z-TQZV" "STAR-XLN7-9XNJ" "STAR-N62T-2R39" "STAR-3S3D-9HXQ" "STAR-TRZF-NMCV" "STAR-TLLJ-SMG4" "STAR-MFT6-Q44H" "STAR-TZX2-TPWF") referral_codes=("STAR-4TZD-6KMM" "STAR-4XM2-VM99" "STAR-2NPY-FCR2" "STAR-T9Z9-7W6P" "STAR-VLBF-W2QR" "STAR-BYR6-YHMF" "STAR-3X2H-VZMX" "STAR-BRWN-FB9T" "STAR-FG6Y-N4Q4" "STAR-VLD6-VZRG" "STAR-T9KF-LV77" "STAR-4XHB-R7RF" "STAR-9NVF-MRN7" "STAR-3Q4W-9TC3" "STAR-3SBK-7QTT" "STAR-XFBT-9TTK" "STAR-F3H9-YPHN" "STAR-BYK6-RCCL" "STAR-XCKH-W6T7" "STAR-H292-39WK" "STAR-ZRT5-PJB7" "STAR-GMBP-SH9Y" "STAR-PLWB-LMFY" "STAR-TNZN-H4ZT" "STAR-T5G5-L2GJ" "STAR-6TPV-7QH2" "STAR-THHD-TV3Y" "STAR-7ZFS-PK2L" "STAR-SRQN-43TB" "STAR-9TDG-D4H9" "STAR-BPH3-THJC" "STAR-HL3M-R5KC" "STAR-GBS5-LTVB" "STAR-CJ3Y-KZZ4" "STAR-5GRM-7HBY" "STAR-G2GX-Y2QJ" "STAR-YWY3-H4XX" "STAR-6VGM-PTKC" "STAR-T6MZ-QFHX" "STAR-T2K6-LXFW" "STAR-XN25-9CJJ" "STAR-47V3-4QGB" "STAR-YD4Z-TQZV" "STAR-XLN7-9XNJ" "STAR-N62T-2R39" "STAR-3S3D-9HXQ" "STAR-TRZF-NMCV" "STAR-TLLJ-SMG4" "STAR-MFT6-Q44H" "STAR-TZX2-TPWF" "STAR-WCHN-4ZMX")
# Pick a random array element. Scale a floating point number for # Pick a random array element. Scale a floating point number for
# a more random distribution than simply calling RANDOM # a more random distribution than simply calling RANDOM
random_code="${referral_codes[$(awk '{srand($2); print int(rand()*$1)}' <<< "${#referral_codes[@]} $RANDOM")]}" random_code="${referral_codes[$(awk '{srand($2); print int(rand()*$1)}' <<< "${#referral_codes[@]} $RANDOM")]}"
@ -1646,7 +1948,7 @@ quit() {
############################################################################ ############################################################################
# MAIN ######## MAIN ##############################################################
############################################################################ ############################################################################
# Check if Zenity is available # Check if Zenity is available
@ -1658,6 +1960,22 @@ fi
# Set defaults # Set defaults
live_or_ptu="$live_dir" live_or_ptu="$live_dir"
# Format some URLs for Zenity
if [ "$use_zenity" -eq 1 ]; then
releases_url="<a href='$releases_url'>$releases_url</a>"
lug_wiki="<a href='$lug_wiki'>$lug_wiki</a>"
fi
# Check if a newer verison of the script is available
latest_version="$(get_latest_release "$repo")"
# Sort the versions and check if the installed Helper is smaller
if [ "$latest_version" != "$current_version" ] &&
[ "$current_version" = "$(printf "$current_version\n$latest_version" | sort -V | head -n1)" ]; then
message info "The latest version of the LUG Helper is $latest_version\nYou are using $current_version\n\nYou can download new releases here:\n$releases_url"
fi
# If invoked with command line arguments, process them and exit # If invoked with command line arguments, process them and exit
if [ "$#" -gt 0 ]; then if [ "$#" -gt 0 ]; then
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
@ -1669,15 +1987,17 @@ if [ "$#" -gt 0 ]; then
Usage: lug-helper <options> Usage: lug-helper <options>
-p, --preflight-check Run system optimization checks -p, --preflight-check Run system optimization checks
-i, --install Install Star Citizen -i, --install Install Star Citizen
-e, --eac Deploy Easy Anti-Cheat Workaround
-m, --manage-runners Install or remove Lutris runners -m, --manage-runners Install or remove Lutris runners
-k, --manage-dxvk Install or remove DXVK versions -k, --manage-dxvk Install or remove DXVK versions
-u, --delete-user-folder Delete Star Citizen USER folder, preserving keybinds -u, --delete-user-folder Delete Star Citizen USER folder, preserving keybinds
-s, --delete-shaders Delete Star Citizen shaders directory -s, --delete-shaders Delete Star Citizen shaders
-c, --delete-dxvk-cache Delete Star Citizen dxvk cache file -c, --delete-dxvk-cache Delete Star Citizen dxvk cache file
-t, --target=[live|ptu] Target LIVE or PTU (default live) -t, --target=[live|ptu] Target LIVE or PTU (default live)
-g, --use-gui=[yes|no] Use Zenity GUI if available (default yes) -g, --use-gui=[yes|no] Use Zenity GUI if available (default yes)
-r, --get-referral Get a random LUG member's Star Citizen referral code -r, --get-referral Get a random LUG member's Star Citizen referral code
-d, --show-directories Show all Star Citizen and LUG Helper directories -d, --show-directories Show all Star Citizen and LUG Helper directories
-w, --show-wiki Show the LUG Wiki
-x, --reset-helper Delete saved lug-helper configs -x, --reset-helper Delete saved lug-helper configs
" "
exit 0 exit 0
@ -1688,6 +2008,9 @@ Usage: lug-helper <options>
--install | -i ) --install | -i )
cargs+=("install_game") cargs+=("install_game")
;; ;;
--eac | -e )
cargs+=("eac_workaround")
;;
--manage-runners | -m ) --manage-runners | -m )
cargs+=("runner_manage") cargs+=("runner_manage")
;; ;;
@ -1695,7 +2018,7 @@ Usage: lug-helper <options>
cargs+=("dxvk_manage") cargs+=("dxvk_manage")
;; ;;
--delete-user-folder | -u ) --delete-user-folder | -u )
cargs+=("sanitize") cargs+=("rm_userdir")
;; ;;
--delete-shaders | -s ) --delete-shaders | -s )
cargs+=("rm_shaders") cargs+=("rm_shaders")
@ -1735,6 +2058,9 @@ Usage: lug-helper <options>
--show-directories | -d ) --show-directories | -d )
cargs+=("display_dirs") cargs+=("display_dirs")
;; ;;
--show-wiki | -w )
cargs+=("display_wiki")
;;
--reset-helper | -x ) --reset-helper | -x )
cargs+=("reset_helper") cargs+=("reset_helper")
;; ;;
@ -1749,29 +2075,13 @@ Usage: lug-helper <options>
# Call the requested functions and exit # Call the requested functions and exit
if [ "${#cargs[@]}" -gt 0 ]; then if [ "${#cargs[@]}" -gt 0 ]; then
for (( i=0; i<"${#cargs[@]}"; i++ )); do for (( x=0; x<"${#cargs[@]}"; x++ )); do
${cargs[i]} ${cargs[x]}
done done
exit 0 exit 0
fi fi
fi fi
# Format some URLs for Zenity
if [ "$use_zenity" -eq 1 ]; then
releases_url="<a href='$releases_url'>$releases_url</a>"
lug_wiki="<a href='$lug_wiki'>$lug_wiki</a>"
fi
# Check if a newer verison of the script is available
latest_version="$(get_latest_release "$repo")"
# Sort the versions and check if the installed Helper is smaller
if [ "$latest_version" != "$current_version" ] &&
[ "$current_version" = "$(printf "$current_version\n$latest_version" | sort -V | head -n1)" ]; then
message info "The latest version of the LUG Helper is $latest_version\nYou are using $current_version\n\nYou can download new releases here:\n$releases_url"
fi
# Loop the main menu until the user selects quit # Loop the main menu until the user selects quit
while true; do while true; do
# Configure the menu # Configure the menu