Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Commit 4a1ab71

Browse files
committed
New status checking system
1 parent 328d901 commit 4a1ab71

File tree

4 files changed

+118
-101
lines changed

4 files changed

+118
-101
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Contributers wellcome!
2222
- [x] Custom cli commands
2323
- [ ] Automatically update spicetify and apply patches after spotify update
2424

25-
## Installation and Running
25+
Currently Windows only!
26+
If would like to improve support for other Platforms feel free to do so!
27+
## Installation and Running
2628

2729
Download project from Github and install dependencies
2830

components/shellbridge.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ def run(self):
4242
subprocess.run('spicetify upgrade')
4343
subprocess.run('spicetify update')
4444
self.finished_signal.emit()
45+
46+
# Apply task
47+
class ApplySpicetify(QThread):
48+
finished_signal = pyqtSignal()
49+
def run(self):
50+
print("Apply started")
51+
subprocess.check_output('spicetify apply')
52+
self.finished_signal.emit()
4553
# Uninstaller task
4654
class UninstallSpicetify(QThread):
4755
finished_signal = pyqtSignal()

manager_window.py

Lines changed: 105 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
from PyQt6.QtWidgets import QMainWindow
88
from PyQt6.QtCore import Qt
99
from PyQt6.uic import loadUi
10+
from PyQt6.QtGui import QDesktopServices
1011
from components.popups import errorDialog, infoDialog, windowsNotification
11-
from components.shellbridge import InstallSpicetify, UpdateSpicetify, UninstallSpicetify, CustomCommand, getLatestRelease,checkApplied,blockSpotifyUpdate
12+
from components.shellbridge import InstallSpicetify, UpdateSpicetify, ApplySpicetify, UninstallSpicetify, CustomCommand, getLatestRelease,checkApplied,blockSpotifyUpdate
1213

1314
from components.afterinstall_popup import Popup
1415

@@ -17,12 +18,13 @@ class Manager(QMainWindow):
1718
#Setup click listeners and load ui and do initial setup
1819
def __init__(self):
1920
super().__init__()
20-
self.installmode = True
21+
2122
self.isSpotifyInstalled = False
2223
self.isSpicetifyInstalled = False
2324
self.isApplied = False
2425
self.isBackedUp = False
2526
self.isActive = False
27+
self.managermode = 0
2628

2729
self.LOCALSPOTIFYVER = ''
2830
self.LATESTSPOTIFYVER = ''
@@ -35,7 +37,7 @@ def __init__(self):
3537

3638
self.InitWindow()
3739

38-
self.bt_install.clicked.connect(self.startInstaller)
40+
self.bt_master.clicked.connect(self.masterButton)
3941
self.bt_update.clicked.connect(self.startUpdate)
4042
self.bt_uninstall.clicked.connect(self.startRemoval)
4143
self.bt_cmd.clicked.connect(self.Custom)
@@ -45,7 +47,6 @@ def __init__(self):
4547
# Execute once window is loaded before listeners are enabled
4648
def InitWindow(self):
4749
self.SystemSoftStatusCheck()
48-
self.checkSpicetify()
4950

5051
#Update user about progress while installing spicetify
5152
def progressmaster(self, action):
@@ -58,40 +59,64 @@ def progressmaster(self, action):
5859
self.l_status.setText(action)
5960
self.l_versioninfo.setText("This process may take a few minutes!")
6061

