Toggle between LIVE and PTU

This commit is contained in:
the-sane 2020-08-17 21:57:24 -04:00 committed by GitHub
parent 6a113e00ab
commit fa5993be8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@ message() {
# main menu radio list # main menu radio list
# call format: message 5 "TRUE" "List item 1" "FALSE" "List item 2" "FALSE" "List item 3" # call format: message 5 "TRUE" "List item 1" "FALSE" "List item 2" "FALSE" "List item 3"
# IMPORTANT: Adjust the height value below based on the number of items listed in the menu # IMPORTANT: Adjust the height value below based on the number of items listed in the menu
margs=("--list" "--radiolist" "--height=240" "--text=<b><big>Welcome, fellow Penguin, to the Star Citizen LUG Helper Script!</big>\n\nThis script is designed to help you optimize your system for Star Citizen.</b>\n\nYou may choose from the following options:" "--hide-header" "--column=" "--column=Option") margs=("--list" "--radiolist" "--height=240" "--text=<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:" "--hide-header" "--column=" "--column=Option")
;; ;;
*) *)
echo -e "Invalid message format.\n\nThe message function expects a numerical argument followed by string arguments.\n" echo -e "Invalid message format.\n\nThe message function expects a numerical argument followed by string arguments.\n"
@ -85,11 +85,11 @@ message() {
if [ "$1" -eq 4 ] || [ "$1" -eq 5 ]; then if [ "$1" -eq 4 ] || [ "$1" -eq 5 ]; then
# requires a space between the assembled arguments # requires a space between the assembled arguments
shift 1 # drop the first numerical argument and shift the remaining up one shift 1 # drop the first numerical argument and shift the remaining up one
zenity "${margs[@]}" "$@" --width="400" --title="Star Citizen LUG Helper Script" zenity "${margs[@]}" "$@" --width="400" --title="Star Citizen LUG Helper"
else else
# no space between the assmebled arguments # no space between the assmebled arguments
shift 1 # drop the first numerical argument and shift the remaining up one shift 1 # drop the first numerical argument and shift the remaining up one
zenity "${margs[@]}""$@" --width="400" --title="Star Citizen LUG Helper Script" zenity "${margs[@]}""$@" --width="400" --title="Star Citizen LUG Helper"
fi fi
else else
# Text based menu. Does not work with message types 4 and 5 (zenity radio lists) # Text based menu. Does not work with message types 4 and 5 (zenity radio lists)
@ -141,7 +141,7 @@ message() {
getdirs() { getdirs() {
# Sanity checks # Sanity checks
if [ ! -d "$conf_dir" ]; then if [ ! -d "$conf_dir" ]; then
message 2 "Config directory not found. The script is unable to proceed.\n\n$conf_dir" message 2 "Config directory not found. The helper is unable to proceed.\n\n$conf_dir"
return 1 return 1
fi fi
@ -155,19 +155,23 @@ getdirs() {
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 [ "$(basename "$game_path")" != "Star Citizen" ]; then
echo -e "\nUnexpected game path found in config file, ignoring.\n"
game_path=""
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")"
fi fi
if [ -z "$wine_prefix" ] || [ -z "$game_path" ] || [ -z "$backup_path" ]; then if [ -z "$wine_prefix" ] || [ -z "$game_path" ] || [ -z "$backup_path" ]; then
message 1 "You will now be asked to provide some directories needed by this script.\n\nThey will be saved for later use in:\n$conf_dir/$conf_subdir/" message 1 "You will now be asked to provide some directories needed by the helper.\n\nThey will be saved for later use in:\n$conf_dir/$conf_subdir/"
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")"
if [ "$?" -eq -1 ]; then if [ "$?" -eq -1 ]; then
message 2 "An unexpected error has occurred. The script is unable to proceed." message 2 "An unexpected error has occurred. The helper is unable to proceed."
return 1 return 1
elif [ -z "$wine_prefix" ]; then elif [ -z "$wine_prefix" ]; then
# User clicked cancel # User clicked cancel
@ -178,12 +182,12 @@ 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 LIVE directory" --filename="$wine_prefix/")"; do while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/drive_c/Program Files/Roberts Space Industries/Star Citizen")"; do
if [ "$?" -eq -1 ]; then if [ "$?" -eq -1 ]; then
message 2 "An unexpected error has occurred. The script is unable to proceed." message 2 "An unexpected error has occurred. The helper is unable to proceed."
return 1 return 1
elif [ "$(basename "$game_path")" != "LIVE" ]; then elif [ "$(basename "$game_path")" != "Star Citizen" ]; then
message 2 "You must select your LIVE directory." message 2 "You must select the directory named 'Star Citizen'"
else else
# All good or cancel # All good or cancel
break break
@ -201,7 +205,7 @@ getdirs() {
if [ -z "$backup_path" ]; then if [ -z "$backup_path" ]; then
backup_path="$(zenity --file-selection --directory --title="Select a backup directory for your keybinds" --filename="$HOME/")" backup_path="$(zenity --file-selection --directory --title="Select a backup directory for your keybinds" --filename="$HOME/")"
if [ "$?" -eq -1 ]; then if [ "$?" -eq -1 ]; then
message 2 "An unexpected error has occurred. The script is unable to proceed." message 2 "An unexpected error has occurred. The helper is unable to proceed."
return 1 return 1
elif [ -z "$backup_path" ]; then elif [ -z "$backup_path" ]; then
# User clicked cancel # User clicked cancel
@ -225,13 +229,13 @@ getdirs() {
# Get the game path # Get the game path
if [ -z "$game_path" ]; then if [ -z "$game_path" ]; then
echo -e "\nEnter the full path to your Star Citizen installation LIVE directory\n(case sensitive)" echo -e "\nEnter the full path to your Star Citizen installation directory\n(case sensitive)"
echo -e "ie. /home/USER/.wine/drive_c/Program Files/Roberts Space Industries/Star Citizen/LIVE/" echo -e "ie. /home/USER/.wine/drive_c/Program Files/Roberts Space Industries/Star Citizen/"
while read -rp ": " game_path; do while read -rp ": " game_path; do
if [ ! -d "$game_path" ]; then if [ ! -d "$game_path" ]; then
echo -e "That directory is invalid or does not exist. Please try again.\n" echo -e "That directory is invalid or does not exist. Please try again.\n"
elif [ "$(basename "$game_path")" != "LIVE" ]; then elif [ "$(basename "$game_path")" != "Star Citizen" ]; then
echo -e "You must select your LIVE directory." echo -e "You must enter the full path to the directory named 'Star Citizen'"
else else
break break
fi fi
@ -260,7 +264,7 @@ getdirs() {
fi fi
# Set some remaining directory paths # Set some remaining directory paths
user_dir="$game_path/USER" user_dir="$game_path/$live_or_ptu/USER"
mappings_dir="$user_dir/Controls/Mappings" mappings_dir="$user_dir/Controls/Mappings"
} }
@ -278,7 +282,7 @@ sanitize() {
# Sanity check # Sanity check
if [ ! -d "$user_dir" ]; then if [ ! -d "$user_dir" ]; then
message 2 "Directory not found. The script is unable to proceed.\n\n$user_dir" message 2 "Directory not found. The helper is unable to proceed.\n\n$user_dir"
return 0 return 0
fi fi
@ -320,7 +324,7 @@ sanitize() {
# Check if setting vm.max_map_count was successful # Check if setting vm.max_map_count was successful
check_mapcount() { check_mapcount() {
if [ "$(cat /proc/sys/vm/max_map_count)" -lt 16777216 ]; then if [ "$(cat /proc/sys/vm/max_map_count)" -lt 16777216 ]; then
message 2 "As far as this script can detect, vm.max_map_count\nwas not successfully configured on your system.\n\nYou will most likely experience crashes." message 2 "As far as this helper can detect, vm.max_map_count\nwas not successfully configured on your system.\n\nYou will most likely experience crashes."
fi fi
} }
@ -348,7 +352,7 @@ set_mapcount() {
newsysctl_msg="To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\n\n\nTo persist the setting between reboots, run:\n\nsudo sh -c 'echo \"vm.max_map_count = 16777216\" >> /etc/sysctl.d/20-max_map_count.conf &amp;&amp; sysctl -p'" newsysctl_msg="To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\n\n\nTo persist the setting between reboots, run:\n\nsudo sh -c 'echo \"vm.max_map_count = 16777216\" >> /etc/sysctl.d/20-max_map_count.conf &amp;&amp; sysctl -p'"
oldsysctl_msg="To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\n\n\nTo persist the setting between reboots, run:\n\nsudo sh -c 'echo \"vm.max_map_count = 16777216\" >> /etc/sysctl.conf &amp;&amp; sysctl -p'" oldsysctl_msg="To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\n\n\nTo persist the setting between reboots, run:\n\nsudo sh -c 'echo \"vm.max_map_count = 16777216\" >> /etc/sysctl.conf &amp;&amp; sysctl -p'"
if message 3 "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 script can detect, the setting\nhas not been changed on your system.\n\nWould you like to change the setting now?"; then if message 3 "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\nWould you like to change the setting now?"; then
if [ "$has_zen" -eq 1 ]; then if [ "$has_zen" -eq 1 ]; then
# zenity menu # zenity menu
options_mapcount=("--height=165" "TRUE" "$once" "FALSE" "$persist" "FALSE" "$manual") options_mapcount=("--height=165" "TRUE" "$once" "FALSE" "$persist" "FALSE" "$manual")
@ -381,7 +385,7 @@ set_mapcount() {
else else
# text menu # text menu
clear clear
echo -e "\nThis script can change vm.max_map_count for you.\nChoose from the following options:\n" echo -e "\nThis helper can change vm.max_map_count for you.\nChoose from the following options:\n"
options_mapcount=("$once" "$persist" "$manual" "$goback") options_mapcount=("$once" "$persist" "$manual" "$goback")
PS3="Enter selection number: " PS3="Enter selection number: "
@ -451,8 +455,8 @@ rm_shaders() {
# Delete DXVK and OpenGL caches # Delete DXVK and OpenGL caches
rm_vidcache() { rm_vidcache() {
dxvk_cache="$game_path/StarCitizen-dxvk.cache" dxvk_cache="$game_path/$live_or_ptu/StarCitizen-dxvk.cache"
opengl_cach="$game_path/" opengl_cach="$game_path/$live_or_ptu"
# Get/Set directory paths # Get/Set directory paths
getdirs getdirs
@ -489,11 +493,12 @@ main_menu() {
clean="Delete my USER folder and preserve my keybinds" clean="Delete my USER folder and preserve my keybinds"
shaders="Delete my shaders only" shaders="Delete my shaders only"
vidcache="Delete my DXVK and OpenGL caches" vidcache="Delete my DXVK and OpenGL caches"
changever="Switch the helper between LIVE and PTU (default is LIVE)"
quit="Quit" quit="Quit"
# Use Zenity if it is available # Use Zenity if it is available
if [ "$has_zen" -eq 1 ]; then if [ "$has_zen" -eq 1 ]; then
options_main=("TRUE" "$mapcount" "FALSE" "$clean" "FALSE" "$shaders" "FALSE" "$vidcache" "FALSE" "$quit") options_main=("TRUE" "$mapcount" "FALSE" "$clean" "FALSE" "$shaders" "FALSE" "$vidcache" "FALSE" "$changever" "FALSE" "$quit")
choice="$(message 5 "${options_main[@]}")" choice="$(message 5 "${options_main[@]}")"
case "$choice" in case "$choice" in
@ -509,6 +514,18 @@ main_menu() {
"$vidcache") "$vidcache")
rm_vidcache rm_vidcache
;; ;;
"$changever")
if [ "$live_or_ptu" == "LIVE" ]; then
live_or_ptu="PTU"
message 1 "The helper will now target your Star Citizen PTU installation."
elif [ "$live_or_ptu" == "PTU" ]; then
live_or_ptu="LIVE"
message 1 "The helper will now target your Star Citizen LIVE installation."
else
echo -e "\nUnexpected game version provided. Defaulting to the LIVE installation."
live_or_ptu="LIVE"
fi
;;
"$quit") "$quit")
exit 0 exit 0
;; ;;
@ -519,9 +536,9 @@ main_menu() {
else else
# Use a text menu if Zenity is not available # Use a text menu if Zenity is not available
clear clear
echo -e "\nWelcome, fellow Penguin, to the Star Citizen Linux Users Group Helper Script!\n\nThis script is designed to help you optimize your system for Star Citizen.\nYou may choose from the following options:\n" echo -e "\nWelcome, 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:\n"
options_main=("$mapcount" "$clean" "$shaders" "$vidcache" "$quit") options_main=("$mapcount" "$clean" "$shaders" "$vidcache" "$changever" "$quit")
PS3="Enter selection number: " PS3="Enter selection number: "
select choice in "${options_main[@]}" select choice in "${options_main[@]}"
@ -547,6 +564,20 @@ main_menu() {
rm_vidcache rm_vidcache
break break
;; ;;
"$changever")
echo -e "\n"
if [ "$live_or_ptu" == "LIVE" ]; then
live_or_ptu="PTU"
message 1 "This helper will now target your Star Citizen PTU installation."
elif [ "$live_or_ptu" == "PTU" ]; then
live_or_ptu="LIVE"
message 1 "This helper will now target your Star Citizen LIVE installation."
else
echo -e "\nUnexpected game version provided. Defaulting to the LIVE installation."
live_or_ptu="LIVE"
fi
break
;;
"$quit") "$quit")
exit 0 exit 0
;; ;;
@ -569,6 +600,9 @@ if [ -x "$(command -v zenity)" ]; then
has_zen=1 has_zen=1
fi fi
# Default to LIVE
live_or_ptu="LIVE"
# Loop the main menu until the user selects quit # Loop the main menu until the user selects quit
while true; do while true; do
main_menu main_menu