@@ -8,7 +8,9 @@ import sys
88import time
99import gettext
1010from setproctitle import setproctitle
11+ from pathlib import Path
1112import psutil
13+ import subprocess
1214import threading
1315import gi
1416import shutil
@@ -53,6 +55,9 @@ class Launcher:
5355 self .fb_pid = 0
5456 self .kill_lock = threading .Lock ()
5557
58+ self .polkit_agent_proc = None
59+ self .nm_applet_proc = None
60+
5661 self .cinnamon_pid = os .fork ()
5762 if self .cinnamon_pid == 0 :
5863 os .execvp ("cinnamon" , ("cinnamon" , "--replace" , ) + tuple (sys .argv [1 :]))
@@ -81,19 +86,52 @@ class Launcher:
8186 else :
8287 self .fb_pid = os .fork ()
8388 if self .fb_pid == 0 :
84- # Start NM applet
85- if shutil .which ("nm-applet" ):
86- os .system ("nm-applet &" )
8789 # Start the fallback panel
8890 if panel_cmd is not None :
8991 os .system (panel_cmd )
9092 # Start the fallback window manager
9193 os .execvp (FALLBACK_COMMAND , (FALLBACK_COMMAND ,) + FALLBACK_ARGS )
9294 else :
95+ self .launch_fallback_helpers ()
9396 self .confirm_restart ()
9497 else :
9598 Gtk .main_quit ()
9699
100+ def launch_fallback_helpers (self ):
101+ agents = ("/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1" ,
102+ "/usr/libexec/polkit-gnome-authentication-agent-1" ,
103+ "/usr/libexec/polkit-mate-authentication-agent-1" )
104+
105+ for path in agents :
106+ if Path (path ).exists ():
107+ print (f"Launching for fallback session: { path } " )
108+ self .polkit_agent_proc = subprocess .Popen ([path ])
109+ break
110+
111+ # Start NM applet
112+ if shutil .which ("nm-applet" ):
113+ print (f"Launching for fallback session: nm-applet" )
114+ self .nm_applet_proc = subprocess .Popen (["nm-applet" ])
115+
116+ def kill_fallback_helpers (self ):
117+ if self .polkit_agent_proc is not None :
118+ print ("Killing fallback polkit agent" )
119+ self .polkit_agent_proc .terminate ()
120+ try :
121+ self .polkit_agent_proc .wait (timeout = 5 )
122+ except subprocess .TimeoutExpired :
123+ self .polkit_agent_proc .kill ()
124+ self .polkit_agent_proc = None
125+
126+ if self .nm_applet_proc is not None :
127+ print ("Killing fallback nm-applet" )
128+ self .nm_applet_proc .terminate ()
129+ try :
130+ self .nm_applet_proc .wait (timeout = 5 )
131+ except subprocess .TimeoutExpired :
132+ self .nm_applet_proc .kill ()
133+ self .nm_applet_proc = None
134+
97135 @async_function
98136 def monitor_memory (self ):
99137 if psutil .pid_exists (self .cinnamon_pid ):
@@ -153,7 +191,7 @@ class Launcher:
153191 if checkbutton .get_active ():
154192 os .environ ["CINNAMON_TROUBLESHOOT" ] = "1"
155193 os .system ("killall %s" % panel_process_name )
156- os . system ( "killall nm-applet" )
194+ self . kill_fallback_helpers ( )
157195 os .system ("kill %d" % self .fb_pid )
158196 os .waitpid (self .fb_pid , 0 )
159197 self .restart_cinnamon ()
0 commit comments