mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-12-21 07:11:52 +01:00
Update NonSteamLaunchers.sh
This commit is contained in:
parent
ec492481f7
commit
81a863b968
@ -2265,118 +2265,7 @@ fi
|
||||
|
||||
sleep 15
|
||||
|
||||
# Function to switch to Game Mode
|
||||
switch_to_game_mode() {
|
||||
echo "Switching to Game Mode..."
|
||||
# Delete NonSteamLaunchersInstallation subfolder in Downloads folder
|
||||
rm -rf "$download_dir"
|
||||
# Delete the service file
|
||||
rm -rf ${logged_in_home}/.config/systemd/user/nslgamescanner.service
|
||||
# Remove the symlink
|
||||
unlink ${logged_in_home}/.config/systemd/user/default.target.wants/nslgamescanner.service
|
||||
# Reload the systemd user instance
|
||||
systemctl --user daemon-reload
|
||||
qdbus org.kde.Shutdown /Shutdown org.kde.Shutdown.logout
|
||||
}
|
||||
|
||||
# Function to display a Zenity message
|
||||
show_message() {
|
||||
zenity --notification --text="$1" --timeout=1
|
||||
}
|
||||
|
||||
# Set the remote repository URL
|
||||
REPO_URL="https://github.com/moraroy/NonSteamLaunchersDecky/"
|
||||
|
||||
# Set the local directory path
|
||||
LOCAL_DIR="${logged_in_home}/homebrew/plugins/NonSteamLaunchers"
|
||||
|
||||
# Set the name of the branch you want to reset
|
||||
BRANCH_NAME="test"
|
||||
|
||||
# Ensure the base directory exists and has the correct permissions
|
||||
BASE_DIR="${logged_in_home}/homebrew/plugins"
|
||||
sudo mkdir -p $BASE_DIR
|
||||
sudo chmod -R u+rw $BASE_DIR
|
||||
sudo chown -R $USER:$USER $BASE_DIR
|
||||
|
||||
# Check if the Decky Loader and NSL Plugin exist
|
||||
DECKY_LOADER_EXISTS=false
|
||||
NSL_PLUGIN_EXISTS=false
|
||||
|
||||
if [ -d "${logged_in_home}/homebrew/plugins" ]; then
|
||||
DECKY_LOADER_EXISTS=true
|
||||
fi
|
||||
|
||||
if [ -d "$LOCAL_DIR" ]; then
|
||||
NSL_PLUGIN_EXISTS=true
|
||||
fi
|
||||
|
||||
if $DECKY_LOADER_EXISTS && $NSL_PLUGIN_EXISTS; then
|
||||
show_message "Decky Loader and NSL Plugin are both already installed! Checking for updates and then entering Gaming Mode..."
|
||||
echo "Navigating to the plugin directory to check for updates..."
|
||||
cd "$LOCAL_DIR"
|
||||
echo "Fetching the latest changes..."
|
||||
git fetch
|
||||
echo "Resetting the plugin to the latest version..."
|
||||
git reset --hard origin/$BRANCH_NAME
|
||||
switch_to_game_mode
|
||||
exit 0
|
||||
elif $DECKY_LOADER_EXISTS && ! $NSL_PLUGIN_EXISTS; then
|
||||
USER_INPUT=$(zenity --forms --title="Authentication Required" --text="Decky Loader detected! But no NSL plugin :( Would you like to inject the plugin and switch to Game Mode?" --separator="|" --add-password="Password")
|
||||
else
|
||||
zenity --error --text="Decky Loader not detected. Please download and install it from their website first and re-run this script to get the NSL Plugin."
|
||||
# Delete NonSteamLaunchersInstallation subfolder in Downloads folder
|
||||
rm -rf "$download_dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract the password
|
||||
USER_PASSWORD=$(echo $USER_INPUT | cut -d'|' -f1)
|
||||
|
||||
# Check if the user provided a password
|
||||
if [ -z "$USER_PASSWORD" ]; then
|
||||
zenity --error --text="No password entered. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Arrays to store original permissions and ownership
|
||||
declare -a PERMISSIONS
|
||||
declare -a OWNERSHIP
|
||||
declare -a DIRECTORIES
|
||||
|
||||
# Save current permissions and ownership for homebrew directory and its subdirectories
|
||||
while IFS= read -r line; do
|
||||
PERMISSIONS+=("$(stat -c "%a" "$line")")
|
||||
OWNERSHIP+=("$(stat -c "%U:%G" "$line")")
|
||||
DIRECTORIES+=("$line")
|
||||
done < <(find "${logged_in_home}/homebrew" -type d)
|
||||
|
||||
# Change permissions for the homebrew directory and its subdirectories
|
||||
sudo chmod -R u+rw "${logged_in_home}/homebrew/"
|
||||
sudo chown -R $USER:$USER "${logged_in_home}/homebrew/"
|
||||
|
||||
# New method to install the plugin
|
||||
mkdir -p "$LOCAL_DIR"
|
||||
sudo chmod -R u+rw "$LOCAL_DIR"
|
||||
sudo chown -R $USER:$USER "$LOCAL_DIR"
|
||||
|
||||
# Clone the repository directly
|
||||
git clone "$REPO_URL" "$LOCAL_DIR"
|
||||
|
||||
# Ensure we're on the correct branch
|
||||
cd "$LOCAL_DIR"
|
||||
git checkout "$BRANCH_NAME"
|
||||
|
||||
# Restore original permissions and ownership for homebrew directory and its subdirectories
|
||||
for i in "${!DIRECTORIES[@]}"; do
|
||||
sudo chmod "${PERMISSIONS[$i]}" "${DIRECTORIES[$i]}"
|
||||
sudo chown "${OWNERSHIP[$i]}" "${DIRECTORIES[$i]}"
|
||||
done
|
||||
|
||||
show_message "Plugin installed. Switching to Game Mode..."
|
||||
|
||||
# Switch to Game Mode after completion
|
||||
switch_to_game_mode
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user