mirror of
https://github.com/the-sane/lug-helper.git
synced 2025-07-01 16:40:35 +00:00
Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
85c1f62c22 | |||
758f106efd | |||
43d2b467e8 | |||
aa60600807 | |||
02338ff299 | |||
a2594c3af3 | |||
e63893f50a | |||
fa14c6d9de | |||
8f3efd0b9c | |||
6d7c84c8b6 | |||
c12509bc0c | |||
224c531d64 | |||
32fdc04ec7 | |||
20eb8e984a | |||
0df2659e54 | |||
4a0b053a68 | |||
26030a6c82 | |||
9c44505d27 | |||
7f0f12e61b | |||
da8c63fdcf | |||
6e27ae8449 | |||
be533e842b | |||
dfc2b4f573 |
17
README.md
17
README.md
@ -13,6 +13,16 @@ Zenity menus are used for a GUI experience with a fallback to terminal-based men
|
|||||||
|
|
||||||
## Options:
|
## Options:
|
||||||
|
|
||||||
|
`Manage Lutris Runners`
|
||||||
|
- Quickly install and delete Lutris wine runners
|
||||||
|
|
||||||
|
`Delete my Star Citizen USER folder and preserve my keybinds`
|
||||||
|
- The helper will make backups of any exported keybinds, delete your Star Citizen USER folder, then restore your keybind files.
|
||||||
|
- To export your keybinds from within the game, go to:
|
||||||
|
- *Options->Keybindings->Control Profiles->Save Control Settings*
|
||||||
|
- To re-import your keybinds from within the game, select them from the list:
|
||||||
|
- *Options->Keybindings->Control Profiles*
|
||||||
|
|
||||||
`Check vm.max_map_count for optimal performance`
|
`Check vm.max_map_count for optimal performance`
|
||||||
- We recommend setting this to at least 16777216 to give the game access to sufficient memory.
|
- We recommend setting this to at least 16777216 to give the game access to sufficient memory.
|
||||||
- The helper will offer to set it for you or show you the commands to do it yourself.
|
- The helper will offer to set it for you or show you the commands to do it yourself.
|
||||||
@ -22,13 +32,6 @@ Zenity menus are used for a GUI experience with a fallback to terminal-based men
|
|||||||
- The helper will offer to set it for you and try to auto-detect the correct method to do so.
|
- The helper will offer to set it for you and try to auto-detect the correct method to do so.
|
||||||
- It is able to update either */etc/systemd/system.conf* or */etc/security/limits.conf*
|
- It is able to update either */etc/systemd/system.conf* or */etc/security/limits.conf*
|
||||||
|
|
||||||
`Delete my Star Citizen USER folder and preserve my keybinds`
|
|
||||||
- The helper will make backups of any exported keybinds, delete your Star Citizen USER folder, then restore your keybind files.
|
|
||||||
- To export your keybinds from within the game, go to:
|
|
||||||
- *Options->Keybindings->Control Profiles->Save Control Settings*
|
|
||||||
- To re-import your keybinds from within the game, select them from the list:
|
|
||||||
- *Options->Keybindings->Control Profiles*
|
|
||||||
|
|
||||||
`Delete my shaders only`
|
`Delete my shaders only`
|
||||||
- Sometimes all you need to do between major version updates is delete your shaders directory.
|
- Sometimes all you need to do between major version updates is delete your shaders directory.
|
||||||
|
|
||||||
|
356
lug-helper.sh
356
lug-helper.sh
@ -25,6 +25,9 @@
|
|||||||
# To import your keybinds from within the game, select them from the list:
|
# To import your keybinds from within the game, select them from the list:
|
||||||
# Options->Keybindings->Control Profiles
|
# Options->Keybindings->Control Profiles
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# Author: https://github.com/the-sane
|
||||||
|
# Contributor: https://github.com/Termuellinator
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
wine_conf="winedir.conf"
|
wine_conf="winedir.conf"
|
||||||
@ -45,10 +48,39 @@ user_subdir_name="USER"
|
|||||||
keybinds_export_path="Controls/Mappings"
|
keybinds_export_path="Controls/Mappings"
|
||||||
|
|
||||||
dxvk_cache_file="StarCitizen.dxvk-cache"
|
dxvk_cache_file="StarCitizen.dxvk-cache"
|
||||||
|
|
||||||
|
# Lutris wine runners directory
|
||||||
|
if [ -z "$XDG_DATA_HOME" ]; then
|
||||||
|
runner_dir="$HOME/.local/share/lutris/runners/wine"
|
||||||
|
else
|
||||||
|
runner_dir="$XDG_DATA_HOME/lutris/runners/wine"
|
||||||
|
fi
|
||||||
|
# URLs for downloading Lutris runners
|
||||||
|
rawfox_url="https://api.github.com/repos/rawfoxDE/raw-wine/releases"
|
||||||
|
snatella_url="https://api.github.com/repos/snatella/wine-runner-sc/releases"
|
||||||
|
|
||||||
|
# Set a maximum number of runners
|
||||||
|
max_runners=20
|
||||||
|
|
||||||
|
# Pixels to add for each Zenity menu option
|
||||||
|
# used to dynamically determine the height of menus
|
||||||
|
menu_option_height="25"
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
# Echo a debug message to the terminal with newlines
|
||||||
|
debug_echo() {
|
||||||
|
# This function expects a string argument
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo -e "\nScript error: The debug_echo function expects an argument. Aborting."
|
||||||
|
read -n 1 -s -p "Press any key..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo -e "\n$1\n"
|
||||||
|
}
|
||||||
|
|
||||||
# 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.
|
||||||
@ -58,7 +90,7 @@ dxvk_cache_file="StarCitizen.dxvk-cache"
|
|||||||
message() {
|
message() {
|
||||||
# Sanity check
|
# Sanity check
|
||||||
if [ "$#" -lt 2 ]; then
|
if [ "$#" -lt 2 ]; then
|
||||||
echo -e "\nScript error: The message function expects two arguments. Aborting."
|
debug_echo "Script error: The message function expects two arguments. Aborting."
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -78,11 +110,11 @@ message() {
|
|||||||
;;
|
;;
|
||||||
"question")
|
"question")
|
||||||
# question
|
# question
|
||||||
# call format: message question "question to ask?"
|
# call format: if message question "question to ask?"; then...
|
||||||
margs=("--question" "--text=")
|
margs=("--question" "--text=")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "\nScript Error: Invalid message type passed to the message function. Aborting."
|
debug_echo "Script Error: Invalid message type passed to the message function. Aborting."
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
@ -90,7 +122,7 @@ message() {
|
|||||||
|
|
||||||
# Display the message
|
# Display the message
|
||||||
shift 1 # drop the first argument and shift the remaining up one
|
shift 1 # drop the first argument and shift the remaining up one
|
||||||
zenity "${margs[@]}""$@" --width="400" --title="Star Citizen LUG Helper"
|
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
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -111,7 +143,7 @@ message() {
|
|||||||
;;
|
;;
|
||||||
"question")
|
"question")
|
||||||
# question
|
# question
|
||||||
# call format: message question "question to ask?"
|
# call format: if message question "question to ask?"; then...
|
||||||
clear
|
clear
|
||||||
echo -e "$2"
|
echo -e "$2"
|
||||||
while read -p "[y/n]: " yn; do
|
while read -p "[y/n]: " yn; do
|
||||||
@ -129,7 +161,7 @@ message() {
|
|||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "\nScript Error: Invalid message type passed to the message function. Aborting."
|
debug_echo "Script Error: Invalid message type passed to the message function. Aborting."
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
@ -165,23 +197,23 @@ message() {
|
|||||||
menu() {
|
menu() {
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if [ "${#menu_options[@]}" -eq 0 ]; then
|
if [ "${#menu_options[@]}" -eq 0 ]; then
|
||||||
echo -e "\nScript error: The array 'menu_options' was not set\nbefore calling the menu function. Aborting."
|
debug_echo "Script error: The array 'menu_options' was not set\nbefore calling the menu function. Aborting."
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "${#menu_actions[@]}" -eq 0 ]; then
|
elif [ "${#menu_actions[@]}" -eq 0 ]; then
|
||||||
echo -e "\nScript error: The array 'menu_actions' was not set\nbefore calling the menu function. Aborting."
|
debug_echo "Script error: The array 'menu_actions' was not set\nbefore calling the menu function. Aborting."
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
elif [ -z "$menu_text_zenity" ]; then
|
elif [ -z "$menu_text_zenity" ]; then
|
||||||
echo -e "\nScript error: The string 'menu_text_zenity' was not set\nbefore calling the menu function. Aborting."
|
debug_echo "Script error: The string 'menu_text_zenity' was not set\nbefore calling the menu function. Aborting."
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
elif [ -z "$menu_text_terminal" ]; then
|
elif [ -z "$menu_text_terminal" ]; then
|
||||||
echo -e "\nScript error: The string 'menu_text_terminal' was not set\nbefore calling the menu function. Aborting."
|
debug_echo "Script error: The string 'menu_text_terminal' was not set\nbefore calling the menu function. Aborting."
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
elif [ -z "$menu_height" ]; then
|
elif [ -z "$menu_height" ]; then
|
||||||
echo -e "\nScript error: The string 'menu_height' was not set\nbefore calling the menu function. Aborting."
|
debug_echo "Script error: The string 'menu_height' was not set\nbefore calling the menu function. Aborting."
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -203,7 +235,7 @@ menu() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Display the zenity radio button menu
|
# Display the zenity radio button menu
|
||||||
choice="$(zenity --list --radiolist --width="400" --height="$menu_height" --text="$menu_text_zenity" --title="Star Citizen LUG Helper" --hide-header --column="" --column="Option" "${zen_options[@]}")"
|
choice="$(zenity --list --radiolist --width="400" --height="$menu_height" --text="$menu_text_zenity" --title="Star Citizen LUG Helper" --hide-header --column="" --column="Option" "${zen_options[@]}" 2>/dev/null)"
|
||||||
|
|
||||||
# Loop through the options array to match the chosen option
|
# Loop through the options array to match the chosen option
|
||||||
matched="false"
|
matched="false"
|
||||||
@ -262,28 +294,28 @@ getdirs() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ ! -d "$conf_dir/$conf_subdir" ]; then
|
if [ ! -d "$conf_dir/$conf_subdir" ]; then
|
||||||
mkdir "$conf_dir/$conf_subdir"
|
mkdir -p "$conf_dir/$conf_subdir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the config files already exist
|
# Check if the config files already exist
|
||||||
if [ -f "$conf_dir/$conf_subdir/$wine_conf" ]; then
|
if [ -f "$conf_dir/$conf_subdir/$wine_conf" ]; then
|
||||||
wine_prefix="$(cat "$conf_dir/$conf_subdir/$wine_conf")"
|
wine_prefix="$(cat "$conf_dir/$conf_subdir/$wine_conf")"
|
||||||
if [ ! -d "$wine_prefix" ]; then
|
if [ ! -d "$wine_prefix" ]; then
|
||||||
echo -e "\nThe saved wine prefix does not exist, ignoring.\n"
|
debug_echo "The saved wine prefix does not exist, ignoring."
|
||||||
wine_prefix=""
|
wine_prefix=""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then
|
if [ -f "$conf_dir/$conf_subdir/$game_conf" ]; then
|
||||||
game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")"
|
game_path="$(cat "$conf_dir/$conf_subdir/$game_conf")"
|
||||||
if [ ! -d "$game_path" ] || [ "$(basename "$game_path")" != "StarCitizen" ]; then
|
if [ ! -d "$game_path" ] || [ "$(basename "$game_path")" != "StarCitizen" ]; then
|
||||||
echo -e "\nUnexpected game path found in config file, ignoring.\n"
|
debug_echo "Unexpected game path found in config file, ignoring."
|
||||||
game_path=""
|
game_path=""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -f "$conf_dir/$conf_subdir/$backup_conf" ]; then
|
if [ -f "$conf_dir/$conf_subdir/$backup_conf" ]; then
|
||||||
backup_path="$(cat "$conf_dir/$conf_subdir/$backup_conf")"
|
backup_path="$(cat "$conf_dir/$conf_subdir/$backup_conf")"
|
||||||
if [ ! -d "$backup_path" ]; then
|
if [ ! -d "$backup_path" ]; then
|
||||||
echo -e "\nThe saved backup path does not exist, ignoring.\n"
|
debug_echo "The saved backup path does not exist, ignoring."
|
||||||
backup_path=""
|
backup_path=""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -294,7 +326,7 @@ getdirs() {
|
|||||||
if [ "$has_zen" -eq 1 ]; then
|
if [ "$has_zen" -eq 1 ]; then
|
||||||
# Get the wine prefix directory
|
# Get the wine prefix directory
|
||||||
if [ -z "$wine_prefix" ]; then
|
if [ -z "$wine_prefix" ]; then
|
||||||
wine_prefix="$(zenity --file-selection --directory --title="Select your WINE prefix directory" --filename="$HOME/.wine")"
|
wine_prefix="$(zenity --file-selection --directory --title="Select your WINE prefix directory" --filename="$HOME/.wine" 2>/dev/null)"
|
||||||
if [ "$?" -eq -1 ]; then
|
if [ "$?" -eq -1 ]; then
|
||||||
message warning "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
|
return 1
|
||||||
@ -307,7 +339,7 @@ getdirs() {
|
|||||||
|
|
||||||
# Get the game path
|
# Get the game path
|
||||||
if [ -z "$game_path" ]; then
|
if [ -z "$game_path" ]; then
|
||||||
while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen")"; do
|
while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/drive_c/Program Files/Roberts Space Industries/StarCitizen" 2>/dev/null)"; do
|
||||||
if [ "$?" -eq -1 ]; then
|
if [ "$?" -eq -1 ]; then
|
||||||
message warning "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
|
return 1
|
||||||
@ -328,7 +360,7 @@ getdirs() {
|
|||||||
|
|
||||||
# Get the backup directory
|
# Get the backup directory
|
||||||
if [ -z "$backup_path" ]; then
|
if [ -z "$backup_path" ]; then
|
||||||
while backup_path="$(zenity --file-selection --directory --title="Select a directory to back up your keybinds into" --filename="$HOME/")"; do
|
while backup_path="$(zenity --file-selection --directory --title="Select a directory to back up your keybinds into" --filename="$HOME/" 2>/dev/null)"; do
|
||||||
if [ "$?" -eq -1 ]; then
|
if [ "$?" -eq -1 ]; then
|
||||||
message warning "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
|
return 1
|
||||||
@ -436,21 +468,21 @@ sanitize() {
|
|||||||
if message question "This helper will delete the following directory:\n\n$user_dir\n\nDo you want to proceed?"; then
|
if message question "This helper will delete the following directory:\n\n$user_dir\n\nDo you want to proceed?"; then
|
||||||
# Back up keybinds
|
# Back up keybinds
|
||||||
if [ "$exported" -eq 1 ]; then
|
if [ "$exported" -eq 1 ]; then
|
||||||
echo "Backing up all saved keybinds..."
|
debug_echo "Backing up all saved keybinds..."
|
||||||
cp -r "$keybinds_dir/." "$backup_path/keybinds/"
|
cp -r "$keybinds_dir/." "$backup_path/keybinds/"
|
||||||
echo -e "Done.\n"
|
debug_echo "Done."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Wipe the user directory
|
# Wipe the user directory
|
||||||
echo "Wiping USER directory..."
|
debug_echo "Wiping USER directory..."
|
||||||
rm -r "$user_dir"
|
rm -r "$user_dir"
|
||||||
echo -e "Done.\n"
|
debug_echo "Done."
|
||||||
|
|
||||||
# Restore custom keybinds
|
# Restore custom keybinds
|
||||||
if [ "$exported" -eq 1 ]; then
|
if [ "$exported" -eq 1 ]; then
|
||||||
echo "Restoring keybinds..."
|
debug_echo "Restoring keybinds..."
|
||||||
mkdir -p "$keybinds_dir" && cp -r "$backup_path/keybinds/." "$keybinds_dir/"
|
mkdir -p "$keybinds_dir" && cp -r "$backup_path/keybinds/." "$keybinds_dir/"
|
||||||
echo -e "Done.\n"
|
debug_echo "Done."
|
||||||
message info "To re-import your keybinds, select it in-game from the list:\nOptions->Keybindings->Control Profiles"
|
message info "To re-import your keybinds, select it in-game from the list:\nOptions->Keybindings->Control Profiles"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -458,6 +490,8 @@ sanitize() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------- begin mapcount functions --------------------------#
|
||||||
|
|
||||||
# Check if setting vm.max_map_count was successful
|
# Check if setting vm.max_map_count was successful
|
||||||
mapcount_check() {
|
mapcount_check() {
|
||||||
if [ "$(cat /proc/sys/vm/max_map_count)" -lt 16777216 ]; then
|
if [ "$(cat /proc/sys/vm/max_map_count)" -lt 16777216 ]; then
|
||||||
@ -512,9 +546,9 @@ mapcount_set() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Configure the menu
|
# Configure the menu
|
||||||
menu_text_zenity="<b>This helper can change vm.max_map_count for you.</b>\n\nChoose from the following options:"
|
menu_text_zenity="<b>This helper can change vm.max_map_count for you</b>\n\nChoose from the following options:"
|
||||||
menu_text_terminal="This helper can change vm.max_map_count for you.\n\nChoose from the following options:"
|
menu_text_terminal="This helper can change vm.max_map_count for you\n\nChoose from the following options:"
|
||||||
menu_height="200"
|
menu_text_height="100"
|
||||||
|
|
||||||
# Configure the menu options
|
# Configure the menu options
|
||||||
once="Change setting until next reboot"
|
once="Change setting until next reboot"
|
||||||
@ -527,6 +561,9 @@ mapcount_set() {
|
|||||||
# 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=("mapcount_once" "mapcount_persist" "mapcount_manual" "mapcount_check")
|
menu_actions=("mapcount_once" "mapcount_persist" "mapcount_manual" "mapcount_check")
|
||||||
|
|
||||||
|
# Calculate the total height the menu should be
|
||||||
|
menu_height="$(("$menu_text_height" + "$menu_option_height" * "${#menu_options[@]}"))"
|
||||||
|
|
||||||
# Display an informational message to the user
|
# Display an informational message to the user
|
||||||
message info "Running Star Citizen requires changing a system setting\nto give the game access to more than 8GB of memory.\n\nvm.max_map_count must be increased to at least 16777216\nto avoid crashes in areas with lots of geometry.\n\n\nAs far as this helper can detect, the setting\nhas not been changed on your system.\n\nYou will now be given the option to change it."
|
message info "Running Star Citizen requires changing a system setting\nto give the game access to more than 8GB of memory.\n\nvm.max_map_count must be increased to at least 16777216\nto avoid crashes in areas with lots of geometry.\n\n\nAs far as this helper can detect, the setting\nhas not been changed on your system.\n\nYou will now be given the option to change it."
|
||||||
|
|
||||||
@ -534,6 +571,10 @@ mapcount_set() {
|
|||||||
menu
|
menu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------- end mapcount 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_check() {
|
filelimit_check() {
|
||||||
if [ "$(ulimit -Hn)" -lt 524288 ]; then
|
if [ "$(ulimit -Hn)" -lt 524288 ]; then
|
||||||
@ -574,6 +615,9 @@ filelimit_set() {
|
|||||||
filelimit_check
|
filelimit_check
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------- end filelimit functions ---------------------------#
|
||||||
|
|
||||||
|
|
||||||
# Delete the shaders directory
|
# Delete the shaders directory
|
||||||
rm_shaders() {
|
rm_shaders() {
|
||||||
# Get/Set directory paths
|
# Get/Set directory paths
|
||||||
@ -593,9 +637,9 @@ rm_shaders() {
|
|||||||
|
|
||||||
# Delete the shader directory
|
# Delete the shader directory
|
||||||
if message question "This helper will delete the following directory:\n\n$shaders_dir\n\nDo you want to proceed?"; then
|
if message question "This helper will delete the following directory:\n\n$shaders_dir\n\nDo you want to proceed?"; then
|
||||||
echo "Deleting shaders..."
|
debug_echo "Deleting shaders..."
|
||||||
rm -r "$shaders_dir"
|
rm -r "$shaders_dir"
|
||||||
echo -e "Done.\n"
|
debug_echo "Done."
|
||||||
message info "Your shaders have been deleted!"
|
message info "Your shaders have been deleted!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -619,13 +663,243 @@ rm_vidcache() {
|
|||||||
|
|
||||||
# Delete the cache file
|
# Delete the cache file
|
||||||
if message question "This helper will delete the following file:\n\n$dxvk_cache\n\nDo you want to proceed?"; then
|
if message question "This helper will delete the following file:\n\n$dxvk_cache\n\nDo you want to proceed?"; then
|
||||||
echo "Deleting DXVK cache..."
|
debug_echo "Deleting DXVK cache..."
|
||||||
rm "$dxvk_cache"
|
rm "$dxvk_cache"
|
||||||
echo -e "Done.\n"
|
debug_echo "Done."
|
||||||
message info "Your DXVK cache has been deleted!"
|
message info "Your DXVK cache has been deleted!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------- begin runner functions ----------------------------#
|
||||||
|
|
||||||
|
# Restart lutris
|
||||||
|
lutris_restart() {
|
||||||
|
if [ "$lutris_needs_restart" = "true" ]; then
|
||||||
|
if message question "Lutris must be restarted to detect runner changes.\nWould you like this helper to restart it for you?"; then
|
||||||
|
if [ "$(pgrep lutris)" ]; then
|
||||||
|
debug_echo "Restarting Lutris..."
|
||||||
|
pkill -SIGTERM lutris && nohup lutris </dev/null &>/dev/null &
|
||||||
|
else
|
||||||
|
message info "Lutris does not appear to be running."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
lutris_needs_restart="false"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Delete the selected runner
|
||||||
|
runner_delete() {
|
||||||
|
# This function expects an index number for the array installed_runners to be passed in as an argument
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
debug_echo "Script error: The runner_delete function expects an argument. Aborting."
|
||||||
|
read -n 1 -s -p "Press any key..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
runner_to_delete="$1"
|
||||||
|
if message question "Are you sure you want to delete the following runner?\n\n${installed_runners[$runner_to_delete]}"; then
|
||||||
|
rm -r "${installed_runners[$runner_to_delete]}"
|
||||||
|
debug_echo "Deleted ${installed_runners[$runner_to_delete]}"
|
||||||
|
lutris_needs_restart="true"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# List installed runners for deletion
|
||||||
|
runner_select_delete() {
|
||||||
|
# Configure the menu
|
||||||
|
menu_text_zenity="Select the Lutris runner you want to remove:"
|
||||||
|
menu_text_terminal="Select the Lutris runner you want to remove:"
|
||||||
|
menu_text_height="65"
|
||||||
|
goback="Return to the runner management menu"
|
||||||
|
unset installed_runners
|
||||||
|
unset menu_options
|
||||||
|
unset menu_actions
|
||||||
|
|
||||||
|
# Create an array containing all directories in the runner_dir
|
||||||
|
for runners_list in "$runner_dir"/*; do
|
||||||
|
if [ -d "$runners_list" ]; then
|
||||||
|
installed_runners+=("$runners_list")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create menu options for the installed runners
|
||||||
|
for (( i=0; i<"${#installed_runners[@]}"; i++ )); do
|
||||||
|
menu_options+=("$(basename "${installed_runners[i]}")")
|
||||||
|
menu_actions+=("runner_delete $i")
|
||||||
|
done
|
||||||
|
|
||||||
|
# Complete the menu by adding the option to go back to the previous menu
|
||||||
|
menu_options+=("$goback")
|
||||||
|
menu_actions+=(":") # no-op
|
||||||
|
|
||||||
|
# Calculate the total height the menu should be
|
||||||
|
menu_height="$(("$menu_text_height" + "$menu_option_height" * "${#menu_options[@]}"))"
|
||||||
|
if [ "$menu_height" -gt "400" ]; then
|
||||||
|
menu_height="400"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Call the menu function. It will use the options as configured above
|
||||||
|
menu
|
||||||
|
}
|
||||||
|
|
||||||
|
# Download and install the selected runner
|
||||||
|
runner_install() {
|
||||||
|
# This function expects an index number for the array runner_versions to be passed in as an argument
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
debug_echo "Script error: The runner_install function expects an argument. Aborting."
|
||||||
|
read -n 1 -s -p "Press any key..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Store the selected runner name and url
|
||||||
|
runner_name="${runner_versions[$1]}"
|
||||||
|
if [ "$latest_url" = "$snatella_url" ]; then
|
||||||
|
# Runners with .tgz file extension
|
||||||
|
runner_url="$(curl -s "$latest_url" | grep "browser_download_url.*$runner_name.tgz" | cut -d \" -f4)"
|
||||||
|
else
|
||||||
|
# Runners with .tar.gz file extension
|
||||||
|
runner_url="$(curl -s "$latest_url" | grep "browser_download_url.*$runner_name.tar.gz" | cut -d \" -f4)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sanity check
|
||||||
|
if [ -z "$runner_url" ]; then
|
||||||
|
message warning "Could not find the requested runner. The Github API may be down or rate limited."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
message info "The selected runner will now be downloaded.\nThis might take a moment."
|
||||||
|
|
||||||
|
# Download and extract the runner
|
||||||
|
if [ "$latest_url" = "$snatella_url" ]; then
|
||||||
|
# Runners without a subdirectory in the archive
|
||||||
|
debug_echo "Downloading $runner_url\ninto $runner_dir/$runner_name"
|
||||||
|
mkdir -p "$runner_dir/$runner_name" && curl -L "$runner_url" | tar -xzf - -C "$runner_dir/$runner_name"
|
||||||
|
lutris_needs_restart="true"
|
||||||
|
else
|
||||||
|
# Runners with a subdirectory in the archive
|
||||||
|
debug_echo "Downloading $runner_url\ninto $runner_dir"
|
||||||
|
mkdir -p "$runner_dir" && curl -L "$runner_url" | tar -xzf - -C "$runner_dir"
|
||||||
|
lutris_needs_restart="true"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# List available runners for download
|
||||||
|
runner_select_install() {
|
||||||
|
# This function expects the name of the runner contributor to be passed in as an argument
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
debug_echo "Script error: The runner_select_install function expects an argument. Aborting."
|
||||||
|
read -n 1 -s -p "Press any key..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set download urls
|
||||||
|
case "$1" in
|
||||||
|
"snatella")
|
||||||
|
latest_url="$snatella_url"
|
||||||
|
runner_versions=($(curl -s "$latest_url" | grep "browser_download_url" | awk '{print $2}' | xargs basename -as .tgz))
|
||||||
|
;;
|
||||||
|
"rawfox")
|
||||||
|
latest_url="$rawfox_url"
|
||||||
|
runner_versions=($(curl -s "$latest_url" | grep "browser_download_url" | awk '{print $2}' | xargs basename -as .tar.gz))
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
debug_echo "Script Error: Invalid parameter passed to the runner version function. Aborting."
|
||||||
|
read -n 1 -s -p "Press any key..."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Sanity check
|
||||||
|
if [ "${#runner_versions[@]}" -eq 0 ]; then
|
||||||
|
message warning "No runner versions were found. The Github API may be down or rate limited."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configure the menu
|
||||||
|
menu_text_zenity="Select the Lutris runner you want to install:"
|
||||||
|
menu_text_terminal="Select the Lutris runner you want to install:"
|
||||||
|
menu_text_height="65"
|
||||||
|
goback="Return to the runner management menu"
|
||||||
|
unset menu_options
|
||||||
|
unset menu_actions
|
||||||
|
|
||||||
|
# Allow up to max_runners to be displayed in the list
|
||||||
|
if [ "${#runner_versions[@]}" -gt "$max_runners" ]; then
|
||||||
|
runner_count="$max_runners"
|
||||||
|
else
|
||||||
|
runner_count="${#runner_versions[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Iterate through the versions, check if they are installed, and add them to the menu options
|
||||||
|
for (( i=0; i<"$runner_count"; i++ )); do
|
||||||
|
if [ -d "$runner_dir/${runner_versions[i]}" ]; then
|
||||||
|
menu_options+=("${runner_versions[i]} [installed]")
|
||||||
|
else
|
||||||
|
menu_options+=("${runner_versions[i]}")
|
||||||
|
fi
|
||||||
|
menu_actions+=("runner_install $i")
|
||||||
|
done
|
||||||
|
|
||||||
|
# Complete the menu by adding the option to go back to the previous menu
|
||||||
|
menu_options+=("$goback")
|
||||||
|
menu_actions+=(":") # no-op
|
||||||
|
|
||||||
|
# Calculate the total height the menu should be
|
||||||
|
menu_height="$(("$menu_text_height" + "$menu_option_height" * "${#menu_options[@]}"))"
|
||||||
|
if [ "$menu_height" -gt "400" ]; then
|
||||||
|
menu_height="400"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Call the menu function. It will use the options as configured above
|
||||||
|
menu
|
||||||
|
}
|
||||||
|
|
||||||
|
# Called when the user is done managing runners. Causes a return to the main menu
|
||||||
|
runner_manage_done() {
|
||||||
|
managing_runners="false"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Manage Lutris runners
|
||||||
|
runner_manage() {
|
||||||
|
# Check if Lutris is installed
|
||||||
|
if [ ! -x "$(command -v lutris)" ]; then
|
||||||
|
message info "Lutris does not appear to be installed."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The runner management menu will loop until the user cancels
|
||||||
|
managing_runners="true"
|
||||||
|
|
||||||
|
while [ "$managing_runners" = "true" ]; do
|
||||||
|
# Configure the menu
|
||||||
|
menu_text_zenity="<b>This helper can manage your Lutris runners</b>\n\nChoose from the following options:"
|
||||||
|
menu_text_terminal="This helper can manage your Lutris runners<\n\nChoose from the following options:"
|
||||||
|
menu_text_height="100"
|
||||||
|
|
||||||
|
# Configure the menu options
|
||||||
|
rawfox="Install a runner from RawFox"
|
||||||
|
snatella="Install a runner from Molotov/Snatella"
|
||||||
|
delete="Remove an installed runner"
|
||||||
|
back="Return to the main menu"
|
||||||
|
# Set the options to be displayed in the menu
|
||||||
|
menu_options=("$rawfox" "$snatella" "$delete" "$back")
|
||||||
|
# Set the corresponding functions to be called for each of the options
|
||||||
|
menu_actions=("runner_select_install rawfox" "runner_select_install snatella" "runner_select_delete" "runner_manage_done")
|
||||||
|
|
||||||
|
# Calculate the total height the menu should be
|
||||||
|
menu_height="$(("$menu_text_height" + "$menu_option_height" * "${#menu_options[@]}"))"
|
||||||
|
|
||||||
|
# Call the menu function. It will use the options as configured above
|
||||||
|
menu
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check if lutris needs to be restarted after making changes
|
||||||
|
lutris_restart
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------- end runner functions -----------------------------#
|
||||||
|
|
||||||
|
|
||||||
# Toggle between targeting the LIVE and PTU game directories for all helper functions
|
# Toggle between targeting the LIVE and PTU game directories for all helper functions
|
||||||
set_version() {
|
set_version() {
|
||||||
if [ "$live_or_ptu" = "LIVE" ]; then
|
if [ "$live_or_ptu" = "LIVE" ]; then
|
||||||
@ -635,7 +909,7 @@ set_version() {
|
|||||||
live_or_ptu="LIVE"
|
live_or_ptu="LIVE"
|
||||||
message info "The helper will now target your Star Citizen LIVE installation."
|
message info "The helper will now target your Star Citizen LIVE installation."
|
||||||
else
|
else
|
||||||
echo -e "\nUnexpected game version provided. Defaulting to the LIVE installation."
|
debug_echo "Unexpected game version provided. Defaulting to the LIVE installation."
|
||||||
live_or_ptu="LIVE"
|
live_or_ptu="LIVE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -644,6 +918,7 @@ quit() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
# MAIN
|
# MAIN
|
||||||
############################################################################
|
############################################################################
|
||||||
@ -654,29 +929,34 @@ if [ -x "$(command -v zenity)" ]; then
|
|||||||
has_zen=1
|
has_zen=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Default to LIVE
|
# Set some defaults
|
||||||
live_or_ptu="LIVE"
|
live_or_ptu="LIVE"
|
||||||
|
lutris_needs_restart="false"
|
||||||
|
|
||||||
# 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
|
||||||
menu_text_zenity="<b><big>Welcome, fellow Penguin, to the Star Citizen LUG Helper!</big>\n\nThis helper is designed to help optimize your system for Star Citizen</b>\n\nYou may choose from the following options:"
|
menu_text_zenity="<b><big>Welcome, fellow Penguin, to the Star Citizen LUG Helper!</big>\n\nThis helper is designed to help optimize your system for Star Citizen</b>\n\nYou may choose from the following options:"
|
||||||
menu_text_terminal="Welcome, fellow Penguin, to the Star Citizen Linux Users Group Helper!\n\nThis helper is designed to help optimize your system for Star Citizen\nYou may choose from the following options:"
|
menu_text_terminal="Welcome, fellow Penguin, to the Star Citizen Linux Users Group Helper!\n\nThis helper is designed to help optimize your system for Star Citizen\nYou may choose from the following options:"
|
||||||
menu_height="315"
|
menu_text_height="140"
|
||||||
|
|
||||||
# Configure the menu options
|
# Configure the menu options
|
||||||
|
runners_msg="Manage Lutris Runners"
|
||||||
|
sanitize_msg="Delete my Star Citizen USER folder and preserve my keybinds"
|
||||||
mapcount_msg="Check vm.max_map_count for optimal performance"
|
mapcount_msg="Check vm.max_map_count for optimal performance"
|
||||||
filelimit_msg="Check my open file descriptors limit"
|
filelimit_msg="Check my open file descriptors limit"
|
||||||
sanitize_msg="Delete my Star Citizen USER folder and preserve my keybinds"
|
|
||||||
shaders_msg="Delete my shaders only"
|
shaders_msg="Delete my shaders only"
|
||||||
vidcache_msg="Delete my DXVK cache"
|
vidcache_msg="Delete my DXVK cache"
|
||||||
version_msg="Switch the helper between LIVE and PTU (default is LIVE)"
|
version_msg="Switch the helper between LIVE and PTU (default is LIVE)"
|
||||||
quit_msg="Quit"
|
quit_msg="Quit"
|
||||||
|
|
||||||
# Set the options to be displayed in the menu
|
# Set the options to be displayed in the menu
|
||||||
menu_options=("$mapcount_msg" "$filelimit_msg" "$sanitize_msg" "$shaders_msg" "$vidcache_msg" "$version_msg" "$quit_msg")
|
menu_options=("$runners_msg" "$sanitize_msg" "$mapcount_msg" "$filelimit_msg" "$shaders_msg" "$vidcache_msg" "$version_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=("mapcount_set" "filelimit_set" "sanitize" "rm_shaders" "rm_vidcache" "set_version" "quit")
|
menu_actions=("runner_manage" "sanitize" "mapcount_set" "filelimit_set" "rm_shaders" "rm_vidcache" "set_version" "quit")
|
||||||
|
|
||||||
|
# Calculate the total height the menu should be
|
||||||
|
menu_height="$(("$menu_text_height" + "$menu_option_height" * "${#menu_options[@]}"))"
|
||||||
|
|
||||||
# Call the menu function. It will use the options as configured above
|
# Call the menu function. It will use the options as configured above
|
||||||
menu
|
menu
|
||||||
|
Reference in New Issue
Block a user