This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository enlightenment.
View the commit online.
commit c6d007b9af5f8b597807f489e1eaa87f3d16b3e0
Author: Carsten Haitzler <ras...@rasterman.com>
AuthorDate: Sat Aug 24 21:48:11 2024 +0100
sys - add settable suspend mode
make hibernate events be suspend events as they serve the same purpose
add suspend modes so you can select regular suspend, hybrid suspend or
suspend then hibernate as your suspend mode and then make all ye olde
suspend actions use this mode. keep hibernate as an explicit "suspend
to disk and turn off now" option. the rest are versions of suspending
to rame.
@feat
---
src/bin/e_actions.c | 8 +-
src/bin/e_config.c | 1 +
src/bin/e_config.h | 1 +
src/bin/e_fm.c | 8 +-
src/bin/e_powersave.c | 2 +-
src/bin/e_randr2.c | 2 +-
src/bin/e_sys.c | 182 ++++++++++++++++++++-
src/bin/e_sys.h | 6 +-
src/bin/e_utils.c | 13 +-
src/bin/system/e_system_power.c | 58 ++++++-
src/modules/battery/e_mod_main.c | 2 +-
.../e_int_config_powermanagement.c | 50 +++++-
src/modules/syscon/e_syscon.c | 2 +-
src/modules/syscon/e_syscon_gadget.c | 2 +-
14 files changed, 307 insertions(+), 30 deletions(-)
diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c
index 4c0347b29..3b542ad60 100644
--- a/src/bin/e_actions.c
+++ b/src/bin/e_actions.c
@@ -2479,7 +2479,7 @@ _e_actions_cb_suspend_dialog_ok(void *data EINA_UNUSED, E_Dialog *dia)
e_object_del(E_OBJECT(suspend_dialog));
suspend_dialog = NULL;
}
- e_sys_action_do(E_SYS_SUSPEND, NULL);
+ e_sys_action_do(E_SYS_SUSPEND_MODE, NULL);
}
static void
@@ -2497,14 +2497,14 @@ _e_actions_cb_suspend_dialog_delete(void *data, Evas *e EINA_UNUSED, Evas_Object
ACT_FN_GO(suspend_now, EINA_UNUSED)
{
- e_sys_action_do(E_SYS_SUSPEND, NULL);
+ e_sys_action_do(E_SYS_SUSPEND_MODE, NULL);
}
ACT_FN_GO(suspend, )
{
if ((params) && (!strcmp(params, "now")))
{
- e_sys_action_do(E_SYS_SUSPEND, NULL);
+ e_sys_action_do(E_SYS_SUSPEND_MODE, NULL);
return;
}
if (suspend_dialog) e_object_del(E_OBJECT(suspend_dialog));
@@ -2564,7 +2564,7 @@ ACT_FN_GO(suspend_smart, EINA_UNUSED)
if (!_have_lid_and_external_screens_on())
{
if (_should_suspend_if_plugged_in())
- e_sys_action_do(E_SYS_SUSPEND, NULL);
+ e_sys_action_do(E_SYS_SUSPEND_MODE, NULL);
else
e_powersave_defer_suspend();
}
diff --git a/src/bin/e_config.c b/src/bin/e_config.c
index bfcfe7957..d59359ce1 100644
--- a/src/bin/e_config.c
+++ b/src/bin/e_config.c
@@ -829,6 +829,7 @@ _e_config_edd_init(Eina_Bool old)
E_CONFIG_VAL(D, T, screensaver_wake_on_urgent, INT);
E_CONFIG_VAL(D, T, suspend_connected_standby, UCHAR);
+ E_CONFIG_VAL(D, T, suspend_mode, UCHAR);
E_CONFIG_VAL(D, T, screensaver_suspend, UCHAR);
E_CONFIG_VAL(D, T, screensaver_hibernate, UCHAR);
diff --git a/src/bin/e_config.h b/src/bin/e_config.h
index aeb0fecdb..117c9914f 100644
--- a/src/bin/e_config.h
+++ b/src/bin/e_config.h
@@ -219,6 +219,7 @@ struct _E_Config
int screensaver_wake_on_urgent; // GUI
unsigned char suspend_connected_standby; // GUI
+ unsigned char suspend_mode; // GUI
unsigned char screensaver_suspend; // GUI
unsigned char screensaver_hibernate; // GUI
diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c
index e603cacec..12608ad59 100644
--- a/src/bin/e_fm.c
+++ b/src/bin/e_fm.c
@@ -472,7 +472,7 @@ static void _e_fm2_volume_icon_update(E_Volume *v);
static int _e_fm2_desktop_open(E_Fm2_Smart_Data *sd);
static void _e_fm2_operation_abort_internal(E_Fm2_Op_Registry_Entry *ere);
-static Eina_Bool _e_fm2_sys_suspend_hibernate(void *, int, void *);
+static Eina_Bool _e_fm2_sys_suspend(void *, int, void *);
static void _e_fm2_favorites_thread_cb(void *d, Ecore_Thread *et);
static void _e_fm2_thread_cleanup_cb(void *d, Ecore_Thread *et);
@@ -855,8 +855,8 @@ e_fm2_init(void)
E_LIST_HANDLER_APPEND(_e_fm_handlers, E_EVENT_FM_OP_REGISTRY_DEL, _e_fm2_op_registry_entry_del_cb, NULL);
E_LIST_HANDLER_APPEND(_e_fm_handlers, E_EVENT_FM_OP_REGISTRY_CHANGED, _e_fm2_op_registry_entry_changed_cb, NULL);
/// DBG
- E_LIST_HANDLER_APPEND(_e_fm_handlers, E_EVENT_SYS_HIBERNATE, _e_fm2_sys_suspend_hibernate, NULL);
- E_LIST_HANDLER_APPEND(_e_fm_handlers, E_EVENT_SYS_RESUME, _e_fm2_sys_suspend_hibernate, NULL);
+ E_LIST_HANDLER_APPEND(_e_fm_handlers, E_EVENT_SYS_SUSPEND, _e_fm2_sys_suspend, NULL);
+ E_LIST_HANDLER_APPEND(_e_fm_handlers, E_EVENT_SYS_RESUME, _e_fm2_sys_suspend, NULL);
return 1;
}
@@ -11186,7 +11186,7 @@ _e_fm2_file_delete_no_cb(void *data, E_Dialog *dialog)
}
static Eina_Bool
-_e_fm2_sys_suspend_hibernate(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
+_e_fm2_sys_suspend(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
{
Eina_List *l, *ll, *lll;
E_Volume *v;
diff --git a/src/bin/e_powersave.c b/src/bin/e_powersave.c
index d39834fe7..bade6a7c5 100644
--- a/src/bin/e_powersave.c
+++ b/src/bin/e_powersave.c
@@ -372,7 +372,7 @@ _e_powersave_event_update_free(void *data EINA_UNUSED, void *event)
if (powersave_deferred_hibernate)
e_sys_action_do(E_SYS_HIBERNATE, NULL);
else if (powersave_deferred_suspend)
- e_sys_action_do(E_SYS_SUSPEND, NULL);
+ e_sys_action_do(E_SYS_SUSPEND_MODE, NULL);
}
powersave_deferred_hibernate = EINA_FALSE;
powersave_deferred_suspend = EINA_FALSE;
diff --git a/src/bin/e_randr2.c b/src/bin/e_randr2.c
index 80807b912..921aba6b5 100644
--- a/src/bin/e_randr2.c
+++ b/src/bin/e_randr2.c
@@ -848,7 +848,7 @@ _cb_deferred_suspend_screen_change(void *data EINA_UNUSED)
(e_powersave_mode_get() > E_POWERSAVE_MODE_LOW))
{
printf("RRR: =========================== powermd low / suspend on ac");
- e_sys_action_do(E_SYS_SUSPEND, NULL);
+ e_sys_action_do(E_SYS_SUSPEND_MODE, NULL);
}
}
return EINA_FALSE;
diff --git a/src/bin/e_sys.c b/src/bin/e_sys.c
index 828c1024d..23de1a1e8 100644
--- a/src/bin/e_sys.c
+++ b/src/bin/e_sys.c
@@ -16,6 +16,8 @@ static int _e_sys_can_halt = 0;
static int _e_sys_can_reboot = 0;
static int _e_sys_can_suspend = 0;
static int _e_sys_can_hibernate = 0;
+static int _e_sys_can_hybrid_suspend = 0;
+static int _e_sys_can_suspend_then_hibernate = 0;
static E_Sys_Action _e_sys_action_current = E_SYS_NONE;
static E_Sys_Action _e_sys_action_after = E_SYS_NONE;
@@ -37,6 +39,8 @@ static void _e_sys_systemd_poweroff(void);
static void _e_sys_systemd_reboot(void);
static void _e_sys_systemd_suspend(void);
static void _e_sys_systemd_hibernate(void);
+static void _e_sys_systemd_hybrid_suspend(void);
+static void _e_sys_systemd_suspend_then_hibernate(void);
static void _e_sys_systemd_exists_cb(void *data, const Eldbus_Message *m, Eldbus_Pending *p);
static Eina_Bool systemd_works = EINA_FALSE;
@@ -58,12 +62,13 @@ static double resume_backlight;
static Ecore_Timer *_e_sys_suspend_delay_timer = NULL;
static Ecore_Timer *_e_sys_hibernate_delay_timer = NULL;
+static Ecore_Timer *_e_sys_hybrid_suspend_delay_timer = NULL;
+static Ecore_Timer *_e_sys_suspend_then_hibernate_delay_timer = NULL;
static Ecore_Timer *_e_sys_halt_reboot_timer = NULL;
static Eina_Bool _on_the_way_out_ = EINA_FALSE;
E_API int E_EVENT_SYS_SUSPEND = -1;
-E_API int E_EVENT_SYS_HIBERNATE = -1;
E_API int E_EVENT_SYS_RESUME = -1;
static Eina_Bool
@@ -139,10 +144,10 @@ _e_sys_comp_action_timeout(void *data)
sig = "e,state,sys,reboot,done";
break;
case E_SYS_SUSPEND:
- sig = "e,state,sys,suspend,done";
- break;
case E_SYS_HIBERNATE:
- sig = "e,state,sys,hibernate,done";
+ case E_SYS_HYBRID_SUSPEND:
+ case E_SYS_SUSPEND_THEN_HIBERNATE:
+ sig = "e,state,sys,suspend,done";
break;
default:
break;
@@ -214,8 +219,19 @@ _e_sys_comp_suspend(void)
static void
_e_sys_comp_hibernate(void)
{
- resume_backlight = e_config->backlight.normal;
- _e_sys_comp_emit_cb_wait(E_SYS_HIBERNATE, "e,state,sys,hibernate", "e,state,sys,hibernate,done", EINA_TRUE);
+ _e_sys_comp_suspend();
+}
+
+static void
+_e_sys_comp_hybrid_suspend(void)
+{
+ _e_sys_comp_suspend();
+}
+
+static void
+_e_sys_comp_suspend_then_hibernate(void)
+{
+ _e_sys_comp_suspend();
}
static void
@@ -494,7 +510,6 @@ e_sys_init(void)
}
E_EVENT_SYS_SUSPEND = ecore_event_type_new();
- E_EVENT_SYS_HIBERNATE = ecore_event_type_new();
E_EVENT_SYS_RESUME = ecore_event_type_new();
return 1;
}
@@ -508,6 +523,10 @@ e_sys_shutdown(void)
ecore_timer_del(_e_sys_suspend_delay_timer);
if (_e_sys_hibernate_delay_timer)
ecore_timer_del(_e_sys_hibernate_delay_timer);
+ if (_e_sys_hybrid_suspend_delay_timer)
+ ecore_timer_del(_e_sys_hybrid_suspend_delay_timer);
+ if (_e_sys_suspend_then_hibernate_delay_timer)
+ ecore_timer_del(_e_sys_suspend_then_hibernate_delay_timer);
if (_e_sys_resume_delay_timer)
ecore_timer_del(_e_sys_resume_delay_timer);
if (_e_sys_screensaver_unignore_timer)
@@ -517,6 +536,8 @@ e_sys_shutdown(void)
_e_sys_halt_reboot_timer = NULL;
_e_sys_suspend_delay_timer = NULL;
_e_sys_hibernate_delay_timer = NULL;
+ _e_sys_hybrid_suspend_delay_timer = NULL;
+ _e_sys_suspend_then_hibernate_delay_timer = NULL;
_e_sys_resume_delay_timer = NULL;
_e_sys_screensaver_unignore_timer = NULL;
_e_sys_acpi_handler = NULL;
@@ -572,6 +593,15 @@ e_sys_action_possible_get(E_Sys_Action a)
case E_SYS_HIBERNATE:
return _e_sys_can_hibernate;
+ case E_SYS_HYBRID_SUSPEND:
+ return _e_sys_can_hybrid_suspend;
+
+ case E_SYS_SUSPEND_THEN_HIBERNATE:
+ return _e_sys_can_suspend_then_hibernate;
+
+ case E_SYS_SUSPEND_MODE:
+ return _e_sys_can_suspend | _e_sys_can_hybrid_suspend | _e_sys_can_suspend_then_hibernate;
+
default:
return 0;
}
@@ -601,6 +631,23 @@ e_sys_action_do(E_Sys_Action a, char *param)
case E_SYS_SUSPEND:
case E_SYS_HIBERNATE:
+ case E_SYS_HYBRID_SUSPEND:
+ case E_SYS_SUSPEND_THEN_HIBERNATE:
+ ret = _e_sys_action_do(a, param, EINA_FALSE);
+ break;
+
+ case E_SYS_SUSPEND_MODE:
+ a = E_SYS_SUSPEND;
+ if ((e_config->suspend_mode == 1) &&
+ (_e_sys_can_hybrid_suspend))
+ a = E_SYS_HYBRID_SUSPEND;
+ else if (e_config->suspend_mode == 2)
+ {
+ if (_e_sys_can_suspend_then_hibernate)
+ a = E_SYS_SUSPEND_THEN_HIBERNATE;
+ else if (_e_sys_can_hybrid_suspend)
+ a = E_SYS_HYBRID_SUSPEND;
+ }
ret = _e_sys_action_do(a, param, EINA_FALSE);
break;
@@ -709,6 +756,7 @@ _e_sys_systemd_handle_inhibit(void)
eldbus_message_arguments_append
(m, "ssss",
"handle-power-key:"
+ "handle-reboot-key:"
"handle-suspend-key:"
"handle-hibernate-key:"
"handle-lid-switch", // what
@@ -745,6 +793,12 @@ _e_sys_systemd_check(void)
if (!eldbus_proxy_call(login1_manger_proxy, "CanHibernate",
_e_sys_systemd_check_cb, &_e_sys_can_hibernate, -1, ""))
return;
+ if (!eldbus_proxy_call(login1_manger_proxy, "CanHybridSleep",
+ _e_sys_systemd_check_cb, &_e_sys_can_hybrid_suspend, -1, ""))
+ return;
+ if (!eldbus_proxy_call(login1_manger_proxy, "CanSuspendThenHibernate",
+ _e_sys_systemd_check_cb, &_e_sys_can_suspend_then_hibernate, -1, ""))
+ return;
}
static void
@@ -765,6 +819,8 @@ fail:
_e_sys_can_reboot = 1;
_e_sys_can_suspend = 1;
_e_sys_can_hibernate = 1;
+ _e_sys_can_hybrid_suspend = 1;
+ _e_sys_can_suspend_then_hibernate = 1;
}
static void
@@ -791,6 +847,18 @@ _e_sys_systemd_hibernate(void)
eldbus_proxy_call(login1_manger_proxy, "Hibernate", NULL, NULL, -1, "b", 0);
}
+static void
+_e_sys_systemd_hybrid_suspend(void)
+{
+ eldbus_proxy_call(login1_manger_proxy, "HybridSleep", NULL, NULL, -1, "b", 0);
+}
+
+static void
+_e_sys_systemd_suspend_then_hibernate(void)
+{
+ eldbus_proxy_call(login1_manger_proxy, "SuspendThenHibernate", NULL, NULL, -1, "b", 0);
+}
+
static Eina_Bool
_e_sys_resume_delay(void *d EINA_UNUSED)
{
@@ -1072,6 +1140,18 @@ _e_sys_current_action(void)
"until hibernation is complete."));
break;
+ case E_SYS_HYBRID_SUSPEND:
+ e_dialog_text_set(dia, _("Hiybrid Susspending.<ps/>"
+ "You cannot perform any other system actions<ps/>"
+ "until hybrid susspend is complete."));
+ break;
+
+ case E_SYS_SUSPEND_THEN_HIBERNATE:
+ e_dialog_text_set(dia, _("Suspending then hibernating.<ps/>"
+ "You cannot perform any other system actions<ps/>"
+ "until suspend then hibernate is complete."));
+ break;
+
default:
e_dialog_text_set(dia, _("EEK! This should not happen"));
break;
@@ -1151,6 +1231,34 @@ _e_sys_hibernate_delay(void *data EINA_UNUSED)
return EINA_FALSE;
}
+static Eina_Bool
+_e_sys_hybrid_suspend_delay(void *data EINA_UNUSED)
+{
+ _e_sys_hybrid_suspend_delay_timer = NULL;
+ _e_sys_begin_time = ecore_time_get();
+ if (systemd_works) _e_sys_systemd_hybrid_suspend();
+ else
+ {
+ _e_sys_susp_hib_check();
+ e_system_send("power-hybrid-suspend", NULL);
+ }
+ return EINA_FALSE;
+}
+
+static Eina_Bool
+_e_sys_suspend_then_hibernate_delay(void *data EINA_UNUSED)
+{
+ _e_sys_suspend_then_hibernate_delay_timer = NULL;
+ _e_sys_begin_time = ecore_time_get();
+ if (systemd_works) _e_sys_systemd_suspend_then_hibernate();
+ else
+ {
+ _e_sys_susp_hib_check();
+ e_system_send("power-suspend-then-hib", NULL);
+ }
+ return EINA_FALSE;
+}
+
static Eina_Bool
_e_sys_halt_reboot(void *data EINA_UNUSED)
{
@@ -1340,7 +1448,7 @@ _e_sys_action_do(E_Sys_Action a, char *param EINA_UNUSED, Eina_Bool raw)
}
else
{
- ecore_event_add(E_EVENT_SYS_HIBERNATE, NULL, NULL, NULL);
+ ecore_event_add(E_EVENT_SYS_SUSPEND, NULL, NULL, NULL);
_e_sys_comp_hibernate();
return 0;
}
@@ -1348,6 +1456,64 @@ _e_sys_action_do(E_Sys_Action a, char *param EINA_UNUSED, Eina_Bool raw)
}
break;
+ case E_SYS_HYBRID_SUSPEND:
+ /* /etc/acpi/hibernate.sh force */
+ if (!_e_sys_comp_waiting)
+ {
+ if (_e_sys_phantom_wake_check_timer)
+ ecore_timer_del(_e_sys_phantom_wake_check_timer);
+ _e_sys_phantom_wake_check_timer = NULL;
+ if (raw)
+ {
+ _e_sys_suspended = EINA_TRUE;
+ if (e_config->desklock_on_suspend)
+ // XXX: this desklock - ensure its instant
+ e_desklock_show(EINA_TRUE);
+ if (_e_sys_hybrid_suspend_delay_timer)
+ ecore_timer_del(_e_sys_hybrid_suspend_delay_timer);
+ ret = 1;
+ // XXX: make timer shorter if desklock is instant
+ _e_sys_hybrid_suspend_delay_timer =
+ ecore_timer_add(0.5, _e_sys_hybrid_suspend_delay, NULL);
+ }
+ else
+ {
+ ecore_event_add(E_EVENT_SYS_SUSPEND, NULL, NULL, NULL);
+ _e_sys_comp_hybrid_suspend();
+ return 0;
+ }
+ }
+ break;
+
+ case E_SYS_SUSPEND_THEN_HIBERNATE:
+ /* /etc/acpi/hibernate.sh force */
+ if (!_e_sys_comp_waiting)
+ {
+ if (_e_sys_phantom_wake_check_timer)
+ ecore_timer_del(_e_sys_phantom_wake_check_timer);
+ _e_sys_phantom_wake_check_timer = NULL;
+ if (raw)
+ {
+ _e_sys_suspended = EINA_TRUE;
+ if (e_config->desklock_on_suspend)
+ // XXX: this desklock - ensure its instant
+ e_desklock_show(EINA_TRUE);
+ if (_e_sys_suspend_then_hibernate_delay_timer)
+ ecore_timer_del(_e_sys_suspend_then_hibernate_delay_timer);
+ ret = 1;
+ // XXX: make timer shorter if desklock is instant
+ _e_sys_suspend_then_hibernate_delay_timer =
+ ecore_timer_add(0.5, _e_sys_suspend_then_hibernate_delay, NULL);
+ }
+ else
+ {
+ ecore_event_add(E_EVENT_SYS_SUSPEND, NULL, NULL, NULL);
+ _e_sys_comp_suspend_then_hibernate();
+ return 0;
+ }
+ }
+ break;
+
default:
return 0;
}
diff --git a/src/bin/e_sys.h b/src/bin/e_sys.h
index 9bf71f804..08e27dfc6 100644
--- a/src/bin/e_sys.h
+++ b/src/bin/e_sys.h
@@ -13,7 +13,10 @@ typedef enum _E_Sys_Action
E_SYS_HALT_NOW,
E_SYS_REBOOT,
E_SYS_SUSPEND,
- E_SYS_HIBERNATE
+ E_SYS_HIBERNATE,
+ E_SYS_HYBRID_SUSPEND,
+ E_SYS_SUSPEND_THEN_HIBERNATE,
+ E_SYS_SUSPEND_MODE
} E_Sys_Action;
struct _E_Sys_Con_Action
@@ -31,7 +34,6 @@ struct _E_Sys_Con_Action
#define E_SYS_H
E_API extern int E_EVENT_SYS_SUSPEND;
-E_API extern int E_EVENT_SYS_HIBERNATE;
E_API extern int E_EVENT_SYS_RESUME;
EINTERN int e_sys_init(void);
diff --git a/src/bin/e_utils.c b/src/bin/e_utils.c
index 6ccbcd831..174fa56e8 100644
--- a/src/bin/e_utils.c
+++ b/src/bin/e_utils.c
@@ -1614,7 +1614,7 @@ _pri_adj(int pid, int pri_set, int pri_adj, int pri_only_filter,
if (do_adj) newpri += pri_adj;
else newpri = pri_set;
if (newpri > 19) newpri = 19;
-// printf("PRI: %i -> %i (adj=%i, adj_ch=%i ch=%i)\n", pid, newpri, do_adj, do_adj_children, do_children);
+ printf("PRI: %i -> %i (adj=%i, adj_ch=%i ch=%i)\n", pid, newpri, do_adj, do_adj_children, do_children);
ret = setpriority(PRIO_PROCESS, pid, newpri);
// if (ret < 0) printf("PRI: ret = %i | %s\n", ret, strerror(errno));
}
@@ -1702,14 +1702,23 @@ _e_pid_nice_priority_lower_can(void)
struct rlimit rlim;
again:
- if (checked == 0) return EINA_FALSE;
+ if (checked == 0) return EINA_TRUE;
else if (checked == 1) return EINA_TRUE;
checked = 1;
+ if (getrlimit(RLIMIT_NICE, &rlim) == 0)
+ {
+ if (rlim.rlim_max >= 20)
+ {
+ rlim.rlim_cur = 20;
+ setrlimit(RLIMIT_NICE, &rlim);
+ }
+ }
if (getrlimit(RLIMIT_NICE, &rlim) == 0)
{
// if we can't lower pri to at least 20 (nice 0 ...) then assume
// we can only raise nice level never lower it
+ printf("PRI: getrlimit(RLIMIT_NUICE) === cur=%i max=%i\n", (int)rlim.rlim_cur, (int)rlim.rlim_max);
if (rlim.rlim_cur < 20) checked = 0;
}
goto again; // set checked now - try again
diff --git a/src/bin/system/e_system_power.c b/src/bin/system/e_system_power.c
index b49ec3a14..4699060bf 100644
--- a/src/bin/system/e_system_power.c
+++ b/src/bin/system/e_system_power.c
@@ -4,6 +4,8 @@ char *_cmd_halt = NULL;
char *_cmd_reboot = NULL;
char *_cmd_suspend = NULL;
char *_cmd_hibernate = NULL;
+char *_cmd_hybrid_suspend = NULL;
+char *_cmd_suspend_then_hibernate = NULL;
static void
_cb_power_halt(void *data EINA_UNUSED, const char *params EINA_UNUSED)
@@ -29,6 +31,18 @@ _cb_power_hibernate(void *data EINA_UNUSED, const char *params EINA_UNUSED)
if (_cmd_hibernate) e_system_run(_cmd_hibernate);
}
+static void
+_cb_power_hybrid_suspend(void *data EINA_UNUSED, const char *params EINA_UNUSED)
+{
+ if (_cmd_hybrid_suspend) e_system_run(_cmd_hybrid_suspend);
+}
+
+static void
+_cb_power_suspend_then_hibernate(void *data EINA_UNUSED, const char *params EINA_UNUSED)
+{
+ if (_cmd_suspend_then_hibernate) e_system_run(_cmd_suspend_then_hibernate);
+}
+
static void
_power_halt_init(void)
{
@@ -118,6 +132,38 @@ _power_hibernate_init(void)
// /etc/acpi/pm-hibernate
}
+static void
+_power_hybrid_suspend_init(void)
+{
+#if defined (__FreeBSD__)
+#elif defined (__OpenBSD__)
+#else
+ if (ecore_file_app_installed("systemctl"))
+ _cmd_hybrid_suspend = strdup("systemctl hybrid-sleep");
+#endif
+ // linux systemd: PATH/systemctl hybrid-sleep
+ // FreeBSD: ?
+ // OpenBSD: ?
+ // if exist:
+ // ?
+}
+
+static void
+_power_suspend_then_hibernate_init(void)
+{
+#if defined (__FreeBSD__)
+#elif defined (__OpenBSD__)
+#else
+ if (ecore_file_app_installed("systemctl"))
+ _cmd_suspend_then_hibernate = strdup("systemctl suspend-then-hibernate");
+#endif
+ // linux systemd: PATH/systemctl suspennd-then-hibernate
+ // FreeBSD: ?
+ // OpenBSD: ?
+ // if exist:
+ // ?
+}
+
void
e_system_power_init(void)
{
@@ -125,10 +171,14 @@ e_system_power_init(void)
_power_reboot_init();
_power_suspend_init();
_power_hibernate_init();
- e_system_inout_command_register("power-halt", _cb_power_halt, NULL);
- e_system_inout_command_register("power-reboot", _cb_power_reboot, NULL);
- e_system_inout_command_register("power-suspend", _cb_power_suspend, NULL);
- e_system_inout_command_register("power-hibernate", _cb_power_hibernate, NULL);
+ _power_hybrid_suspend_init();
+ _power_suspend_then_hibernate_init();
+ e_system_inout_command_register("power-halt", _cb_power_halt, NULL);
+ e_system_inout_command_register("power-reboot", _cb_power_reboot, NULL);
+ e_system_inout_command_register("power-suspend", _cb_power_suspend, NULL);
+ e_system_inout_command_register("power-hibernate", _cb_power_hibernate, NULL);
+ e_system_inout_command_register("power-hybrid-suspend", _cb_power_hybrid_suspend, NULL);
+ e_system_inout_command_register("power-suspend-then-hib", _cb_power_suspend_then_hibernate, NULL);
}
void
diff --git a/src/modules/battery/e_mod_main.c b/src/modules/battery/e_mod_main.c
index 6985c6100..b00dacc6c 100644
--- a/src/modules/battery/e_mod_main.c
+++ b/src/modules/battery/e_mod_main.c
@@ -938,7 +938,7 @@ _battery_update(int full, int time_left, int time_full, Eina_Bool have_battery,
{
printf("battery %i suspend below %i\n", full, battery_config->suspend_below);
if (battery_config->suspend_method == SUSPEND)
- e_sys_action_do(E_SYS_SUSPEND, NULL);
+ e_sys_action_do(E_SYS_SUSPEND_MODE, NULL);
else if (battery_config->suspend_method == HIBERNATE)
e_sys_action_do(E_SYS_HIBERNATE, NULL);
else if (battery_config->suspend_method == SHUTDOWN)
diff --git a/src/modules/conf_performance/e_int_config_powermanagement.c b/src/modules/conf_performance/e_int_config_powermanagement.c
index ab879f853..cb8e30a3a 100644
--- a/src/modules/conf_performance/e_int_config_powermanagement.c
+++ b/src/modules/conf_performance/e_int_config_powermanagement.c
@@ -22,6 +22,7 @@ struct _E_Config_Dialog_Data
E_Powersave_Mode powersave_min;
E_Powersave_Mode powersave_max;
int suspend_connected_standby;
+ int suspend_mode;
};
E_Config_Dialog *
@@ -58,6 +59,7 @@ _create_data(E_Config_Dialog *cfd EINA_UNUSED)
cfdata->powersave_high = e_config->powersave.high;
cfdata->powersave_extreme = e_config->powersave.extreme;
cfdata->suspend_connected_standby = e_config->suspend_connected_standby;
+ cfdata->suspend_mode = e_config->suspend_mode;
return cfdata;
}
@@ -73,6 +75,7 @@ static int
_basic_apply(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
{
e_config->suspend_connected_standby = cfdata->suspend_connected_standby;
+ e_config->suspend_mode = cfdata->suspend_mode;
e_config->powersave.none = cfdata->powersave_none;
e_config->powersave.low = cfdata->powersave_low;
e_config->powersave.medium = cfdata->powersave_medium;
@@ -96,6 +99,7 @@ static int
_basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
{
return ((e_config->suspend_connected_standby != cfdata->suspend_connected_standby) ||
+ (e_config->suspend_mode != cfdata->suspend_mode) ||
(e_config->powersave.min != cfdata->powersave_min) ||
(e_config->powersave.max != cfdata->powersave_max) ||
(!EINA_DBL_EQ(e_config->powersave.none, cfdata->powersave_none)) ||
@@ -109,13 +113,14 @@ static Evas_Object *
_basic_create(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *ob, *ol;
- E_Radio_Group *rmin, *rmax;
+ E_Radio_Group *rmin, *rmax, *smode;
int y;
cfdata->powersave_min = e_config->powersave.min;
cfdata->powersave_max = e_config->powersave.max;
rmin = e_widget_radio_group_new((int*) &(cfdata->powersave_min));
rmax = e_widget_radio_group_new((int*) &(cfdata->powersave_max));
+ smode = e_widget_radio_group_new((int*) &(cfdata->suspend_mode));
ol = e_widget_table_add(e_win_evas_win_get(evas), 0);
@@ -381,6 +386,49 @@ _basic_create(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data
1, 0, //expand
0.0, 0.5 //align
);
+ y++;
+ ob = e_widget_label_add(evas,
+ _("Suspend Mode"));
+ e_widget_table_object_align_append(ol, ob,
+ 0, y, //place
+ 4, 1, //span
+ 1, 1, //fill
+ 1, 0, //expand
+ 0.0, 0.5 //align
+ );
+ y++;
+ ob = e_widget_radio_add(evas, "Suspend", 0, smode);
+ if (!e_sys_action_possible_get(E_SYS_SUSPEND))
+ e_widget_disabled_set(ob, EINA_TRUE);
+ e_widget_table_object_align_append(ol, ob,
+ 0, y, //place
+ 4, 1, //span
+ 1, 1, //fill
+ 1, 0, //expand
+ 0.0, 0.5 //align
+ );
+ y++;
+ ob = e_widget_radio_add(evas, "Hybrid suspend", 1, smode);
+ if (!e_sys_action_possible_get(E_SYS_HYBRID_SUSPEND))
+ e_widget_disabled_set(ob, EINA_TRUE);
+ e_widget_table_object_align_append(ol, ob,
+ 0, y, //place
+ 4, 1, //span
+ 1, 1, //fill
+ 1, 0, //expand
+ 0.0, 0.5 //align
+ );
+ y++;
+ ob = e_widget_radio_add(evas, "Suspend then hibernate", 2, smode);
+ if (!e_sys_action_possible_get(E_SYS_SUSPEND_THEN_HIBERNATE))
+ e_widget_disabled_set(ob, EINA_TRUE);
+ e_widget_table_object_align_append(ol, ob,
+ 0, y, //place
+ 4, 1, //span
+ 1, 1, //fill
+ 1, 0, //expand
+ 0.0, 0.5 //align
+ );
return ol;
}
diff --git a/src/modules/syscon/e_syscon.c b/src/modules/syscon/e_syscon.c
index aa0ecf56e..25d5323bd 100644
--- a/src/modules/syscon/e_syscon.c
+++ b/src/modules/syscon/e_syscon.c
@@ -169,7 +169,7 @@ e_syscon_show(E_Zone *zone, const char *defact)
(!e_sys_action_possible_get(E_SYS_REBOOT)))
disabled = 1;
else if ((!strcmp(sca->action, "suspend")) &&
- (!e_sys_action_possible_get(E_SYS_SUSPEND)))
+ (!e_sys_action_possible_get(E_SYS_SUSPEND_MODE)))
disabled = 1;
else if ((!strcmp(sca->action, "hibernate")) &&
(!e_sys_action_possible_get(E_SYS_HIBERNATE)))
diff --git a/src/modules/syscon/e_syscon_gadget.c b/src/modules/syscon/e_syscon_gadget.c
index e7734f429..2182edf20 100644
--- a/src/modules/syscon/e_syscon_gadget.c
+++ b/src/modules/syscon/e_syscon_gadget.c
@@ -341,7 +341,7 @@ e_syscon_menu_fill(E_Menu *m)
if (sca->icon)
e_util_menu_item_theme_icon_set(it, sca->icon);
e_menu_item_callback_set(it, _cb_menu_sel, sca);
- if (!e_sys_action_possible_get(E_SYS_SUSPEND))
+ if (!e_sys_action_possible_get(E_SYS_SUSPEND_MODE))
e_menu_item_disabled_set(it, EINA_TRUE);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.