chiark / gitweb /
Prep v239: Add support for the new 'suspend-then-hibernate' method.
[elogind.git] / src / shared / sleep-config.c
index 3cb917358c6ea214c5aa5ef3019b8e1a00babb53..1d7d46ac110762132c56677b2b4b71642952c71f 100644 (file)
@@ -378,11 +378,19 @@ static bool can_s2h(Manager *m) {
 
 #if 0 /// elogind has to ask the manager for some stuff
 int can_sleep(const char *verb) {
+        _cleanup_strv_free_ char **modes = NULL, **states = NULL;
+        int r;
 #else
 int can_sleep(Manager *m, const char *verb) {
+        assert(m);
+
+        char **modes  = streq(verb, "suspend")   ? m->suspend_mode     :
+                        streq(verb, "hibernate") ? m->hibernate_mode   :
+                                                       m->hybrid_sleep_mode;
+        char **states = streq(verb, "suspend")   ? m->suspend_state     :
+                        streq(verb, "hibernate") ? m->hibernate_state   :
+                                                   m->hybrid_sleep_state;
 #endif // 0
-        _cleanup_strv_free_ char **modes = NULL, **states = NULL;
-        int r;
 
         assert(STR_IN_SET(verb, "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate"));