61-
# Launch installer task
62-
def startInstaller(self):
63-
self.setCursor(Qt.CursorShape.WaitCursor)
64-
self.bt_install.setEnabled(False)
65-
self.bt_update.setEnabled(False)
66-
self.bt_uninstall.setEnabled(False)
67-
self.iprocess = InstallSpicetify()
68-
self.iprocess.finished_signal.connect(self.setup_finished)
69-
self.iprocess.progress_signal.connect(self.progressmaster)
70-
self.iprocess.start()
71-
def launchSpotify(self):
72-
os.startfile(os.path.join( os.path.expanduser('~'), 'AppData','Roaming/Spotify/Spotify.exe'))
73-
# Applies spicetify
74-
def activateSpicetify(self):
75-
subprocess.check_output('spicetify apply')
76-
self.checkSpicetify()
62+
63+
# Launch installer task !WIP
64+
def masterButton(self):
65+
if self.managermode == 0:
66+
os.startfile(os.path.join( os.path.expanduser('~'), 'AppData','Roaming/Spotify/Spotify.exe'))
67+
self.SystemSoftStatusCheck()
68+
if self.managermode == 1:
69+
QDesktopServices.openUrl('https://download.scdn.co/SpotifySetup.exe')
70+
self.SystemSoftStatusCheck()
71+
elif self.managermode == 2:
72+
self.setCursor(Qt.CursorShape.WaitCursor)
73+
self.bt_master.setEnabled(False)
74+
self.bt_update.setEnabled(False)
75+
self.bt_uninstall.setEnabled(False)
76+
self.l_status.setText("Installling Spicetify...")
77+
self.iprocess = InstallSpicetify()
78+
self.iprocess.finished_signal.connect(self.setup_finished)
79+
self.iprocess.progress_signal.connect(self.progressmaster)
80+
self.iprocess.start()
81+
elif self.managermode == 3:
82+
self.setCursor(Qt.CursorShape.WaitCursor)
83+
self.bt_master.setEnabled(False)
84+
self.bt_update.setEnabled(False)
85+
self.bt_uninstall.setEnabled(False)
86+
self.l_status.setText("Running apply")
87+
self.iprocess = ApplySpicetify()
88+
self.iprocess.finished_signal.connect(self.apply_finished)
89+
self.iprocess.start()
90+
elif self.managermode == 4:
91+
killpath1 = os.path.join(os.path.join( os.path.expanduser('~'), 'AppData','Roaming'), 'Spotify', 'Apps', 'login.spa')
92+
killpath2 = os.path.join(os.path.join( os.path.expanduser('~'), 'AppData','Roaming'), 'Spotify', 'Apps', 'xpui.spa')
93+
os.remove(killpath1)
94+
os.remove(killpath2)
95+
self.SystemSoftStatusCheck()
96+
else:
97+
print("Error selection overshoot!")
98+
99+
77100
# Launch uninstaller task
78101
def startRemoval(self):
79102
self.setCursor(Qt.CursorShape.WaitCursor)
80103
self.bt_uninstall.setEnabled(False)
81104
self.bt_update.setEnabled(False)
82-
self.bt_install.setEnabled(False)
105+
self.bt_master.setEnabled(False)
83106
self.l_status.setStyleSheet("color: Orange")
84107
self.l_status.setText("Uninstalling Spicetify...")
85108
self.iprocess = UninstallSpicetify()
86109
self.iprocess.finished_signal.connect(self.uninstall_finished)
87110
self.iprocess.start()
111+
112+
88113
# Launch updater task
89114
def startUpdate(self):
90115
try:
91116
self.setCursor(Qt.CursorShape.WaitCursor)
92117
self.bt_update.setEnabled(False)
93118
self.bt_uninstall.setEnabled(False)
94-
self.bt_install.setEnabled(False)
119+
self.bt_master.setEnabled(False)
95120
self.l_status.setStyleSheet("color: Orange")
96121
self.l_status.setText("Checking for updates...")
97122
localversion = subprocess.check_output('spicetify --version',shell=True).decode("utf-8").strip()
@@ -102,7 +127,7 @@ def startUpdate(self):
102127
self.setCursor(Qt.CursorShape.ArrowCursor)
103128
self.bt_update.setEnabled(True)
104129
self.bt_uninstall.setEnabled(True)
105-
self.bt_install.setEnabled(True)
130+
self.bt_master.setEnabled(True)
106131
else:
107132
self.l_status.setStyleSheet("color: Orange")
108133
self.l_status.setText("Updating...")
@@ -117,89 +142,46 @@ def Custom(self):
117142
self.iprocess = CustomCommand(self.combo_cmd.currentIndex())
118143
self.iprocess.finished_signal.connect(self.uninstall_finished)
119144
self.iprocess.start()
145+
146+
120147
# Disables Spotify self update function using permissions
121148
def DisableUpdate(self):
122149
if not (blockSpotifyUpdate(self.check_noupdate.isChecked())):
123-
infoDialog("Success", " The process has finished !")
150+
windowsNotification("Spicetify Manager", "Update supression failed!")
124151
else:
125-
errorDialog("The process has failed ! You might need to remove the Update folder from Spotify manually.")
152+
windowsNotification("Spicetify Manager", "Update supression activated!")
126153

