Skip to content

Commit d46cb62

Browse files
committed
cs_power.py: Discover suspend/hibernate capabilities from cinnamon-
session. This is what our logout dialog uses, and the capabilities should match. The session manager is already checking with the active login manager (systemd or consolekit). Ref: #13219
1 parent 2b70b6b commit d46cb62

File tree

1 file changed

+13
-34
lines changed
  • files/usr/share/cinnamon/cinnamon-settings/modules

1 file changed

+13
-34
lines changed

files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def on_module_selected(self):
148148

149149
section = power_page.add_section(_("Power options"))
150150

151-
lid_options, button_power_options, critical_options, can_suspend, can_hybrid_sleep, can_hibernate = get_available_options(self.up_client)
151+
lid_options, button_power_options, critical_options, can_suspend, can_hybrid_sleep, can_hibernate = get_available_options()
152152

153153
size_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
154154

@@ -577,44 +577,23 @@ def on_alias_changed(self, entry, event, device_id):
577577
self.settings.set_strv("device-aliases", aliases)
578578

579579

580-
def get_available_options(up_client):
580+
def get_available_options():
581581
can_suspend = False
582582
can_hibernate = False
583583
can_hybrid_sleep = False
584584

585-
# Try logind first
585+
# There's no reason this should ever fail as a normal user
586586
try:
587-
connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
588-
proxy = Gio.DBusProxy.new_sync(
589-
connection,
590-
Gio.DBusProxyFlags.NONE,
591-
None,
592-
"org.freedesktop.login1",
593-
"/org/freedesktop/login1",
594-
"org.freedesktop.login1.Manager",
595-
None)
596-
597-
can_suspend = proxy.CanSuspend() == "yes"
598-
can_hibernate = proxy.CanHibernate() == "yes"
599-
can_hybrid_sleep = proxy.CanHybridSleep() == "yes"
600-
except:
601-
pass
602-
603-
# Next try ConsoleKit
604-
try:
605-
connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
606-
proxy = Gio.DBusProxy.new_sync(
607-
connection,
608-
Gio.DBusProxyFlags.NONE,
609-
None,
610-
"org.freedesktop.ConsoleKit",
611-
"/org/freedesktop/ConsoleKit/Manager",
612-
"org.freedesktop.ConsoleKit.Manager",
613-
None)
614-
615-
can_suspend = can_suspend or (proxy.CanSuspend() == "yes")
616-
can_hibernate = can_hibernate or (proxy.CanHybridSleep() == "yes")
617-
can_hybrid_sleep = can_hybrid_sleep or (proxy.CanHybridSleep() == "yes")
587+
proxy = Gio.DBusProxy.new_for_bus_sync(
588+
Gio.BusType.SESSION,
589+
Gio.DBusProxyFlags.NONE,
590+
None,
591+
"org.gnome.SessionManager",
592+
"/org/gnome/SessionManager",
593+
"org.cinnamon.SessionManager.EndSessionDialog",
594+
None)
595+
596+
__, __, __, can_hybrid_sleep, can_suspend, can_hibernate, __ = proxy.GetCapabilities()
618597
except:
619598
pass
620599

0 commit comments

Comments
 (0)