From: Thomas Gstädtner <thomas@gstaedtner.net>

Subject: [E-devel] [PATCH] battery: add support for different suspend
methods

Allow the user to select what to do when the battery runs low:
Suspend, Hibernate or Shutdown.



SVN revision: 69623
devs/princeamd/enlightenment-0.17-elive
Thomas Gstädtner 11 years ago committed by Carsten Haitzler
parent f456602ebb
commit 6f55d529a3
  1. 1
      AUTHORS
  2. 16
      src/modules/battery/e_mod_config.c
  3. 9
      src/modules/battery/e_mod_main.c
  4. 7
      src/modules/battery/e_mod_main.h

@ -31,3 +31,4 @@ Jihoon Kim <jihoon48.kim@samsung.com>
Sthitha <iamsthitha@gmail>
Doyoun Kang <doyoun.kang@samsung.com>
Gwanglim Lee <gl77.lee@samsung.com>
Thomas Gstädtner <thomas@gstaedtner.net>

@ -13,6 +13,7 @@ struct _E_Config_Dialog_Data
int dismiss_alert;
int alert_timeout;
int suspend_below;
int suspend_method;
int force_mode; // 0 == auto, 1 == batget, 2 == subsystem
#ifdef HAVE_ENOTIFY
int desktop_notifications;
@ -76,6 +77,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->poll_interval = battery_config->poll_interval;
cfdata->alert_timeout = battery_config->alert_timeout;
cfdata->suspend_below = battery_config->suspend_below;
cfdata->suspend_method = battery_config->suspend_method;
cfdata->force_mode = battery_config->force_mode;
#ifdef HAVE_EEZE
cfdata->fuzzy = battery_config->fuzzy;
@ -236,11 +238,19 @@ _advanced_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_D
NULL, &(cfdata->poll_interval), 100);
e_widget_table_object_append(o, ob, 0, 1, 1, 1, 1, 0, 1, 0);
ob = e_widget_label_add(evas, _("Hibernate when below:"));
rg = e_widget_radio_group_new(&(cfdata->suspend_method));
ob = e_widget_radio_add(evas, _("Suspend when below:"), 0, rg);
e_widget_on_change_hook_set(ob, _cb_radio_changed, cfdata);
e_widget_table_object_append(o, ob, 0, 2, 1, 1, 1, 0, 1, 0);
ob = e_widget_radio_add(evas, _("Hibernate when below:"), 1, rg);
e_widget_on_change_hook_set(ob, _cb_radio_changed, cfdata);
e_widget_table_object_append(o, ob, 0, 3, 1, 1, 1, 0, 1, 0);
ob = e_widget_radio_add(evas, _("Shutdown when below:"), 2, rg);
e_widget_on_change_hook_set(ob, _cb_radio_changed, cfdata);
e_widget_table_object_append(o, ob, 0, 4, 1, 1, 1, 0, 1, 0);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f %%"), 0, 50, 1, 0,
NULL, &(cfdata->suspend_below), 100);
e_widget_table_object_append(o, ob, 0, 3, 1, 1, 1, 0, 1, 0);
e_widget_table_object_append(o, ob, 0, 5, 1, 1, 1, 0, 1, 0);
e_widget_toolbook_page_append(otb, NULL, _("Polling"), o, 1, 0, 1, 0,
0.5, 0.0);
@ -334,6 +344,7 @@ _advanced_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfda
battery_config->force_mode = cfdata->force_mode;
battery_config->suspend_below = cfdata->suspend_below;
battery_config->suspend_method = cfdata->suspend_method;
_battery_config_updated();
e_config_save_queue();
@ -352,6 +363,7 @@ _advanced_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *c
(cfdata->poll_interval != battery_config->poll_interval) ||
(cfdata->alert_timeout != battery_config->alert_timeout) ||
(cfdata->suspend_below != battery_config->suspend_below) ||
(cfdata->suspend_method != battery_config->suspend_method) ||
#ifdef HAVE_EEZE
(cfdata->fuzzy != battery_config->fuzzy) ||
#endif

@ -610,7 +610,14 @@ _battery_update(int full, int time_left, int time_full, Eina_Bool have_battery,
if ((have_battery) && (!have_power) && (full >= 0) &&
(battery_config->suspend_below > 0) &&
(full < battery_config->suspend_below))
e_sys_action_do(E_SYS_HIBERNATE, NULL);
{
if (battery_config->suspend_method == SUSPEND)
e_sys_action_do(E_SYS_SUSPEND, NULL);
else if (battery_config->suspend_method == HIBERNATE)
e_sys_action_do(E_SYS_HIBERNATE, NULL);
else if (battery_config->suspend_method == SHUTDOWN)
e_sys_action_do(E_SYS_HALT, NULL);
}
}
if (!have_battery)
e_powersave_mode_set(E_POWERSAVE_MODE_LOW);

@ -19,6 +19,10 @@ typedef struct _Config Config;
#define NOSUBSYSTEM 1
#define SUBSYSTEM 2
#define SUSPEND 0
#define HIBERNATE 1
#define SHUTDOWN 2
#define POPUP_DEBOUNCE_CYCLES 2
struct _Config
@ -28,7 +32,8 @@ struct _Config
int alert; /* Alert on minutes remaining */
int alert_p; /* Alert on percentage remaining */
int alert_timeout; /* Popup dismissal timeout */
int suspend_below; /* Suspend if batter drops below this level */
int suspend_below; /* Suspend if battery drops below this level */
int suspend_method; /* Method used to suspend the machine */
int force_mode; /* force use of batget or hal */
/* just config state */
E_Module *module;

Loading…
Cancel
Save