55from PySide6 .QtWidgets import QMessageBox
66from PySide6 .QtCore import QTimer
77from utils import get_text , logging
8-
98running_processes = []
109last_launch_times = {}
11-
1210apps = {
1311 'steam' : {'command' : ['flatpak' , 'run' , 'com.valvesoftware.Steam' , '-gamepadui' ], 'flatpak' : True , 'requires_internet' : True , 'title_name' : 'Steam' },
1412 'heroic' : {'command' : ['flatpak' , 'run' , 'com.heroicgameslauncher.hgl' ], 'flatpak' : True , 'requires_internet' : True , 'title_name' : 'Heroic Games Launcher' },
1513 'hyperplay' : {'command' : ['flatpak' , 'run' , 'xyz.hyperplay.HyperPlay' ], 'flatpak' : True , 'requires_internet' : True , 'title_name' : 'HyperPlay' },
1614 'lutris' : {'command' : ['lutris' ], 'flatpak' : False , 'requires_internet' : False , 'title_name' : 'Lutris' }
1715}
18-
1916def check_app_installed (command , app_name ):
2017 try :
2118 if 'flatpak' in command :
@@ -38,7 +35,6 @@ def check_app_installed(command, app_name):
3835 logging .error (f'Error checking if { app_name } is installed: { e } ' )
3936 QMessageBox .warning (None , "Warning" , get_text ('app_not_installed' , {'app' : app_name }))
4037 return False
41-
4238def check_internet ():
4339 try :
4440 result = subprocess .run (['nmcli' , 'networking' , 'connectivity' ], capture_output = True , text = True )
@@ -49,7 +45,6 @@ def check_internet():
4945 except Exception as e :
5046 logging .error (f'Error checking internet: { e } ' )
5147 return False
52-
5348def set_fullscreen (app_name , title_name , retries = 3 , delay = 3 ):
5449 for i in range (retries ):
5550 try :
@@ -61,15 +56,7 @@ def set_fullscreen(app_name, title_name, retries=3, delay=3):
6156 time .sleep (delay )
6257 logging .error (f'Failed to set fullscreen for { app_name } after { retries } attempts' )
6358 return False
64-
6559def launch_app (app_name , main_window ):
66- if app_name == 'steam' :
67- logging .info ('Launching Steam with gamescope-session-plus and closing application' )
68- main_window .close ()
69- subprocess .Popen (['gamescope-session-plus' , 'steam' ])
70- sys .exit (0 )
71- return
72-
7360 current_time = time .time ()
7461 last_launch = last_launch_times .get (app_name , 0 )
7562 cooldown = 60
@@ -78,20 +65,16 @@ def launch_app(app_name, main_window):
7865 QMessageBox .warning (None , "Warning" , get_text ('launch_cooldown' , {'seconds' : remaining , 'app' : app_name }))
7966 logging .info (f'Launch blocked for { app_name } due to cooldown: { remaining } s' )
8067 return
81-
8268 app = apps .get (app_name )
8369 if not app :
8470 logging .error (f'Unknown app: { app_name } ' )
8571 return
86-
8772 if not check_app_installed (app ['command' ], app_name ):
8873 return
89-
9074 if app ['requires_internet' ] and not check_internet ():
9175 QMessageBox .warning (None , "Warning" , get_text ('no_internet' ))
9276 logging .error (f'No internet for { app_name } ' )
9377 return
94-
9578 main_window .hide ()
9679 logging .info (f'Launching { app_name } ' )
9780 env = os .environ .copy ()
@@ -100,7 +83,6 @@ def launch_app(app_name, main_window):
10083 running_processes .append ((app_name , proc ))
10184 last_launch_times [app_name ] = current_time
10285 QTimer .singleShot (3000 , lambda : set_fullscreen (app_name , app ['title_name' ]))
103-
10486 def check_process ():
10587 if proc .poll () is not None :
10688 logging .info (f'{ app_name } closed' )
@@ -112,17 +94,14 @@ def check_process():
11294 logging .error (f'Error restoring fullscreen for Hacker Mode: { err } ' )
11395 return
11496 QTimer .singleShot (1000 , check_process )
115-
11697 QTimer .singleShot (1000 , check_process )
117-
11898def system_action (action , main_window = None ):
11999 actions = {
120- 'switchToPlasma' : lambda : (logging .info ('Switching to Plasma' ), subprocess .run (['startplasma-wayland ' ]), main_window .close () if main_window else None ),
100+ 'switchToPlasma' : lambda : (logging .info ('Switching to Plasma' ), subprocess .run (['/usr/share/HackerOS/Scripts/Bin/revert_to_plasma.sh ' ]), main_window .close () if main_window else None ),
121101 'shutdown' : lambda : (logging .info ('Shutting down' ), subprocess .run (['systemctl' , 'poweroff' ])),
122102 'restart' : lambda : (logging .info ('Restarting' ), subprocess .run (['systemctl' , 'reboot' ])),
123103 'sleep' : lambda : (logging .info ('Suspending' ), subprocess .run (['systemctl' , 'suspend' ])),
124- 'restartApps' : lambda : (logging .info ('Restarting apps' ), [subprocess .run (['pkill' , '-f' , app ]) for app in ['steam' , 'heroic' , 'hyperplay' , 'lutris' ]], running_processes .clear (), main_window .show () if main_window else None , subprocess .run (['wf-shell' , 'fullscreen' , 'enable' ])),
125- 'restartWayfire' : lambda : (logging .info ('Restarting Wayfire' ), subprocess .run (['wayfire' , '-c' , os .path .expanduser ('~/.config/wayfire.ini' ), '--replace' ]))
104+ 'restartApps' : lambda : (logging .info ('Restarting apps' ), [subprocess .run (['pkill' , '-f' , app ]) for app in ['steam' , 'heroic' , 'hyperplay' , 'lutris' ]], running_processes .clear (), main_window .show () if main_window else None , subprocess .run (['wf-shell' , 'fullscreen' , 'enable' ]))
126105 }
127106 func = actions .get (action )
128107 if func :
0 commit comments