Skip to content

Commit

Permalink
Implemented background update/activate
Browse files Browse the repository at this point in the history
  • Loading branch information
Protonosgit committed Dec 15, 2023
1 parent 05b1b37 commit e0afc71
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
14 changes: 14 additions & 0 deletions components/shellbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 22 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit e0afc71

Please sign in to comment.