Removed NSL Decky Plugin isntallation from the NSL Script
Release Please / release-please (push) Has been cancelled

This commit is contained in:
Roy
2025-08-21 19:03:36 -07:00
committed by GitHub
parent 5fd0565f43
commit dc36c54c39
-179
View File
@@ -4110,185 +4110,6 @@ rm -rf "$download_dir"
show_message "Waiting to detect plugin..."
# Function to switch to Game Mode
switch_to_game_mode() {
echo "Switching to Game Mode..."
show_message "Switching to Game Mode..."
rm -rf "$download_dir"
echo "Removing user service..."
rm -rf ${logged_in_home}/.config/systemd/user/nslgamescanner.service
unlink ${logged_in_home}/.config/systemd/user/default.target.wants/nslgamescanner.service
echo "Reloading systemd user daemon..."
systemctl --user daemon-reload
systemctl --user reset-failed
echo "Logging out to complete Game Mode switch..."
qdbus org.kde.Shutdown /Shutdown org.kde.Shutdown.logout
}
# Set the remote repository URL
REPO_URL="https://github.com/moraroy/NonSteamLaunchersDecky/archive/refs/heads/main.zip"
# Set the local directory path
LOCAL_DIR="${logged_in_home}/homebrew/plugins/NonSteamLaunchers"
# Function to check if a directory exists and contains files
directory_exists_and_not_empty() {
[ -d "$1" ] && [ -n "$(ls -A "$1")" ]
}
# Function to fetch version from GitHub
fetch_github_version() {
response=$(curl -s "https://raw.githubusercontent.com/moraroy/NonSteamLaunchersDecky/refs/heads/main/package.json")
echo "$response" | jq -r '.version'
}
# Function to fetch local version from package.json
fetch_local_version() {
if [ -f "$LOCAL_DIR/package.json" ]; then
jq -r '.version' "$LOCAL_DIR/package.json"
else
echo "null"
fi
}
# Function to compare versions
compare_versions() {
local local_version=$(fetch_local_version)
local github_version=$(fetch_github_version)
echo "Fetched Local Version: $local_version"
echo "Fetched GitHub Version: $github_version"
if [ "$local_version" == "null" ]; then
echo "Local version not found, need installation."
return 1
fi
echo "Local Version: $local_version, GitHub Version: $github_version"
if [ "$local_version" == "$github_version" ]; then
echo "Plugin is up-to-date."
return 0
else
echo "Update needed."
return 1
fi
}
# Function to check permissions for directories
check_permissions() {
ls -ld "${logged_in_home}/homebrew" "${logged_in_home}/homebrew/plugins" "${logged_in_home}/homebrew/plugins/NonSteamLaunchers"
}
# Function to adjust permissions temporarily to allow installation
adjust_permissions() {
echo "Adjusting permissions for plugin directories..."
chmod u+w "${logged_in_home}/homebrew/plugins" "${logged_in_home}/homebrew/plugins/NonSteamLaunchers"
}
# Function to restore original permissions
restore_permissions() {
echo "Restoring original permissions for plugin directories..."
chmod u-w "${logged_in_home}/homebrew/plugins" "${logged_in_home}/homebrew/plugins/NonSteamLaunchers"
}
# Main logic
set +x
show_message "Starting NSL Plugin installation/update script..."
echo "Detecting environment..."
# Check if Decky Loader exists
echo "Checking for Decky Loader..."
if ! directory_exists_and_not_empty "${logged_in_home}/homebrew/plugins"; then
zenity --error --text="This is not an error. Decky Loader was not detected. Please install it from their website and re-run this script to access the plugin version of NSL."
fi
# Check if the NSL Plugin exists
echo "Checking if NSL Plugin already exists..."
if directory_exists_and_not_empty "$LOCAL_DIR"; then
NSL_PLUGIN_EXISTS=true
echo "NSL Plugin found at $LOCAL_DIR"
else
NSL_PLUGIN_EXISTS=false
echo "NSL Plugin not found."
fi
set +x
# Compare versions and update if necessary
echo "Comparing local and remote plugin versions..."
show_message "Checking for plugin updates..."
if compare_versions; then
echo "No update needed. Plugin is already up-to-date."
show_message "NSL Plugin is up-to-date."
else
echo "Update required. Proceeding with update..."
show_message "Updating NSL Plugin to the latest version..."
# Remove existing plugin if it exists
if $NSL_PLUGIN_EXISTS; then
show_message "Removing existing plugin..."
echo "Removing $LOCAL_DIR..."
rm -rf "$LOCAL_DIR"
fi
# Adjust permissions before installation
show_message "Creating base directory and setting permissions..."
adjust_permissions
echo "Creating plugin directory at $LOCAL_DIR"
mkdir -p "$LOCAL_DIR"
chmod -R u+rw "$LOCAL_DIR"
chown -R $logged_in_user:$logged_in_user "$LOCAL_DIR"
# Download, unzip, and copy the plugin files
show_message "Downloading plugin from GitHub..."
echo "Downloading plugin zip..."
curl -L "$REPO_URL" -o /tmp/NonSteamLaunchersDecky.zip
echo "Unzipping plugin..."
unzip -o /tmp/NonSteamLaunchersDecky.zip -d /tmp/
echo "Copying files to $LOCAL_DIR..."
cp -r /tmp/NonSteamLaunchersDecky-main/* "$LOCAL_DIR"
# Clean up temporary files
echo "Cleaning up temporary files..."
rm -rf /tmp/NonSteamLaunchersDecky*
# Restore original permissions after installation
restore_permissions
set -x
#Switch to Game Mode
zenity --question --timeout=30 --text="NSL Plugin has been installed or updated. Do you want to switch to Game Mode now?"
if [ $? -eq 0 ]; then
show_message "Switching to Game Mode..."
switch_to_game_mode
else
echo "User chose not to switch to Game Mode or timed out."
fi
fi