Skip to content

Commit

Permalink
Fixed background status check and improved toast actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Protonosgit committed Dec 9, 2023
1 parent 341d1b2 commit 555b5c2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
12 changes: 5 additions & 7 deletions components/popups.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt6.QtWidgets import QErrorMessage, QMessageBox
from PyQt6.QtWidgets import QMessageBox
from windows_toasts import WindowsToaster, Toast, ToastButton, InteractableWindowsToaster

# !!!
Expand Down Expand Up @@ -40,15 +40,13 @@ def windowsToast(title, message):
toastbuilder.text_fields = [title, message]
toaster.show_toast(toastbuilder)

# Unused


def winUpdateToast():
# unused due to limitations related to the window manager in main.py
def spicetifyStatusToast(message):
interactableToaster = InteractableWindowsToaster('Spicetify Manager')
newToast = Toast(['Spicetify is not active'], 'Spicetify Manager')
newToast = Toast([message])

newToast.AddAction(ToastButton('Open Manager', 'response=decent'))
newToast.AddAction(ToastButton('Open manager', 'response=decent'))
newToast.AddAction(ToastButton('Ignore', 'response=bad'))

interactableToaster.show_toast(newToast)
return newToast
20 changes: 10 additions & 10 deletions components/statusInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ def checkMarketplaceInstalled():

def spicetifyStatusCheck():
try:
LOCALSPICETIFYVER = subprocess.check_output(
'spicetify --version', shell=True).decode("utf-8").strip()
LATESTSPICETIFYVER = getLatestSpicetifyRelease().replace("v", "").strip()
linkpath = os.path.join(os.path.join(os.path.expanduser(
'~'), 'AppData', 'Roaming'), 'Spotify', 'Apps', 'login.spa')
if os.path.exists(linkpath):
if (LOCALSPICETIFYVER == LATESTSPICETIFYVER):
return 0
if checkSpicetifyInstalled():
spicetifylatest = getLatestSpicetifyRelease().replace("v", "").strip()
spicetifylocal = subprocess.check_output(
'spicetify --version', shell=True).decode("utf-8").strip()
if checkSpicetifyActive():
if spicetifylatest == spicetifylocal:
return 0
else:
return 2
else:
return 1
else:
return 2
return 0
except:
return 0
14 changes: 11 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
from PyQt6.QtCore import Qt, QUrl, QThread
from PyQt6.uic import loadUi
from PyQt6.QtGui import QDesktopServices, QMovie, QIcon
from components.popups import errorDialog, infoDialog, windowsToast, confirmationModal
from components.popups import errorDialog, infoDialog, windowsToast, confirmationModal, spicetifyStatusToast
from components.shellbridge import InstallSpicetify, UpdateSpicetify, ApplySpicetify, UninstallSpicetify, CustomCommand, blockSpotifyUpdate
from components.statusInfo import *
from components.tools import *
from components.dialog_windows import AfterInstall
from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple
from windows_toasts import ToastActivatedEventArgs

initConfig()

Expand Down Expand Up @@ -451,12 +452,19 @@ def run(self):
def alertSpicetifyStatus():
status = spicetifyStatusCheck()
if status == 2:
windowsToast("Spicetify Manager", "Update available!")
spicetifyStatusToast(
'A new version of Spicetify is available').on_activated = toast_callback
elif status == 1:
windowsToast("Spicetify Manager", "Not applied!")
spicetifyStatusToast(
'Spicetify is not working correctly').on_activated = toast_callback


def toast_callback(activatedEventArgs: ToastActivatedEventArgs):
print('For some f***ing reason this is not working pls help')


# start the app
manager = None
if __name__ == "__main__":
manager = Manager()
manager.run()

0 comments on commit 555b5c2

Please sign in to comment.