mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-11-20 08:09:18 +01:00
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:
parent
5084a90d94
commit
41e2097fe4
@ -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
|
||||||
|
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
|
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
|
||||||
options="$selected_launchers"
|
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"
|
||||||
|
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,94 +692,105 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check if the Start Fresh button was clicked
|
|
||||||
if [[ $options == "Start Fresh" ]]; then
|
|
||||||
# The Start Fresh button was clicked
|
|
||||||
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
|
|
||||||
compatdata_dir="$HOME/.local/share/Steam/steamapps/compatdata"
|
|
||||||
|
|
||||||
# Define an array of original folder names
|
# Define the StartFreshFunction
|
||||||
folder_names=("EpicGamesLauncher" "GogGalaxyLauncher" "UplayLauncher" "OriginLauncher" "Battle.netLauncher" "TheEAappLauncher" "AmazonGamesLauncher" "itchioLauncher" "LegacyGamesLauncher" "HumbleGamesLauncher" "IndieGalaLauncher" "RockstarGamesLauncher" "GlyphLauncher" "MinecraftLauncher" "PlaystationPlusLauncher" "DMMGameLauncher")
|
function StartFreshFunction {
|
||||||
|
# Define the path to the compatdata directory
|
||||||
|
compatdata_dir="$HOME/.local/share/Steam/steamapps/compatdata"
|
||||||
|
|
||||||
# Iterate over each folder name in the folder_names array
|
# Define an array of original folder names
|
||||||
for folder in "${folder_names[@]}"; do
|
folder_names=("EpicGamesLauncher" "GogGalaxyLauncher" "UplayLauncher" "OriginLauncher" "Battle.netLauncher" "TheEAappLauncher" "AmazonGamesLauncher" "itchioLauncher" "LegacyGamesLauncher" "HumbleGamesLauncher" "IndieGalaLauncher" "RockstarGamesLauncher" "GlyphLauncher" "MinecraftLauncher" "PlaystationPlusLauncher" "DMMGameLauncher")
|
||||||
# Check if the folder exists
|
|
||||||
if [ -e "$compatdata_dir/$folder" ]; then
|
|
||||||
# Check if the folder is a symbolic link
|
|
||||||
if [ -L "$compatdata_dir/$folder" ]; then
|
|
||||||
# Get the path of the target of the symbolic link
|
|
||||||
target_path=$(readlink -f "$compatdata_dir/$folder")
|
|
||||||
|
|
||||||
# Delete the target of the symbolic link
|
# Iterate over each folder name in the folder_names array
|
||||||
rm -rf "$target_path"
|
for folder in "${folder_names[@]}"; do
|
||||||
|
# Check if the folder exists
|
||||||
# Delete the symbolic link
|
if [ -e "$compatdata_dir/$folder" ]; then
|
||||||
unlink "$compatdata_dir/$folder"
|
# Check if the folder is a symbolic link
|
||||||
else
|
if [ -L "$compatdata_dir/$folder" ]; then
|
||||||
# Delete the folder
|
|
||||||
rm -rf "$compatdata_dir/$folder"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Check if the NonSteamLaunchers folder exists
|
|
||||||
if [ -e "$compatdata_dir/NonSteamLaunchers" ]; then
|
|
||||||
# Check if the NonSteamLaunchers folder is a symbolic link
|
|
||||||
if [ -L "$compatdata_dir/NonSteamLaunchers" ]; then
|
|
||||||
# Get the path of the target of the symbolic link
|
# Get the path of the target of the symbolic link
|
||||||
target_path=$(readlink -f "$compatdata_dir/NonSteamLaunchers")
|
target_path=$(readlink -f "$compatdata_dir/$folder")
|
||||||
|
|
||||||
# Delete the target of the symbolic link
|
# Delete the target of the symbolic link
|
||||||
rm -rf "$target_path"
|
rm -rf "$target_path"
|
||||||
|
|
||||||
# Delete the symbolic link
|
# Delete the symbolic link
|
||||||
unlink "$compatdata_dir/NonSteamLaunchers"
|
unlink "$compatdata_dir/$folder"
|
||||||
else
|
else
|
||||||
# Delete the NonSteamLaunchers folder
|
# Delete the folder
|
||||||
rm -rf "$compatdata_dir/NonSteamLaunchers"
|
rm -rf "$compatdata_dir/$folder"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Iterate over each folder in the compatdata directory
|
# Check if the NonSteamLaunchers folder exists
|
||||||
for folder_path in "$compatdata_dir"/*; do
|
if [ -e "$compatdata_dir/NonSteamLaunchers" ]; then
|
||||||
# Check if the current item is a folder
|
# Check if the NonSteamLaunchers folder is a symbolic link
|
||||||
if [ -d "$folder_path" ]; then
|
if [ -L "$compatdata_dir/NonSteamLaunchers" ]; then
|
||||||
# Check if the folder is empty
|
# Get the path of the target of the symbolic link
|
||||||
if [ -z "$(ls -A "$folder_path")" ]; then
|
target_path=$(readlink -f "$compatdata_dir/NonSteamLaunchers")
|
||||||
# Delete the empty folder
|
|
||||||
rmdir "$folder_path"
|
# Delete the target of the symbolic link
|
||||||
echo "Deleted empty folder: $(basename "$folder_path")"
|
rm -rf "$target_path"
|
||||||
fi
|
|
||||||
|
# Delete the symbolic link
|
||||||
|
unlink "$compatdata_dir/NonSteamLaunchers"
|
||||||
|
else
|
||||||
|
# Delete the NonSteamLaunchers folder
|
||||||
|
rm -rf "$compatdata_dir/NonSteamLaunchers"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Iterate over each folder in the compatdata directory
|
||||||
|
for folder_path in "$compatdata_dir"/*; do
|
||||||
|
# Check if the current item is a folder
|
||||||
|
if [ -d "$folder_path" ]; then
|
||||||
|
# Check if the folder is empty
|
||||||
|
if [ -z "$(ls -A "$folder_path")" ]; then
|
||||||
|
# Delete the empty folder
|
||||||
|
rmdir "$folder_path"
|
||||||
|
echo "Deleted empty folder: $(basename "$folder_path")"
|
||||||
fi
|
fi
|
||||||
done
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf "/run/media/mmcblk0p1/NonSteamLaunchers/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/EpicGamesLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/GogGalaxyLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/OriginLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/UplayLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/Battle.netLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/TheEAappLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/AmazonGamesLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/LegacyGamesLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/itchioLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/HumbleGamesLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/IndieGalaLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/RockstarGamesLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/GlyphLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/MinecraftLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/PlaystationPlusLauncher/"
|
||||||
|
rm -rf "/run/media/mmcblk0p1/DMMGameLauncher/"
|
||||||
|
rm -rf ~/Downloads/NonSteamLaunchersInstallation
|
||||||
|
|
||||||
rm -rf "/run/media/mmcblk0p1/NonSteamLaunchers/"
|
# Exit the script with exit code 0 to indicate success
|
||||||
rm -rf "/run/media/mmcblk0p1/EpicGamesLauncher/"
|
exit 0
|
||||||
rm -rf "/run/media/mmcblk0p1/GogGalaxyLauncher/"
|
}
|
||||||
rm -rf "/run/media/mmcblk0p1/OriginLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/UplayLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/Battle.netLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/TheEAappLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/AmazonGamesLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/LegacyGamesLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/itchioLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/HumbleGamesLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/IndieGalaLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/RockstarGamesLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/GlyphLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/MinecraftLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/PlaystationPlusLauncher/"
|
|
||||||
rm -rf "/run/media/mmcblk0p1/DMMGameLauncher/"
|
|
||||||
rm -rf ~/Downloads/NonSteamLaunchersInstallation
|
|
||||||
|
|
||||||
# Exit the script with exit code 0 to indicate success
|
# Check if the Start Fresh button was clicked or if the Start Fresh option was passed as a command line argument
|
||||||
exit 0
|
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
|
||||||
|
# The user clicked the "No" button, so exit with exit code 0 to indicate success.
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# The user clicked the "No" button, so exit with exit code 0 to indicate success.
|
# Command line arguments were provided, so skip displaying the zenity window and directly perform any necessary actions to start fresh by calling the StartFreshFunction
|
||||||
exit 0
|
StartFreshFunction
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user