Add function comment markers for IDEs

This commit is contained in:
the-sane
2025-06-07 15:37:06 -04:00
parent 1f6c07f2e5
commit 43f75b1f71

View File

@ -190,6 +190,7 @@ current_version="v3.11"
############################################################################ ############################################################################
# MARK: try_exec()
# Try to execute a supplied command with either user or root privileges # Try to execute a supplied command with either user or root privileges
# Expects two string arguments # Expects two string arguments
# Usage: try_exec [root|user] "command" # Usage: try_exec [root|user] "command"
@ -247,6 +248,7 @@ try_exec() {
return 0 return 0
} }
# MARK: debug_print()
# Echo a formatted debug message to the terminal and optionally exit # Echo a formatted debug message to the terminal and optionally exit
# Accepts either "continue" or "exit" as the first argument # Accepts either "continue" or "exit" as the first argument
# followed by the string to be echoed # followed by the string to be echoed
@ -277,6 +279,7 @@ debug_print() {
esac esac
} }
# MARK: message()
# 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.
@ -400,6 +403,7 @@ message() {
fi fi
} }
# MARK: menu()
# Display a menu to the user. # Display a menu to the user.
# Uses Zenity for a gui menu with a fallback to plain old text. # Uses Zenity for a gui menu with a fallback to plain old text.
# #
@ -547,12 +551,14 @@ menu() {
fi fi
} }
# MARK: menu_loop_done()
# Called when the user clicks cancel on a looping menu # Called when the user clicks cancel on a looping menu
# Causes a return to the main menu # Causes a return to the main menu
menu_loop_done() { menu_loop_done() {
looping_menu="false" looping_menu="false"
} }
# MARK: getdirs()
# Get paths to the user's wine prefix, game directory, and a backup directory # Get paths to the user's wine prefix, game directory, and a backup directory
# Returns 3 if the user was asked to select new directories # Returns 3 if the user was asked to select new directories
getdirs() { getdirs() {
@ -695,6 +701,7 @@ getdirs() {
######## begin preflight check functions ################################### ######## begin preflight check functions ###################################
############################################################################ ############################################################################
# MARK: preflight_check()
# Check that the system is optimized for Star Citizen # Check that the system is optimized for Star Citizen
# Accepts an optional string argument, "wine" # Accepts an optional string argument, "wine"
# This argument is used by the install functions to indicate which # This argument is used by the install functions to indicate which
@ -857,6 +864,7 @@ preflight_check() {
fi fi
} }
# MARK: wine_check()
# Check the system Wine version # Check the system Wine version
# Tells the preflight check whether or not wine is installed # Tells the preflight check whether or not wine is installed
# Additionally sets system_wine_ok if system wine meets the minimum version requirement # Additionally sets system_wine_ok if system wine meets the minimum version requirement
@ -886,6 +894,7 @@ wine_check() {
fi fi
} }
# MARK: memory_check()
# Check system memory and swap space # Check system memory and swap space
memory_check() { memory_check() {
# Get totals in bytes # Get totals in bytes
@ -916,6 +925,7 @@ memory_check() {
fi fi
} }
# MARK: avx_check()
# Check CPU for the required AVX extension # Check CPU for the required AVX extension
avx_check() { avx_check() {
if grep -q "avx" /proc/cpuinfo; then if grep -q "avx" /proc/cpuinfo; then
@ -929,6 +939,7 @@ avx_check() {
######## begin mapcount functions ########################################## ######## begin mapcount functions ##########################################
############################################################################ ############################################################################
# MARK: mapcount_check()
# Check vm.max_map_count for the correct setting # Check vm.max_map_count for the correct setting
mapcount_check() { mapcount_check() {
mapcount="$(cat /proc/sys/vm/max_map_count)" mapcount="$(cat /proc/sys/vm/max_map_count)"
@ -961,6 +972,7 @@ mapcount_check() {
fi fi
} }
# MARK: mapcount_set()
# Set vm.max_map_count # Set vm.max_map_count
mapcount_set() { mapcount_set() {
if [ -d "/etc/sysctl.d" ]; then if [ -d "/etc/sysctl.d" ]; then
@ -977,6 +989,7 @@ mapcount_set() {
preflight_followup+=("mapcount_confirm") preflight_followup+=("mapcount_confirm")
} }
# MARK: mapcount_once()
# Sets vm.max_map_count for the current session only # Sets vm.max_map_count for the current session only
mapcount_once() { mapcount_once() {
preflight_root_actions+=('sysctl -w vm.max_map_count=16777216') preflight_root_actions+=('sysctl -w vm.max_map_count=16777216')
@ -984,6 +997,7 @@ mapcount_once() {
preflight_followup+=("mapcount_confirm") preflight_followup+=("mapcount_confirm")
} }
# MARK: mapcount_confirm()
# Check if setting vm.max_map_count was successful # Check if setting vm.max_map_count was successful
mapcount_confirm() { mapcount_confirm() {
if [ "$(cat /proc/sys/vm/max_map_count)" -lt 16777216 ]; then if [ "$(cat /proc/sys/vm/max_map_count)" -lt 16777216 ]; then
@ -999,6 +1013,7 @@ mapcount_confirm() {
######## begin filelimit functions ######################################### ######## begin filelimit functions #########################################
############################################################################ ############################################################################
# MARK: filelimit_check()
# Check the open file descriptors limit # Check the open file descriptors limit
filelimit_check() { filelimit_check() {
filelimit="$(ulimit -Hn)" filelimit="$(ulimit -Hn)"
@ -1027,6 +1042,7 @@ filelimit_check() {
fi fi
} }
# MARK: filelimit_set()
# Set the open file descriptors limit # Set the open file descriptors limit
filelimit_set() { filelimit_set() {
if [ -f "/etc/systemd/system.conf" ]; then if [ -f "/etc/systemd/system.conf" ]; then
@ -1048,6 +1064,7 @@ filelimit_set() {
preflight_followup+=("filelimit_confirm") preflight_followup+=("filelimit_confirm")
} }
# MARK: filelimit_confirm()
# Check if setting the open file descriptors limit was successful # Check if setting the open file descriptors limit was successful
filelimit_confirm() { filelimit_confirm() {
if [ "$(ulimit -Hn)" -lt 524288 ]; then if [ "$(ulimit -Hn)" -lt 524288 ]; then
@ -1067,6 +1084,7 @@ filelimit_confirm() {
######## begin download functions ########################################## ######## begin download functions ##########################################
############################################################################ ############################################################################
# MARK: download_manage()
# Manage downloads. Called by a dedicated download type manage function, ie runner_manage_wine() # Manage downloads. Called by a dedicated download type manage function, ie runner_manage_wine()
# #
# This function expects the following variables to be set: # This function expects the following variables to be set:
@ -1161,6 +1179,7 @@ download_manage() {
done done
} }
# MARK: runner_manage_wine()
# Configure the download_manage function for wine runners # Configure the download_manage function for wine runners
runner_manage_wine() { runner_manage_wine() {
# We'll want to instruct the user on how to use the downloaded runner # We'll want to instruct the user on how to use the downloaded runner
@ -1206,6 +1225,7 @@ runner_manage_wine() {
download_manage "runner" download_manage "runner"
} }
# MARK: download_select_install()
# List available items for download. Called by download_manage() # List available items for download. Called by download_manage()
# #
# The following variables are expected to be set before calling this function: # The following variables are expected to be set before calling this function:
@ -1423,6 +1443,7 @@ download_select_install() {
menu menu
} }
# MARK: download_install()
# Download and install the selected item. Called by download_select_install() # Download and install the selected item. Called by download_select_install()
# #
# The following variables are expected to be set before calling this function: # The following variables are expected to be set before calling this function:
@ -1607,6 +1628,7 @@ download_install() {
return 0 return 0
} }
# MARK: download_select_delete()
# List installed items for deletion. Called by download_manage() # List installed items for deletion. Called by download_manage()
# #
# The following variables are expected to be set before calling this function: # The following variables are expected to be set before calling this function:
@ -1687,6 +1709,7 @@ download_select_delete() {
menu menu
} }
# MARK: download_delete()
# Uninstall the selected item(s). Called by download_select_install() # Uninstall the selected item(s). Called by download_select_install()
# Accepts array index numbers as an argument # Accepts array index numbers as an argument
# #
@ -1731,6 +1754,7 @@ download_delete() {
fi fi
} }
# MARK: post_download()
# Perform post-download actions or display a message/instructions # Perform post-download actions or display a message/instructions
# #
# The following variables are expected to be set before calling this function: # The following variables are expected to be set before calling this function:
@ -1830,6 +1854,7 @@ post_download() {
fi fi
} }
# MARK: download_file()
# Download a file to the tmp directory # Download a file to the tmp directory
# Expects three arguments: The download URL, file name, and download type # Expects three arguments: The download URL, file name, and download type
download_file() { download_file() {
@ -1880,6 +1905,7 @@ download_file() {
######## begin maintenance functions ####################################### ######## begin maintenance functions #######################################
############################################################################ ############################################################################
# MARK: maintenance_menu()
# Show maintenance/troubleshooting options # Show maintenance/troubleshooting options
maintenance_menu() { maintenance_menu() {
# Loop the menu until the user selects quit # Loop the menu until the user selects quit
@ -1929,6 +1955,7 @@ maintenance_menu() {
done done
} }
# MARK: switch_prefix()
# Target the Helper at a different Star Citizen prefix/installation # Target the Helper at a different Star Citizen prefix/installation
switch_prefix() { switch_prefix() {
# Check if the config file exists # Check if the config file exists
@ -1947,6 +1974,7 @@ switch_prefix() {
fi fi
} }
# MARK: update_launcher()
# Update the game launch script if necessary # Update the game launch script if necessary
update_launcher() { update_launcher() {
getdirs getdirs
@ -1993,6 +2021,7 @@ update_launcher() {
fi fi
} }
# MARK: call_launch_script()
# Call our launch script and pass it the given command line argument # Call our launch script and pass it the given command line argument
call_launch_script() call_launch_script()
{ {
@ -2031,6 +2060,7 @@ call_launch_script()
"$wine_prefix/$wine_launch_script_name" "$launch_arg" "$wine_prefix/$wine_launch_script_name" "$launch_arg"
} }
# MARK: edit_wine_launch_script()
# Edit the launch script # Edit the launch script
edit_wine_launch_script() { edit_wine_launch_script() {
# Get/Set directory paths # Get/Set directory paths
@ -2055,6 +2085,7 @@ edit_wine_launch_script() {
fi fi
} }
# MARK: display_dirs()
# 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() {
dirs_list="\n" dirs_list="\n"
@ -2083,12 +2114,14 @@ display_dirs() {
message info "$message_heading\n$dirs_list" message info "$message_heading\n$dirs_list"
} }
# MARK: display_wiki()
# Display the LUG Wiki # Display the LUG Wiki
display_wiki() { display_wiki() {
# Display a message containing the URL # Display a message containing the URL
message info "See the Wiki for our Quick-Start Guide, Troubleshooting,\nand Performance Tuning Recommendations:\n\n$lug_wiki" message info "See the Wiki for our Quick-Start Guide, Troubleshooting,\nand Performance Tuning Recommendations:\n\n$lug_wiki"
} }
# MARK: reset_helper()
# Delete the helper's config directory # Delete the helper's config directory
reset_helper() { reset_helper() {
if [ "$1" = "switchprefix" ]; then if [ "$1" = "switchprefix" ]; then
@ -2112,6 +2145,7 @@ reset_helper() {
############################################################################ ############################################################################
# MARK: install_game_wine()
# Install the game with Wine # Install the game with Wine
install_game_wine() { install_game_wine() {
# Double check that wine is installed # Double check that wine is installed
@ -2365,6 +2399,7 @@ Path=$(echo $install_dir | sed 's/ /\\\s/g')/dosdevices/c:/Program\sFiles/Robert
message info "Installation has finished. The install log was written to $tmp_install_log\n\nTo start the RSI Launcher, run the following launch script in a terminal\nEdit the environment variables in the script as needed:\n $installed_launch_script\n\nYou may also start the RSI Launcher using the following .desktop files:\n $home_desktop_file\n $localshare_desktop_file" message info "Installation has finished. The install log was written to $tmp_install_log\n\nTo start the RSI Launcher, run the following launch script in a terminal\nEdit the environment variables in the script as needed:\n $installed_launch_script\n\nYou may also start the RSI Launcher using the following .desktop files:\n $home_desktop_file\n $localshare_desktop_file"
} }
# MARK: download_wine()
# Download a default wine runner for use by the installer # Download a default wine runner for use by the installer
# Expects download_dirs to be set before calling # Expects download_dirs to be set before calling
download_wine() { download_wine() {
@ -2399,6 +2434,7 @@ download_wine() {
fi fi
} }
# MARK: download_winetricks()
# Download winetricks to a temporary file # Download winetricks to a temporary file
download_winetricks() { download_winetricks() {
download_file "$winetricks_url" "winetricks" "winetricks" download_file "$winetricks_url" "winetricks" "winetricks"
@ -2417,6 +2453,7 @@ download_winetricks() {
chmod +x "$winetricks_bin" chmod +x "$winetricks_bin"
} }
# MARK: install_powershell()
# Install powershell verb into the game's wine prefix # Install powershell verb into the game's wine prefix
install_powershell() { install_powershell() {
# Download winetricks # Download winetricks
@ -2439,6 +2476,7 @@ install_powershell() {
fi fi
} }
# MARK: dxvk_update_wine()
# Update dxvk for native wine installs # Update dxvk for native wine installs
dxvk_update_wine() { dxvk_update_wine() {
# Download winetricks # Download winetricks
@ -2461,6 +2499,7 @@ dxvk_update_wine() {
fi fi
} }
# MARK: format_urls()
# Format some URLs for Zenity # Format some URLs for Zenity
format_urls() { format_urls() {
if [ "$use_zenity" -eq 1 ]; then if [ "$use_zenity" -eq 1 ]; then
@ -2470,6 +2509,7 @@ format_urls() {
fi fi
} }
# MARK: get_latest_release()
# Get the latest release version of a repo. Expects "user/repo_name" as input # Get the latest release version of a repo. Expects "user/repo_name" as input
# Credits for this go to https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c # Credits for this go to https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
get_latest_release() { get_latest_release() {
@ -2483,6 +2523,7 @@ get_latest_release() {
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
} }
# MARK: referral_randomizer()
# 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
@ -2494,6 +2535,7 @@ referral_randomizer() {
message info "Your random Penguin's referral code is:\n\n$random_code\n\nThank you!" message info "Your random Penguin's referral code is:\n\n$random_code\n\nThank you!"
} }
# MARK: quit()
quit() { quit() {
exit 0 exit 0
} }
@ -2503,6 +2545,7 @@ quit() {
######## MAIN ############################################################## ######## MAIN ##############################################################
############################################################################ ############################################################################
# MARK: MAIN
# Zenity availability/version check # Zenity availability/version check
use_zenity=0 use_zenity=0
# Initialize some variables # Initialize some variables
@ -2559,6 +2602,7 @@ if [ "$latest_version" != "$current_version" ] &&
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" 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 fi
# MARK: Cmdline arguments
# 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 ]
@ -2657,6 +2701,7 @@ fi
menu_heading_zenity="<b><big>Greetings, Space Penguin!</big>\n\nThis tool is provided by the Star Citizen Linux Users Group</b>\nFor help, see our wiki: $lug_wiki" menu_heading_zenity="<b><big>Greetings, Space Penguin!</big>\n\nThis tool is provided by the Star Citizen Linux Users Group</b>\nFor help, see our wiki: $lug_wiki"
menu_heading_terminal="Greetings, Space Penguin!\n\nThis tool is provided by the Star Citizen Linux Users Group\nFor help, see our wiki: $lug_wiki" menu_heading_terminal="Greetings, Space Penguin!\n\nThis tool is provided by the Star Citizen Linux Users Group\nFor help, see our wiki: $lug_wiki"
# MARK: First Run
# First run # First run
firstrun_message="It looks like this is your first time running the Helper\n\nWould you like to run the Preflight Check and install Star Citizen?" firstrun_message="It looks like this is your first time running the Helper\n\nWould you like to run the Preflight Check and install Star Citizen?"
if [ "$use_zenity" -eq 1 ]; then if [ "$use_zenity" -eq 1 ]; then
@ -2675,6 +2720,7 @@ if [ "$is_firstrun" = "true" ]; then
echo "false" > "$conf_dir/$conf_subdir/$firstrun_conf" echo "false" > "$conf_dir/$conf_subdir/$firstrun_conf"
fi fi
# MARK: Main Menu
# 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