diff --git a/components/shellbridge.py b/components/shellbridge.py index 451442c..a676dbe 100644 --- a/components/shellbridge.py +++ b/components/shellbridge.py @@ -176,3 +176,17 @@ def run(self): spotipath = os.path.join(os.path.join(os.path.expanduser( '~'), 'AppData', 'Roaming'), 'Spotify', 'Spotify.exe') subprocess.Popen(spotipath) + + +def backgroundActivate(): + try: + killpath1 = os.path.join(os.path.join(os.path.expanduser( + '~'), 'AppData', 'Roaming'), 'Spotify', 'Apps', 'login.spa') + killpath2 = os.path.join(os.path.join(os.path.expanduser( + '~'), 'AppData', 'Roaming'), 'Spotify', 'Apps', 'xpui.spa') + os.remove(killpath1) + os.remove(killpath2) + return True + except: + print("Error while removing login.spa and xpui.spa") + return False diff --git a/main.py b/main.py index 7c066a6..3f5e6b6 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ from PyQt6.uic import loadUi from PyQt6.QtGui import QDesktopServices, QMovie, QIcon from components.popups import errorDialog, warnDialog, windowsToast, confirmationModal, spicetifyStatusToast -from components.shellbridge import InstallSpicetify, UpdateSpicetify, ApplySpicetify, ActivateSpicetify, UninstallSpicetify, CustomCommand, blockSpotifyUpdate, RestartSpotify +from components.shellbridge import * from components.statusInfo import * from components.tools import * from components.dialog_windows import AfterInstall @@ -520,16 +520,27 @@ def run(self): def alertSpicetifyStatus(): status = spicetifyStatusCheck() - if status == 0: - print("A new version of Spicetify is available") - interactableToaster = InteractableWindowsToaster( - 'An update for spicetify is available') - interactableToaster.show_toast(newToast) - elif status == 1: - print("Spicetify is not working correctly") - interactableToaster = InteractableWindowsToaster( - 'Spicetify is not working correctly') - interactableToaster.show_toast(newToast) + if readConfig('Manager', 'autopatch') == 'True': + if status == 0: + windowsToast("Spicetify is updating", "Prepare for restart!") + subprocess.run('spicetify upgrade -q', shell=True) + elif status == 1: + if backgroundActivate(): + windowsToast("Background Patcher", + "Spicetify has been activated!") + else: + windowsToast("Error", "Spicetify could not be activated!") + else: + if status == 0: + print("A new version of Spicetify is available") + interactableToaster = InteractableWindowsToaster( + 'An update for spicetify is available') + interactableToaster.show_toast(newToast) + elif status == 1: + print("Spicetify is not working correctly") + interactableToaster = InteractableWindowsToaster( + 'Spicetify is not working correctly') + interactableToaster.show_toast(newToast) def activated_callback(activatedEventArgs: ToastActivatedEventArgs):