127154

128155
#Called when spicetify is installed or not?
129156
def setup_finished(self):
130-
self.checkSpicetify()
157+
self.SystemSoftStatusCheck()
131158
dialog = Popup(self)
132159
dialog.exec()
160+
windowsNotification("Spicetify Manager", "Spicetify has been installed!")
161+
#Called when spicetify is applied
162+
def apply_finished(self):
163+
self.SystemSoftStatusCheck()
164+
windowsNotification("Spicetify Manager", "Spicetify has been applied!")
133165
#Called when spicetify is updated
134166
def update_finished(self):
135-
self.checkSpicetify()
167+
self.SystemSoftStatusCheck()
168+
windowsNotification("Spicetify Manager", "Spicetify has been updated!")
136169
#Called when spicetify is uninstalled
137170
def uninstall_finished(self):
138-
self.checkSpicetify()
171+
self.SystemSoftStatusCheck()
172+
windowsNotification("Spicetify Manager", "Spicetify has been uninstalled!")
139173

140-
# Check if spicetify is installed and applied (mainly ui work)
141-
def checkSpicetify(self):
142-
try:
143-
self.setCursor(Qt.CursorShape.ArrowCursor)
144-
folder_path = os.path.join(os.path.join( os.path.expanduser('~'), 'AppData','Local'), 'spicetify')
145-
if os.path.exists(folder_path) and os.path.isdir(folder_path):
146-
if not checkApplied():
147-
self.l_status.setText("Spicetify is not activated yet")
148-
self.l_status.setStyleSheet("color: orange")
149-
self.l_versioninfo.setText('Please press activate to apply any modifications')
150-
self.bt_uninstall.setEnabled(True)
151-
self.bt_update.setEnabled(True)
152-
self.bt_install.setEnabled(True)
153-
if self.installmode:
154-
self.installmode = False
155-
self.bt_install.setText("Activate")
156-
self.bt_install.clicked.disconnect(self.startInstaller)
157-
else:
158-
self.bt_install.clicked.disconnect(self.launchSpotify)
159-
self.bt_install.clicked.connect(self.activateSpicetify)
160-
else:
161-
self.l_status.setText("Spotify is spiced up!")
162-
self.l_status.setStyleSheet("color: green")
163-
versionoutput = subprocess.check_output('spicetify --version',shell=True)
164-
self.l_versioninfo.setText('Version: '+versionoutput.decode("utf-8"))
165-
self.bt_uninstall.setEnabled(True)
166-
self.bt_update.setEnabled(True)
167-
self.bt_install.setEnabled(True)
168-
if self.installmode:
169-
self.installmode = False
170-
self.bt_install.setText("Launch Spotify")
171-
self.bt_install.clicked.disconnect(self.startInstaller)
172-
self.bt_install.clicked.connect(self.launchSpotify)
173-
else:
174-
self.l_status.setText("Spicetify is not installed")
175-
self.l_status.setStyleSheet("color: red")
176-
self.l_versioninfo.setText("")
177-
self.bt_uninstall.setEnabled(False)
178-
self.bt_update.setEnabled(False)
179-
self.bt_install.setEnabled(True)
180-
if not self.installmode:
181-
self.installmode = True
182-
self.bt_install.setText("Install")
183-
self.bt_install.clicked.disconnect(self.launchSpotify)
184-
self.bt_install.clicked.connect(self.startInstaller)
185-
except Exception as e:
186-
print("E: Error while checking Spicetify!")
187-
print(e)
188-
self.l_status.setText("Spicetify is not installed")
189-
190-
# Spicetify status check (NEW attempt)
174+
# Spicetify status check V2
191175
def SystemSoftStatusCheck(self):
192176
spotipath = os.path.join(os.path.join( os.path.expanduser('~'), 'AppData','Roaming'), 'Spotify', 'Spotify.exe')
193177
if os.path.exists(spotipath):
194178
self.isSpotifyInstalled = True
195-
windowsNotification("Spicetify Manager", "Spicetify is installed!")
196179
else:
197180
self.isSpotifyInstalled = False
198181

