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 6e5eabcdb7ef6a40f72cd9f71e5c388ae1192d59
Author: Carsten Haitzler <ras...@rasterman.com>
AuthorDate: Tue May 20 17:34:21 2025 +0100
battery - remember max charge per battery in e as kernel doesn't
so even with kernel updates it seems kernel/battery firmware oesnt
remember max charge, so do it in e.
---
src/modules/battery/e_mod_main.c | 45 ++++++++++++++++++++++++++++++++++++++--
src/modules/battery/e_mod_main.h | 8 +++++++
src/modules/battery/e_mod_udev.c | 19 ++++++++++++++++-
3 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/src/modules/battery/e_mod_main.c b/src/modules/battery/e_mod_main.c
index 0bfb0cff8..6ab95e827 100644
--- a/src/modules/battery/e_mod_main.c
+++ b/src/modules/battery/e_mod_main.c
@@ -90,6 +90,7 @@ static void _battery_popup_usage_new(Instance *inst);
static Eina_Bool _powersave_cb_config_update(void *data, int type, void *event);
+static E_Config_DD *conf_battery_edd = NULL;
static E_Config_DD *conf_edd = NULL;
static Ecore_Event_Handler *_handler = NULL;
@@ -481,9 +482,30 @@ _cb_charge_lim_change(void *data, Evas_Object *obj, void *info EINA_UNUSED)
{
_Popup_Widgets *w = data;
double v = elm_slider_value_get(obj);
+ Config_Battery *cb;
+ Eina_List *l;
w->bat->charge_lim = (int)v;
e_system_send("battery-lim-set", "%s %i\n", w->bat->udi, (int)v);
+ EINA_LIST_FOREACH(battery_config->battery_configs, l, cb)
+ {
+ if ((cb->udi) && (w->bat->udi) && (!strcmp(cb->udi, w->bat->udi))) break;
+ cb = NULL;
+ }
+ if (!cb)
+ {
+ cb = E_NEW(Config_Battery, 1);
+ if (cb)
+ {
+ battery_config->battery_configs = eina_list_append(battery_config->battery_configs, cb);
+ cb->udi = eina_stringshare_add(w->bat->udi);
+ }
+ }
+ if (cb)
+ {
+ cb->charge_limit = w->bat->charge_lim;
+ e_config_save_queue();
+ }
}
static Evas_Object *
@@ -1309,6 +1331,14 @@ E_API E_Module_Api e_modapi =
E_API void *
e_modapi_init(E_Module *m)
{
+ conf_battery_edd = E_CONFIG_DD_NEW("Battery_Config_Battery", Config_Battery);
+#undef T
+#undef D
+#define T Config_Battery
+#define D conf_battery_edd
+ E_CONFIG_VAL(D, T, udi, STR);
+ E_CONFIG_VAL(D, T, charge_limit, INT);
+
conf_edd = E_CONFIG_DD_NEW("Battery_Config", Config);
#undef T
#undef D
@@ -1318,10 +1348,12 @@ e_modapi_init(E_Module *m)
E_CONFIG_VAL(D, T, alert_p, INT);
E_CONFIG_VAL(D, T, alert_timeout, INT);
E_CONFIG_VAL(D, T, suspend_below, INT);
+ E_CONFIG_VAL(D, T, suspend_method, INT);
+ E_CONFIG_VAL(D, T, desktop_notifications, INT);
+ E_CONFIG_LIST(D, T, battery_configs, conf_battery_edd);
#if defined HAVE_EEZE || defined(__OpenBSD__)
E_CONFIG_VAL(D, T, fuzzy, INT);
#endif
- E_CONFIG_VAL(D, T, desktop_notifications, INT);
battery_config = e_config_domain_load("module.battery", conf_edd);
if (!battery_config)
@@ -1331,10 +1363,10 @@ e_modapi_init(E_Module *m)
battery_config->alert_p = 10;
battery_config->alert_timeout = 0;
battery_config->suspend_below = 0;
+ battery_config->desktop_notifications = 0;
#if defined HAVE_EEZE || defined(__OpenBSD__)
battery_config->fuzzy = 0;
#endif
- battery_config->desktop_notifications = 0;
}
E_CONFIG_LIMIT(battery_config->alert, 0, 60);
E_CONFIG_LIMIT(battery_config->alert_p, 0, 100);
@@ -1365,6 +1397,8 @@ e_modapi_init(E_Module *m)
E_API int
e_modapi_shutdown(E_Module *m EINA_UNUSED)
{
+ Config_Battery *cb;
+
e_configure_registry_item_del("advanced/battery");
e_configure_registry_category_del("advanced");
e_gadcon_provider_unregister(&_gadcon_class);
@@ -1383,9 +1417,16 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
_battery_upower_stop();
#endif
+ EINA_LIST_FREE(battery_config->battery_configs, cb)
+ {
+ eina_stringshare_del(cb->udi);
+ free(cb);
+ }
+
free(battery_config);
battery_config = NULL;
E_CONFIG_DD_FREE(conf_edd);
+ E_CONFIG_DD_FREE(conf_battery_edd);
return 1;
}
diff --git a/src/modules/battery/e_mod_main.h b/src/modules/battery/e_mod_main.h
index 2a9999595..03cb86e3e 100644
--- a/src/modules/battery/e_mod_main.h
+++ b/src/modules/battery/e_mod_main.h
@@ -23,6 +23,13 @@
#define POPUP_DEBOUNCE_CYCLES 2
+typedef struct _Config_Battery Config_Battery;
+struct _Config_Battery
+{
+ const char *udi;
+ int charge_limit;
+};
+
typedef struct _Config Config;
struct _Config
{
@@ -32,6 +39,7 @@ struct _Config
int alert_timeout; /* Popup dismissal timeout */
int suspend_below; /* Suspend if battery drops below this level */
int suspend_method; /* Method used to suspend the machine */
+ Eina_List *battery_configs;/* Per battery config */
/* just config state */
E_Module *module;
E_Config_Dialog *config_dialog;
diff --git a/src/modules/battery/e_mod_udev.c b/src/modules/battery/e_mod_udev.c
index 127f704d2..046740565 100644
--- a/src/modules/battery/e_mod_udev.c
+++ b/src/modules/battery/e_mod_udev.c
@@ -101,6 +101,8 @@ _battery_udev_battery_add(const char *syspath)
double full_design = 0.0;
double voltage_min_design = 0.0;
double full = 0.0;
+ Config_Battery *cb;
+ Eina_List *l;
if ((bat = _battery_battery_find(syspath)))
{
@@ -166,7 +168,22 @@ _battery_udev_battery_add(const char *syspath)
test = eeze_udev_syspath_get_sysattr(syspath, "charge_control_end_threshold");
if (!test) bat->charge_lim = -1;
- else bat->charge_lim = atoi(test);
+ else
+ {
+ bat->charge_lim = atoi(test);
+ // find a matching battery config entry and retore from there
+ EINA_LIST_FOREACH(battery_config->battery_configs, l, cb)
+ {
+ if ((cb->udi) && (bat->udi) && (!strcmp(cb->udi, bat->udi)))
+ {
+ if (cb->charge_limit < 10) cb->charge_limit = 10;
+ else if (cb->charge_limit > 100) cb->charge_limit = 100;
+ bat->charge_lim = cb->charge_limit;
+ e_system_send("battery-lim-set", "%s %i\n", bat->udi, bat->charge_lim);
+ }
+ }
+ }
+
device_batteries = eina_list_append(device_batteries, bat);
_battery_udev_battery_update(syspath, bat);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.