Fixes, formatting

This commit is contained in:
the-sane 2020-08-03 18:15:38 -04:00 committed by GitHub
parent 7002579c3c
commit 94dc48f52c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,15 +39,9 @@ mappings="$user/Controls/Mappings"
############################################################################ ############################################################################
############################################################################ ############################################################################
# Check if Zenity is available
zenity=0
if [ -x "$(command -v zenity)" ]; then
zenity=1
fi
# Display a message to the user. Expects a numerical argument followed by the string to display. # Display a message to the user. Expects a numerical argument followed by the string to display.
message() { message() {
if [ "$zenity" -eq 1 ]; then if [ "$has_zen" -eq 1 ]; then
if [ "$1" -eq 1 ]; then if [ "$1" -eq 1 ]; then
# info # info
margs="--info --no-wrap --text=" margs="--info --no-wrap --text="
@ -60,16 +54,16 @@ message() {
elif [ "$1" -eq 4 ]; then elif [ "$1" -eq 4 ]; then
# radio list # radio list
margs="--list --radiolist --height=\"200\" --column=\" \" --column=\"What would you like to do?\" " margs="--list --radiolist --height=\"200\" --column=\" \" --column=\"What would you like to do?\" "
elif [ "$1" -eq 5]; then elif [ "$1" -eq 5 ]; then
# main menu radio list # main menu radio list
margs="--list --radiolist --height=\"175\" --text="Welcome, fellow penguin, to the Star Citizen Linux Users Group Helper Script!" --column=\" \" --column=\"What would you like to do?\" " margs="--list --radiolist --height=\"175\" --text=\"Welcome, fellow penguin, to the Star Citizen Linux Users Group Helper Script!\" --column=\" \" --column=\"What would you like to do?\" "
else else
echo -e "Invalid message format.\n\nThe message function expects a numerical argument followed by the string to display.\n" echo -e "Invalid message format.\n\nThe message function expects a numerical argument followed by the string to display.\n"
read -n 1 -s -p "Press any key..." read -n 1 -s -p "Press any key..."
fi fi
# Display the message # Display the message
zenity "$margs$2" --icon-name='lutris' --width="400" --title="Star Citizen LUG Helper Script" zenity "$margs" --icon-name='lutris' --width="400" --title="Star Citizen LUG Helper Script"
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)
# those need to be handled specially in the code # those need to be handled specially in the code
@ -84,7 +78,7 @@ message() {
exit 0 exit 0
elif [ "$1" -eq 3 ]; then elif [ "$1" -eq 3 ]; then
# question # question
echo -e "\n$2\n" echo -e "$2"
while true; do while true; do
read -p "[y/n]: " yn read -p "[y/n]: " yn
case "$yn" in case "$yn" in
@ -193,8 +187,8 @@ set_map_count() {
persist="Change setting and persist after reboot" persist="Change setting and persist after reboot"
manual="Show me the commands; I'll handle it myself" manual="Show me the commands; I'll handle it myself"
if message 3 "Running Star Citizen requires changing a system setting.\n\nvm.max_map_count must be increased to at least 16777216 to avoid crashes in areas with lots of geometry.\n\nAs far as this script can detect, the setting has 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.\n\nvm.max_map_count must be increased to at least 16777216\nto avoid crashes in areas with lots of geometry.\n\nAs far as this script can detect,\nthe setting has not been changed on your system.\n\nWould you like to change the setting now?"; then
if [ "$zenity" -eq 1 ]; then if [ "$has_zen" -eq 1 ]; then
# zenity menu # zenity menu
RESULT="$(message 4 "TRUE $once \ FALSE $persist \ FALSE $manual")" RESULT="$(message 4 "TRUE $once \ FALSE $persist \ FALSE $manual")"
case "$RESULT" in case "$RESULT" in
@ -223,7 +217,8 @@ set_map_count() {
esac esac
else else
# text menu # text menu
options="($once $persist $manual)" echo -e "\n"
options=("$once" "$persist" "$manual")
PS3="Enter selection number or 'q' to quit: " PS3="Enter selection number or 'q' to quit: "
select choice in "${options[@]}" select choice in "${options[@]}"
@ -242,6 +237,7 @@ set_map_count() {
break break
;; ;;
"3") "3")
clear
if [ -d "/etc/sysctl.d" ]; then if [ -d "/etc/sysctl.d" ]; then
message 1 "To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\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 && sysctl -p'" message 1 "To change the setting (a kernel parameter) until next boot, run:\n\nsudo sh -c 'sysctl -w vm.max_map_count=16777216'\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 && sysctl -p'"
else else
@ -268,8 +264,14 @@ set_map_count() {
# MAIN # MAIN
############################################################################ ############################################################################
# Check if Zenity is available
has_zen=0
if [ -x "$(command -v zenity)" ]; then
has_zen=1
fi
# Use Zenity if it is available # Use Zenity if it is available
if [ "$zenity" -eq 1 ]; then if [ "$has_zen" -eq 1 ]; then
check="Check my system settings for optimal performance" check="Check my system settings for optimal performance"
clean="Delete my USER folder and preserve my keybinds" clean="Delete my USER folder and preserve my keybinds"
options="$(message 5 "TRUE $check \ FALSE $clean")" options="$(message 5 "TRUE $check \ FALSE $clean")"
@ -285,7 +287,7 @@ if [ "$zenity" -eq 1 ]; then
;; ;;
esac esac
else else
# Use a text menu if Zenity is not available # Use a text menu if Zenity is not available
echo -e "\nWelcome, fellow penguin, to the Star Citizen Linux Users Group Helper Script!\nWhat would you like to do?\n" echo -e "\nWelcome, fellow penguin, to the Star Citizen Linux Users Group Helper Script!\nWhat would you like to do?\n"
options=("Check my system settings for optimal performance" "Delete my USER folder and preserve my keybinds") options=("Check my system settings for optimal performance" "Delete my USER folder and preserve my keybinds")