Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -ur lxpanel-0.9.3/plugins/batt/batt_sys.c lxpanel-0.9.3-r1/plugins/batt/batt_sys.c
- --- lxpanel-0.9.3/plugins/batt/batt_sys.c 2017-01-20 21:34:34.000000000 +0000
- +++ lxpanel-0.9.3-r1/plugins/batt/batt_sys.c 2017-11-09 11:10:21.820000980 +0000
- @@ -45,7 +45,10 @@
- //b->capacity_unit = "mAh";
- b->energy_full = -1;
- b->charge_full = -1;
- + b->capacity = -1;
- b->voltage_now = -1;
- + b->voltage_min_design = -1;
- + b->voltage_max_design = -1;
- b->energy_full_design = -1;
- b->charge_full_design = -1;
- b->energy_now = -1;
- @@ -94,6 +97,22 @@
- return value;
- }
- +/* get_gint_1000_from_infofile():
- + * If the sys_file exists, then its value is converted to an int,
- + * NOT divided by 1000, and returned.
- + * Failure is indicated by returning -1. */
- +static gint get_gint_1000_from_infofile(battery *b, gchar *sys_file)
- +{
- + gchar *file_content = parse_info_file(b, sys_file);
- + gint value = -1;
- +
- + if (file_content != NULL)
- + value = atoi(file_content);
- + g_free(file_content);
- +
- + return value;
- +}
- +
- static gchar* get_gchar_from_infofile(battery *b, gchar *sys_file)
- {
- return parse_info_file(b, sys_file);
- @@ -196,6 +215,10 @@
- b->energy_full_design = get_gint_from_infofile(b, "energy_full_design");
- b->voltage_now = get_gint_from_infofile(b, "voltage_now");
- + b->voltage_min_design = get_gint_from_infofile(b, "voltage_min_design");
- + b->voltage_max_design = get_gint_from_infofile(b, "voltage_max_design");
- +
- + b->capacity = get_gint_1000_from_infofile(b, "capacity");
- gctmp = get_gchar_from_infofile(b, "type");
- b->type_battery = gctmp ? (strcasecmp(gctmp, "battery") == 0) : TRUE;
- @@ -259,6 +282,14 @@
- else if (b->energy_full != -1 && b->energy_now != -1)
- /* no charge data, let try energy instead */
- promille = (b->energy_now * 1000) / b->energy_full;
- + else if (b->capacity != -1)
- + /* teres 1: use "capacity" */
- + promille = b->capacity * 10;
- + else if (b->voltage_now != -1 && b->voltage_min_design != -1 && b->voltage_max_design != -1)
- + /* fallback, try voltage */
- + /* on teres 1, the min voltage is 1000 times less than it should be */
- + promille = ((b->voltage_now - 1000 * b->voltage_min_design) * 1000) /
- + (b->voltage_max_design - 1000 * b->voltage_min_design);
- else
- promille = 0;
- diff -ur lxpanel-0.9.3/plugins/batt/batt_sys.h lxpanel-0.9.3-r1/plugins/batt/batt_sys.h
- --- lxpanel-0.9.3/plugins/batt/batt_sys.h 2016-11-19 18:28:43.000000000 +0000
- +++ lxpanel-0.9.3-r1/plugins/batt/batt_sys.h 2017-11-09 09:00:42.320021695 +0000
- @@ -44,10 +44,13 @@
- int current_now;
- int power_now;
- int voltage_now;
- + int voltage_min_design;
- + int voltage_max_design;
- int charge_full_design;
- int energy_full_design;
- int charge_full;
- int energy_full;
- + int capacity;
- /* extra info */
- int seconds;
- int percentage;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement