This repository was archived by the owner on Oct 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathUI.py
More file actions
101 lines (87 loc) · 2.82 KB
/
UI.py
File metadata and controls
101 lines (87 loc) · 2.82 KB
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
# AltServer-Linux GUI wrote in PyQT5
# This is the UI part
# Author of the GUI : powen
# import
from Main import *
# check permission
if not os.access(AltServer, os.X_OK):
subprocess.run(f"chmod +x {AltServer}", shell=True)
if not os.access(AutoStart, os.X_OK):
subprocess.run(f"chmod +x {AutoStart}", shell=True)
if not os.access(NetMuxd, os.X_OK):
subprocess.run(f"chmod +x {NetMuxd}", shell=True)
# UI part
app = QApplication(sys.argv)
app.setApplicationName("AltServer")
app.setQuitOnLastWindowClosed(False)
# Create the icon
icon = QIcon(resource_path("MenuBar.png"))
app.setWindowIcon(QIcon(resource_path("AppIcon.png")))
# Create the tray
tray = QSystemTrayIcon()
tray.setIcon(icon)
tray.setVisible(True)
# Create the menu
menu = QMenu()
About = QAction("About AltServer")
About.triggered.connect(about_message)
menu.addAction(About)
menu.addSeparator()
# Add Inatall AltStore option to the menu.
AltInstall = QAction('Install AltStore')
AltInstall.triggered.connect(Installation)
menu.addAction(AltInstall)
menu.addSeparator()
# Add Launch At Login in option to the menu.
LaunchAtLogin = QAction("Launch at Login",checkable=True)
launch_enable=False
CheckTime=0
if glob.glob("/home/*/.config/autostart/AltServer.desktop") and CheckTime==0:
LaunchAtLogin.setChecked(True)
launch_enable=True
CheckTime=1
if not glob.glob("/home/*/.config/autostart/AltServer.desktop") and CheckTime==0:
LaunchAtLogin.setChecked(False)
launch_enable=False
CheckTime=1
def launch_config() :
if LaunchAtLogin.isChecked():
launch_enable=True
if not LaunchAtLogin.isChecked():
launch_enable=False
if launch_enable :
LaunchAtLogin.setChecked(True)
subprocess.run(resource_path("AutoStart.sh"),shell=True)
if not launch_enable :
LaunchAtLogin.setChecked(False)
subprocess.run("rm -rf /home/*/.config/autostart/AltServer.desktop",shell=True)
LaunchAtLogin.toggled.connect(launch_config)
menu.addAction(LaunchAtLogin)
# Add Pair in option to the menu.
Pair = QAction("Pair")
menu.addAction(Pair)
Pair.triggered.connect(pair)
# Add Restart Daemon in option to the menu.
RestartDaemon = QAction("Restart AltDaemon")
menu.addAction(RestartDaemon)
RestartDaemon.triggered.connect(restart_daemon)
menu.addSeparator()
# Add Check Update option to the menu.
CheckUpdate = QAction("Check for Update")
CheckUpdate.triggered.connect(check_update)
menu.addAction(CheckUpdate)
menu.addSeparator()
# Add a Quit option to the menu.
def app_quit():
subprocess.run(f'killall {AltServer}',shell=True)
app.quit()
quit = QAction("Quit AltServer")
quit.triggered.connect(app_quit)
quit.setCheckable(False)
quit.setShortcut('Ctrl+Q')
menu.addAction(quit)
# Add the menu to the tray
tray.setContextMenu(menu)
subprocess.run(f'{AltServer} &> /dev/null &',shell=True)
UpdateNotification()
app.exec_()