-
Notifications
You must be signed in to change notification settings - Fork 5
/
maneki_Neko
executable file
·274 lines (195 loc) · 7.9 KB
/
maneki_Neko
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/usr/bin/env python
import sys
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtWidgets import QMainWindow, QApplication, QDialog
from time import sleep
import os, subprocess
# globals
app = QApplication(sys.argv)
totalPages=3
class welcomeScreen(QMainWindow):
def __init__(self):
# init the class
super(welcomeScreen,self).__init__()
# load the ui file
loadUi("src/ui/welcomeScreen.ui",self)
# always init window to first page
self.windowStackedWidget.setCurrentIndex(0)
# Buttons
self.nextButton.clicked.connect(self.moveForward)
self.backButton.clicked.connect(self.moveBackward)
self.distroInstallerButton.clicked.connect(self.runDistroInstallerScript)
self.changeThemeButton.clicked.connect(self.runThemeChangerScript)
self.browserInstallerButton.clicked.connect(self.runBrowserInstallerScript)
self.openWEBSITEbutton.clicked.connect(self.openWEBSITE_Website)
self.openFORUMbutton.clicked.connect(self.openFORUM_Website)
self.autostartCheckBox.clicked.connect(self.setupAutostart)
self.creditsButton.clicked.connect(self.openCreditsDialog)
return
def disableBackAtFirstPage(self):
currentIndex = self.windowStackedWidget.currentIndex() #current index of the window
# disable back button if at first page
if currentIndex == 0:
self.backButton.setEnabled(False)
return
def moveForward(self):
global totalPages
currentIndex = self.windowStackedWidget.currentIndex() #current index of the window
# if already in last page then exit
if currentIndex+1 == totalPages:
print("Exiting...")
app.exec_()
exit()
# change page by one forward
self.windowStackedWidget.setCurrentIndex(currentIndex+1)
# now enable back button
self.backButton.setEnabled(True)
# morph the button to "Exit" button on last page
currentIndex = self.windowStackedWidget.currentIndex() #updated index of the window
if currentIndex+1 == totalPages:
self.morphNextButton()
return
def moveBackward(self):
currentIndex = self.windowStackedWidget.currentIndex()
# go back until currentIndex is 0
if currentIndex >= 0:
self.windowStackedWidget.setCurrentIndex(currentIndex-1)
# call func to disable back button at first page
self.disableBackAtFirstPage()
# to undo morph (from "Exit" to "Next")
self.morphNextButton()
return
def morphNextButton(self):
currentIndex = self.windowStackedWidget.currentIndex()
# set button label to "Next" as long as it is not on last page
if currentIndex+1 != totalPages:
self.nextButton.setText("Next")
else:
self.nextButton.setText("Exit")
def runDistroInstallerScript(self):
# work need to be done
print("executing the installer script")
# the command to execute
# pls change this
command = ["gnome-terminal", "-e", 'bash -c /home/kali/Desktop/stratOS_welcome/src/scripts/distroInstaller.sh']
temporary = subprocess.Popen(command,stdout=subprocess.PIPE)
# get the STDOUT
result=temporary.communicate()
#print(result)
return
def runThemeChangerScript(self):
# work need to be done
print("executing the installer script")
# the command to execute
# pls change this
command = ["gnome-terminal", "-e", 'bash -c /home/kali/Desktop/stratOS_welcome/src/scripts/themeChanger.sh']
temporary = subprocess.Popen(command,stdout=subprocess.PIPE)
# get the STDOUT
result=temporary.communicate()
#print(result)
return
def runBrowserInstallerScript(self):
# work need to be done
print("executing the installer script")
# the command to execute
# pls change this
command = ["gnome-terminal", "-e", 'bash -c /home/kali/Desktop/stratOS_welcome/src/scripts/browserInstaller.sh']
temporary = subprocess.Popen(command,stdout=subprocess.PIPE)
# get the STDOUT
result=temporary.communicate()
#print(result)
return
def openWEBSITE_Website(self):
# command to open the URL
command = ["xdg-open", "www.stratos-linux.github.io"]
run = subprocess.Popen(command)
print("Opening WEBSITE website on default browser")
return
def openFORUM_Website(self):
# command to open the URL
command = ["xdg-open", "https://forum.stratos-linux.github.io"]
run = subprocess.Popen(command)
print("Opening WEBSITE forum website on default browser")
return
def openCreditsDialog(self):
dialog = creditsWindow()
if dialog.exec_():
return
def setupAutostart(self):
# define home and the full file path
home = os.path.expanduser("~")
filePath = home + "/.config/autostart/maneki_neko.desktop" # full path to desktop file
# create the desktop file and save it in $HOME/.config/autostart when the checkBox is checked
if self.autostartCheckBox.isChecked():
pwd = os.getcwd()
# returns this running script's file name
thisScriptFileName = os.path.basename(__file__)
# opening the file in write mode
with open(filePath,"w") as f:
fileContent=f"""
[Desktop Entry]
Type=Application
Name=Maneki Neko
Exec={pwd}/{thisScriptFileName}
Icon={pwd}/src/png/logo.png
Comment=stratOS welcome screen
X-GNOME-Autostart-enabled=true
Path={pwd}
Terminal=false
StartupNotify=false
"""
f.write(fileContent)
# end of with block
print("setupAutostart():create desktop file:OK")
#make file executable
command = ["chmod", "+x", filePath]
run = subprocess.Popen(command)
print("setupAutostart():make desktop file executable:OK")
print("Maneki Neko autostart Enabled")
# update checkbox text for feedback
self.autostartCheckBox.setText("Autostart Maneki Neko (Enabled)")
else:
try:
os.remove(filePath)
# update checkbox text for feedback
self.autostartCheckBox.setText("Autostart Maneki Neko (Disabled)")
print("Maneki Neko autostart Disabled")
except Exception as E:
print("setupAutostart():remove: desktop file was not found anyway")
self.autostartCheckBox.setText("Autostart Maneki Neko")
return
def main():
global app
print("Program launch OK")
mainScreen = welcomeScreen()
mainScreen.show()
try:
sys.exit(app.exec_())
except:
print("Exiting...")
return
class creditsWindow(QDialog):
def __init__(self):
# init the class and the ui file
super(creditsWindow,self).__init__()
loadUi("src/ui/creditsDialog.ui",self)
self.openBedrockSiteButton.clicked.connect(self.openBedrockWebsite)
self.openGithubRepo.clicked.connect(self.openWEBSITErepo)
return
def openBedrockWebsite(self):
# the command to open the website
command = ['xdg-open', 'https://bedrocklinux.org/']
# run the command
run = subprocess.Popen(command)
print("Opening Bedrock Linux website on default browser.")
return
def openWEBSITErepo(self):
# the command to open the website
command = ['xdg-open', 'https://stratos-linux.github.io']
# run the command
run = subprocess.Popen(command)
print("Opening WEBSITE Github repo on default browser.")
return
if __name__ == "__main__":
main()