From 9da66068dc1f0b254f42062aae82e7014beeda9d Mon Sep 17 00:00:00 2001 From: Nick Price Date: Sat, 11 Jul 2026 17:43:14 -0700 Subject: [PATCH] dbus: do not use the bus in watch_suspend_resume when there is none The guard read if bus is not None and on_resume_callback is not None or on_suspend_callback is not None: which parses as (bus is not None and on_resume_callback is not None) or (on_suspend_callback is not None) so a caller passing on_suspend_callback entered the body regardless of whether the bus exists, and bus.add_signal_receiver() raised AttributeError on None. gtk.py passes both callbacks under --restart-on-wake-up, so that option crashed on any system without a running system dbus. Test the bus separately and return early. The success message was also logged even when no bus was connected. --- lib/solaar/dbus.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/solaar/dbus.py b/lib/solaar/dbus.py index 142b5904..b7145cba 100644 --- a/lib/solaar/dbus.py +++ b/lib/solaar/dbus.py @@ -61,7 +61,9 @@ def watch_suspend_resume( global _resume_callback, _suspend_callback _suspend_callback = on_suspend_callback _resume_callback = on_resume_callback - if bus is not None and on_resume_callback is not None or on_suspend_callback is not None: + if bus is None: + return + if on_resume_callback is not None or on_suspend_callback is not None: bus.add_signal_receiver( _suspend_or_resume, "PrepareForSleep",