@@ -64,7 +64,10 @@ def __init__(self):
6464 parser .add_argument ("--no-prompt" , dest = "no_prompt" , action = 'store_true' ,
6565 help = _ ("Don't prompt for user confirmation" ))
6666 parser .add_argument ("--sm-owned" , action = "store_true" , help = argparse .SUPPRESS )
67- parser .add_argument ("--sm-bus-id" , dest = "bus_id" , action = "store" , help = argparse .SUPPRESS , default = config .DBUS_ADDRESS )
67+
68+ # unused in 6.4+, kept only for upgrade session (running c-s process is previous version, dialog is new)
69+ parser .add_argument ("--sm-bus-id" , dest = "bus_id" , action = "store" , help = argparse .SUPPRESS , default = None )
70+
6871 args = parser .parse_args ()
6972
7073 self .dialog_response = ResponseCode .NONE
@@ -76,11 +79,7 @@ def __init__(self):
7679 self .force = args .force
7780 self .no_prompt = args .no_prompt
7881 self .sm_owned = args .sm_owned
79-
80- if self .sm_owned :
81- self .bus_id = args .bus_id
82- else :
83- self .bus_id = None
82+ self .bus_id = args .bus_id
8483
8584 self .proxy = None
8685 self .signal_handler_id = 0
@@ -118,7 +117,7 @@ def async_cb(proxy, res):
118117 proxy .call_finish (res )
119118 # self.quit()
120119 except GLib .Error as e :
121- print ("An error occurred forwarding to the session manager: %s" % e .message )
120+ print ("An error occurred forwarding to the session manager: %s" % e .message , file = sys . stderr , end = None )
122121
123122 if self .mode == Action .LOGOUT :
124123 arg = LogoutParams .NORMAL
@@ -156,7 +155,7 @@ def async_cb(proxy, res):
156155 )
157156 except GLib .Error as e :
158157 if sm_proxy is None :
159- print ("Could not forward to org.cinnamon.SessionManager.Manager: %s" % e .message )
158+ print ("Could not forward to org.cinnamon.SessionManager.Manager: %s" % e .message , file = sys . stderr , end = None )
160159 sys .exit (1 )
161160
162161 sys .exit (0 )
@@ -169,40 +168,52 @@ def setup_proxy(self):
169168 connection = None
170169
171170 try :
172- connection = Gio .DBusConnection .new_for_address_sync (
173- self .bus_id ,
174- Gio .DBusConnectionFlags .AUTHENTICATION_CLIENT ,
175- None , None
176- )
171+ # 6.4 and later this will always be None, obsolete connection
172+ if self .bus_id is not None :
173+ connection = Gio .DBusConnection .new_for_address_sync (
174+ self .bus_id ,
175+ Gio .DBusConnectionFlags .AUTHENTICATION_CLIENT ,
176+ None , None
177+ )
177178
178- self .proxy = Gio .DBusProxy .new_sync (
179- connection ,
180- Gio .DBusProxyFlags .DO_NOT_AUTO_START ,
181- None ,
182- None ,
183- "/org/gnome/SessionManager" ,
184- "org.cinnamon.SessionManager.DialogPrivate" ,
185- None
186- )
179+ self .proxy = Gio .DBusProxy .new_sync (
180+ connection ,
181+ Gio .DBusProxyFlags .DO_NOT_AUTO_START ,
182+ None ,
183+ None ,
184+ "/org/gnome/SessionManager" ,
185+ "org.cinnamon.SessionManager.DialogPrivate" ,
186+ None
187+ )
188+ else :
189+ self .proxy = Gio .DBusProxy .new_for_bus_sync (
190+ Gio .BusType .SESSION ,
191+ Gio .DBusProxyFlags .DO_NOT_AUTO_START ,
192+ None ,
193+ "org.gnome.SessionManager" ,
194+ "/org/gnome/SessionManager" ,
195+ "org.cinnamon.SessionManager.EndSessionDialog" ,
196+ None
197+ )
187198
188199 self .proxy .connect ("g-signal" , self .inhibitor_info_received )
189200
190201 except GLib .Error as e :
191202 if connection is None :
192- print ("Could not connect to session dialog server: %s" % e .message )
203+ print ("Could not connect to session dialog server: %s" % e .message , file = sys . stderr , end = None )
193204 sys .exit (1 )
194205 if self .proxy is None :
195- print ("Could not create proxy to session dialog interface: %s" % e .message )
206+ print ("Could not create proxy to session dialog interface: %s" % e .message , file = sys . stderr , end = None )
196207 sys .exit (1 )
197208
198209 def inhibitor_info_received (self , proxy , sender , signal , params ):
199210 inhibitors = params [0 ]
200211
201212 if self .dialog_response == ResponseCode .NONE :
202- print ("Ignoring inhibitor info, still waiting on initial response from user" )
213+ print ("Ignoring inhibitor info, still waiting on initial response from user" , file = sys . stderr , end = None )
203214 return
204215
205- print ("Inhibitor info received (%d inhibitors)" % len (inhibitors ))
216+ print ("Inhibitor info received (%d inhibitors): %s " % ( len (inhibitors ), params ), file = sys . stderr , end = None )
206217
207218 if inhibitors :
208219 self .inhibited = True
@@ -243,8 +254,10 @@ def run_dialog(self):
243254 self .view_stack = self .builder .get_object ("view_stack" )
244255 self .inhibitor_treeview = self .builder .get_object ("inhibitor_treeview" )
245256
246- can_switch_user , can_stop , can_restart , can_hybrid_sleep , can_suspend , can_hibernate , can_logout = self .get_session_capabilities ()
247-
257+ try :
258+ can_switch_user , can_stop , can_restart , can_hybrid_sleep , can_suspend , can_hibernate , can_logout = self .get_session_capabilities ()
259+ except Exception as e :
260+ print (e , file = sys .stderr , end = None )
248261 default_button = None
249262
250263 if self .mode == Action .LOGOUT :
@@ -265,7 +278,7 @@ def run_dialog(self):
265278 self .window .set_icon_name ("system-shutdown" )
266279 elif self .mode == Action .RESTART :
267280 if not can_restart :
268- print ("Restart not available" )
281+ print ("Restart not available" , file = sys . stderr , end = None )
269282 Gtk .main_quit ()
270283 return
271284 self .dialog_label .set_text (_ ("Restart this system now?" ))
@@ -304,7 +317,7 @@ def get_session_capabilities(self):
304317 )
305318 return caps [0 ]
306319 except GLib .Error as e :
307- print ("Could not retrieve session capabilities: %s" % e .message )
320+ print ("Could not retrieve session capabilities: %s" % e .message , file = sys . stderr , end = None )
308321
309322 def start_timer (self ):
310323 if self .timer_id > 0 :
@@ -315,6 +328,11 @@ def start_timer(self):
315328 self .update_timer ()
316329 GLib .timeout_add (1000 , self .update_timer )
317330
331+ def stop_timer (self ):
332+ if self .timer_id > 0 :
333+ GLib .source_remove (self .timer_id )
334+ self .timer_id = 0
335+
318336 def update_timer (self ):
319337 if self .current_time == 0 :
320338 self .handle_response (self .window , self .default_response )
@@ -347,15 +365,17 @@ def update_timer(self):
347365 return GLib .SOURCE_CONTINUE
348366
349367 def handle_response (self , dialog , code ):
368+ self .stop_timer ()
369+
350370 self .view_stack .set_visible_child_name ("busy" )
351371
352372 if self .inhibited :
353373 if code == ResponseCode .CONTINUE :
354- print ("Sending ignore inhibitors" )
374+ print ("Sending ignore inhibitors" , file = sys . stderr , end = None )
355375 self .send_command ("IgnoreInhibitors" )
356376 self .finish_up ()
357377 elif code in (ResponseCode .CANCEL , Gtk .ResponseType .NONE , Gtk .ResponseType .DELETE_EVENT ):
358- print ("Canceling action during inhibit phase" )
378+ print ("Canceling action during inhibit phase" , file = sys . stderr , end = None )
359379 self .send_command ("Cancel" )
360380 self .quit ()
361381 return
@@ -378,7 +398,7 @@ def handle_response(self, dialog, code):
378398 self .send_command ("Cancel" )
379399 self .quit (0 )
380400 else :
381- print ("Invalid response code: %d" % code )
401+ print ("Invalid response code: %d" % code , file = sys . stderr , end = None )
382402
383403 def send_command (self , command ):
384404 try :
@@ -391,7 +411,7 @@ def send_command(self, command):
391411 None
392412 )
393413 except GLib .Error as e :
394- print ("Could not send command '%s' to session manager: %s" % (str (command ), e .message ))
414+ print ("Could not send command '%s' to session manager: %s" % (str (command ), e .message ), file = sys . stderr , end = None )
395415
396416 self .command_sent = True
397417 # wait for inhibit info
@@ -409,7 +429,7 @@ def show_inhibit_view(self, info):
409429 self .view_stack .set_visible_child_name ("inhibit" )
410430
411431 def on_terminate (self , data = None ):
412- print ("Received SIGTERM from cinnamon-session, exiting" )
432+ print ("Received SIGTERM from cinnamon-session, exiting" , file = sys . stderr , end = None )
413433 self .quit (0 )
414434
415435 def finish_up (self ):
0 commit comments