mirror of
https://github.com/the-sane/lug-helper.git
synced 2025-01-14 13:20:35 +00:00
Fixes, formatting
This commit is contained in:
parent
7002579c3c
commit
94dc48f52c
@ -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.
|
||||
message() {
|
||||
if [ "$zenity" -eq 1 ]; then
|
||||
if [ "$has_zen" -eq 1 ]; then
|
||||
if [ "$1" -eq 1 ]; then
|
||||
# info
|
||||
margs="--info --no-wrap --text="
|
||||
@ -62,14 +56,14 @@ message() {
|
||||
margs="--list --radiolist --height=\"200\" --column=\" \" --column=\"What would you like to do?\" "
|
||||
elif [ "$1" -eq 5 ]; then
|
||||
# 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
|
||||
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..."
|
||||
fi
|
||||
|
||||
# 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
|
||||
# Text based menu. Does not work with message types 4 and 5 (zenity radio lists)
|
||||
# those need to be handled specially in the code
|
||||
@ -84,7 +78,7 @@ message() {
|
||||
exit 0
|
||||
elif [ "$1" -eq 3 ]; then
|
||||
# question
|
||||
echo -e "\n$2\n"
|
||||
echo -e "$2"
|
||||
while true; do
|
||||
read -p "[y/n]: " yn
|
||||
case "$yn" in
|
||||
@ -193,8 +187,8 @@ set_map_count() {
|
||||
persist="Change setting and persist after reboot"
|
||||
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 [ "$zenity" -eq 1 ]; 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 [ "$has_zen" -eq 1 ]; then
|
||||
# zenity menu
|
||||
RESULT="$(message 4 "TRUE $once \ FALSE $persist \ FALSE $manual")"
|
||||
case "$RESULT" in
|
||||
@ -223,7 +217,8 @@ set_map_count() {
|
||||
esac
|
||||
else
|
||||
# text menu
|
||||
options="($once $persist $manual)"
|
||||
echo -e "\n"
|
||||
options=("$once" "$persist" "$manual")
|
||||
PS3="Enter selection number or 'q' to quit: "
|
||||
|
||||
select choice in "${options[@]}"
|
||||
@ -242,6 +237,7 @@ set_map_count() {
|
||||
break
|
||||
;;
|
||||
"3")
|
||||
clear
|
||||
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'"
|
||||
else
|
||||
@ -268,8 +264,14 @@ set_map_count() {
|
||||
# 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
|
||||
if [ "$zenity" -eq 1 ]; then
|
||||
if [ "$has_zen" -eq 1 ]; then
|
||||
check="Check my system settings for optimal performance"
|
||||
clean="Delete my USER folder and preserve my keybinds"
|
||||
options="$(message 5 "TRUE $check \ FALSE $clean")"
|
||||
|
Loading…
x
Reference in New Issue
Block a user