Reworked more code for decky plugin

~reworked some code to allow for the main functions of the zenity window to be in line with the plugins capabilities. Overtime the script will need to be updated to allow more functionality.
This commit is contained in:
Roy 2023-08-09 01:09:45 -07:00 committed by GitHub
parent 5084a90d94
commit 41e2097fe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -542,6 +542,9 @@ args=("$@")
# Initialize an array to store the custom websites # Initialize an array to store the custom websites
custom_websites=() custom_websites=()
# Initialize a variable to store whether the "Separate App IDs" option is selected or not
separate_app_ids=false
# Check if any command line arguments were provided # Check if any command line arguments were provided
if [ ${#args[@]} -eq 0 ]; then if [ ${#args[@]} -eq 0 ]; then
# No command line arguments were provided, so display the main zenity window # No command line arguments were provided, so display the main zenity window
@ -555,29 +558,65 @@ if [ ${#args[@]} -eq 0 ]; then
# The user did not click the 'Cancel' button or select one of the extra buttons, so prompt for custom websites # The user did not click the 'Cancel' button or select one of the extra buttons, so prompt for custom websites
custom_websites_str=$(zenity --entry --title="Shortcut Creator" --text="Enter custom websites that you want shortcuts for, separated by commas. Leave blank and press ok if you dont want any. E.g. myspace.com, limewire.com, my.screenname.aol.com") custom_websites_str=$(zenity --entry --title="Shortcut Creator" --text="Enter custom websites that you want shortcuts for, separated by commas. Leave blank and press ok if you dont want any. E.g. myspace.com, limewire.com, my.screenname.aol.com")
# Check if the user clicked the 'Cancel' button # Check if the user clicked the 'Cancel' button or entered an empty string
if [ $? -eq 1 ]; then if [ $? -eq 1 ] || [ -z "$custom_websites_str" ]; then
# The user clicked the 'Cancel' button, so exit the script # The user clicked the 'Cancel' button or entered an empty string, so exit the script
echo "The cancel button was clicked" echo "The cancel button was clicked or no custom websites were entered"
exit 1 exit 1
fi fi
# Split the custom_websites_str variable into an array using ',' as the delimiter # Split the custom_websites_str variable into an array using ',' as the delimiter
IFS=',' read -ra custom_websites <<< "$custom_websites_str" IFS=',' read -ra custom_websites <<< "$custom_websites_str"
fi fi
else else
# Command line arguments were provided, so set the value of the options variable using the command line arguments # Command line arguments were provided, so set the value of the options variable using the command line arguments
selected_launchers="${args[0]}"
custom_websites+=("${args[@]:1}") # Initialize an array to store the selected launchers
selected_launchers=()
for arg in "${args[@]}"; do
if [[ "$arg" =~ ^https?:// ]]; then
# Check if the arg is not an empty string before adding it to the custom_websites array
if [ -n "$arg" ]; then
custom_websites+=("$arg")
fi fi
else
selected_launchers+=("$arg")
fi
done
# Convert the selected_launchers array to a string by joining its elements with a `|` delimiter.
selected_launchers_str=$(IFS="|"; echo "${selected_launchers[*]}")
# Check if the `SEPARATE APP IDS - CHECK THIS TO SEPARATE YOUR PREFIX'S` option was included in the `selected_launchers` variable. If this option was included, set the value of the `separate_app_ids` variable to `true`, indicating that separate app IDs should be used. Otherwise, set it to `false`.
if [[ "${selected_launchers[@]}" =~ "SEPARATE APP IDS - CHECK THIS TO SEPARATE YOUR PREFIX'S" ]]; then
separate_app_ids=true
else
separate_app_ids=false
fi
fi
# Print the selected launchers and custom websites # Print the selected launchers and custom websites
echo "Selected launchers: $selected_launchers" echo "Selected launchers: $selected_launchers"
echo "Selected launchers: $selected_launchers_str"
echo "Custom websites: ${custom_websites[@]}" echo "Custom websites: ${custom_websites[@]}"
echo "Separate App IDs: $separate_app_ids"
# Set the value of the options variable # Set the value of the options variable
if [ ${#args[@]} -eq 0 ]; then
# No command line arguments were provided, so set the value of the options variable using the selected_launchers variable
options="$selected_launchers" options="$selected_launchers"
else
# Command line arguments were provided, so set the value of the options variable using the selected_launchers_str variable
options="$selected_launchers_str"
fi
# Check if the cancel button was clicked # Check if the cancel button was clicked
if [ $? -eq 1 ] && [[ $options != "Start Fresh" ]] && [[ $options != "Move to SD Card" ]] && [[ $options != "Uninstall" ]] && [[ $options != "Find Games" ]]; then if [ $? -eq 1 ] && [[ $options != "Start Fresh" ]] && [[ $options != "Move to SD Card" ]] && [[ $options != "Uninstall" ]] && [[ $options != "Find Games" ]]; then
@ -609,6 +648,9 @@ fi
# Check if the user selected both Origin and EA App # Check if the user selected both Origin and EA App
if [[ $options == *"Origin"* ]] && [[ $options == *"EA App"* ]] && [ "$use_separate_appids" = false ]; then if [[ $options == *"Origin"* ]] && [[ $options == *"EA App"* ]] && [ "$use_separate_appids" = false ]; then
# User selected both Origin and EA App without selecting separate app IDs # User selected both Origin and EA App without selecting separate app IDs
@ -650,11 +692,9 @@ fi
# Check if the Start Fresh button was clicked
if [[ $options == "Start Fresh" ]]; then # Define the StartFreshFunction
# The Start Fresh button was clicked function StartFreshFunction {
if zenity --question --text="aaahhh it always feels good to start fresh :) but...This will delete the App ID folders you installed inside the steamapps/compatdata/ directory. This means anything youve installed (launchers or games) WITHIN THIS SCRIPT will be deleted if you have them there. Everything will be wiped. Are you sure?" --width=300 --height=260; then
# The user clicked the "Yes" button
# Define the path to the compatdata directory # Define the path to the compatdata directory
compatdata_dir="$HOME/.local/share/Steam/steamapps/compatdata" compatdata_dir="$HOME/.local/share/Steam/steamapps/compatdata"
@ -713,7 +753,6 @@ if [[ $options == "Start Fresh" ]]; then
fi fi
done done
rm -rf "/run/media/mmcblk0p1/NonSteamLaunchers/" rm -rf "/run/media/mmcblk0p1/NonSteamLaunchers/"
rm -rf "/run/media/mmcblk0p1/EpicGamesLauncher/" rm -rf "/run/media/mmcblk0p1/EpicGamesLauncher/"
rm -rf "/run/media/mmcblk0p1/GogGalaxyLauncher/" rm -rf "/run/media/mmcblk0p1/GogGalaxyLauncher/"
@ -735,10 +774,24 @@ if [[ $options == "Start Fresh" ]]; then
# Exit the script with exit code 0 to indicate success # Exit the script with exit code 0 to indicate success
exit 0 exit 0
}
# Check if the Start Fresh button was clicked or if the Start Fresh option was passed as a command line argument
if [[ $options == "Start Fresh" ]] || [[ $selected_launchers == "Start Fresh" ]]; then
# The Start Fresh button was clicked or the Start Fresh option was passed as a command line argument
if [ ${#args[@]} -eq 0 ]; then
# No command line arguments were provided, so display the zenity window
if zenity --question --text="aaahhh it always feels good to start fresh :) but...This will delete the App ID folders you installed inside the steamapps/compatdata/ directory. This means anything youve installed (launchers or games) WITHIN THIS SCRIPT will be deleted if you have them there. Everything will be wiped. Are you sure?" --width=300 --height=260; then
# The user clicked the "Yes" button, so call the StartFreshFunction
StartFreshFunction
else else
# The user clicked the "No" button, so exit with exit code 0 to indicate success. # The user clicked the "No" button, so exit with exit code 0 to indicate success.
exit 0 exit 0
fi fi
else
# Command line arguments were provided, so skip displaying the zenity window and directly perform any necessary actions to start fresh by calling the StartFreshFunction
StartFreshFunction
fi
fi fi