199-
# maybe also check executable in local appdata
200-
spicypath1 = os.path.join(os.path.join( os.path.expanduser('~'), 'AppData','Local'), 'spicetify')
201-
spicypath2 = os.path.join(os.path.join( os.path.expanduser('~'), 'AppData','Roaming'), 'Spotify')
202-
if os.path.exists(spicypath1) and os.path.isdir(spicypath2):
182+
# maybe (also) check executable in local appdata
183+
spicypath = os.path.join(os.path.join( os.path.expanduser('~'), 'AppData','Local'), 'spicetify', 'spicetify.exe')
184+
if os.path.exists(spicypath):
203185
self.isSpicetifyInstalled = True
204186
self.LOCALSPICETIFYVER = subprocess.check_output('spicetify --version',shell=True).decode("utf-8").strip()
205187
else:
@@ -218,21 +200,46 @@ def SystemSoftStatusCheck(self):
218200
self.isActive = False
219201
else:
220202
self.isActive = True
221-
222203

223-
204+
self.installerUiUpdate()
205+
224206
def installerUiUpdate(self):
207+
self.setCursor(Qt.CursorShape.ArrowCursor)
208+
self.bt_update.setEnabled(True)
209+
self.bt_uninstall.setEnabled(True)
210+
self.bt_master.setEnabled(True)
225211
if(self.isSpotifyInstalled):
226-
pass
227-
else:
228-
pass
229-
230-
if(self.isSpicetifyInstalled):
231-
pass
232-
else:
233-
pass
234-
235-
if(self.isActive):
236-
pass
212+
if(self.isSpicetifyInstalled):
213+
if(self.isApplied):
214+
if(self.isActive):
215+
#Implement update checker here
216+
self.l_status.setText("Spotify is spiced up!")
217+
self.l_status.setStyleSheet("color: lime")
218+
self.bt_master.setText("Launch Spotify")
219+
self.l_versioninfo.setText('Version: '+self.LOCALSPICETIFYVER)
220+
self.managermode = 0
221+
else:
222+
self.l_status.setText("Spicetify is inactive")
223+
self.l_status.setStyleSheet("color: yellow")
224+
self.l_versioninfo.setText('Press activate to activate Spicetify')
225+
self.bt_master.setText("Activate")
226+
self.managermode = 4
227+
else:
228+
self.l_status.setText("Spicetify is not applied yet")
229+
self.l_status.setStyleSheet("color: orange")
230+
self.l_versioninfo.setText('Press apply to enable modifications')
231+
self.bt_master.setText("Apply")
232+
self.managermode = 3
233+
else:
234+
self.l_status.setText("Spicetify is not installed")
235+
self.l_status.setStyleSheet("color: White")
236+
self.l_versioninfo.setText('Press install to start the process')
237+
#self.l_versioninfo.setText('Latest version: '+self.LATESTSPICETIFYVER)
238+
self.bt_master.setText("Install")
239+
self.managermode = 2
237240
else:
238-
pass
241+
self.l_status.setText("Spotify is not installed")
242+
self.l_status.setStyleSheet("color: red")
243+
self.l_versioninfo.setText('Download Spotify from the official website')
244+
self.bt_master.setText("Download")
245+
self.managermode = 1

res/manager.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ QPushButton:pressed
279279
<enum>QTabWidget::North</enum>
280280
</property>
281281
<property name="currentIndex">
282-
<number>1</number>
282+
<number>0</number>
283283
</property>
284284
<widget class="QWidget" name="tab_1">
285285
<property name="styleSheet">
@@ -292,7 +292,7 @@ QPushButton:pressed
292292
<attribute name="title">
293293
<string>Simple</string>
294294
</attribute>
295-
<widget class="QPushButton" name="bt_install">
295+
<widget class="QPushButton" name="bt_master">
296296
<property name="enabled">
297297
<bool>true</bool>
298298
</property>

0 commit comments

Comments
 (0)