Battery: fix issue #616
This commit is contained in:
@@ -56,6 +56,8 @@ char *battery_uwheel_command;
|
|||||||
char *battery_dwheel_command;
|
char *battery_dwheel_command;
|
||||||
gboolean battery_found;
|
gboolean battery_found;
|
||||||
|
|
||||||
|
char *battery_sys_prefix = (char*)"";
|
||||||
|
|
||||||
void battery_init_fonts();
|
void battery_init_fonts();
|
||||||
char *battery_get_tooltip(void *obj);
|
char *battery_get_tooltip(void *obj);
|
||||||
int battery_compute_desired_size(void *obj);
|
int battery_compute_desired_size(void *obj);
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ extern char *battery_rclick_command;
|
|||||||
extern char *battery_uwheel_command;
|
extern char *battery_uwheel_command;
|
||||||
extern char *battery_dwheel_command;
|
extern char *battery_dwheel_command;
|
||||||
|
|
||||||
|
extern char *battery_sys_prefix;
|
||||||
|
|
||||||
static inline gchar *chargestate2str(ChargeState state)
|
static inline gchar *chargestate2str(ChargeState state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
|||||||
@@ -38,18 +38,16 @@ struct psy_battery {
|
|||||||
gint64 timestamp;
|
gint64 timestamp;
|
||||||
/* sysfs files */
|
/* sysfs files */
|
||||||
gchar *path_present;
|
gchar *path_present;
|
||||||
gchar *path_energy_now;
|
gchar *path_level_now;
|
||||||
gchar *path_energy_full;
|
gchar *path_level_full;
|
||||||
gchar *path_power_now;
|
gchar *path_rate_now;
|
||||||
gchar *path_status;
|
gchar *path_status;
|
||||||
/* sysfs hints */
|
|
||||||
gboolean energy_in_uamp;
|
|
||||||
gboolean power_in_uamp;
|
|
||||||
/* values */
|
/* values */
|
||||||
gboolean present;
|
gboolean present;
|
||||||
gint energy_now;
|
gint level_now;
|
||||||
gint energy_full;
|
gint level_full;
|
||||||
gint power_now;
|
gint rate_now;
|
||||||
|
gchar unit;
|
||||||
ChargeState status;
|
ChargeState status;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,22 +74,23 @@ static void uevent_battery_plug()
|
|||||||
static struct uevent_notify psy_plug = {UEVENT_ADD | UEVENT_REMOVE, "power_supply", NULL, uevent_battery_plug};
|
static struct uevent_notify psy_plug = {UEVENT_ADD | UEVENT_REMOVE, "power_supply", NULL, uevent_battery_plug};
|
||||||
|
|
||||||
#define RETURN_ON_ERROR(err) \
|
#define RETURN_ON_ERROR(err) \
|
||||||
if (error) { \
|
if (err) { \
|
||||||
g_error_free(err); \
|
g_error_free(err); \
|
||||||
|
fprintf(stderr, RED "%s:%d: errror" RESET "\n", __FILE__, __LINE__); \
|
||||||
return FALSE; \
|
return FALSE; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList *batteries = NULL;
|
static GList *batteries = NULL;
|
||||||
static GList *mains = NULL;
|
static GList *mains = NULL;
|
||||||
|
|
||||||
static guint8 energy_to_percent(gint energy_now, gint energy_full)
|
static guint8 level_to_percent(gint level_now, gint level_full)
|
||||||
{
|
{
|
||||||
return 0.5 + ((energy_now <= energy_full ? energy_now : energy_full) * 100.0) / energy_full;
|
return 0.5 + ((level_now <= level_full ? level_now : level_full) * 100.0) / level_full;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum psy_type power_supply_get_type(const gchar *entryname)
|
static enum psy_type power_supply_get_type(const gchar *entryname)
|
||||||
{
|
{
|
||||||
gchar *path_type = g_build_filename("/sys/class/power_supply", entryname, "type", NULL);
|
gchar *path_type = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "type", NULL);
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gchar *type;
|
gchar *type;
|
||||||
gsize typelen;
|
gsize typelen;
|
||||||
@@ -99,6 +98,7 @@ static enum psy_type power_supply_get_type(const gchar *entryname)
|
|||||||
g_file_get_contents(path_type, &type, &typelen, &error);
|
g_file_get_contents(path_type, &type, &typelen, &error);
|
||||||
g_free(path_type);
|
g_free(path_type);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
return PSY_UNKNOWN;
|
return PSY_UNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -122,59 +122,53 @@ static gboolean init_linux_battery(struct psy_battery *bat)
|
|||||||
{
|
{
|
||||||
const gchar *entryname = bat->name;
|
const gchar *entryname = bat->name;
|
||||||
|
|
||||||
bat->energy_in_uamp = FALSE;
|
bat->path_present = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "present", NULL);
|
||||||
bat->power_in_uamp = FALSE;
|
|
||||||
|
|
||||||
bat->path_present = g_build_filename("/sys/class/power_supply", entryname, "present", NULL);
|
|
||||||
if (!g_file_test(bat->path_present, G_FILE_TEST_EXISTS)) {
|
if (!g_file_test(bat->path_present, G_FILE_TEST_EXISTS)) {
|
||||||
|
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||||
goto err0;
|
goto err0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bat->path_energy_now = g_build_filename("/sys/class/power_supply", entryname, "energy_now", NULL);
|
bat->path_level_now = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "energy_now", NULL);
|
||||||
if (!g_file_test(bat->path_energy_now, G_FILE_TEST_EXISTS)) {
|
bat->path_level_full =
|
||||||
g_free(bat->path_energy_now);
|
g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "energy_full", NULL);
|
||||||
bat->path_energy_now = g_build_filename("/sys/class/power_supply", entryname, "charge_now", NULL);
|
bat->path_rate_now = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "power_now", NULL);
|
||||||
bat->energy_in_uamp = TRUE;
|
bat->unit = 'W';
|
||||||
|
|
||||||
|
if (!g_file_test(bat->path_level_now, G_FILE_TEST_EXISTS) ||
|
||||||
|
!g_file_test(bat->path_level_full, G_FILE_TEST_EXISTS) ||
|
||||||
|
!g_file_test(bat->path_rate_now, G_FILE_TEST_EXISTS)) {
|
||||||
|
g_free(bat->path_level_now);
|
||||||
|
g_free(bat->path_level_full);
|
||||||
|
g_free(bat->path_rate_now);
|
||||||
|
bat->path_level_now =
|
||||||
|
g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "charge_now", NULL);
|
||||||
|
bat->path_level_full =
|
||||||
|
g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "charge_full", NULL);
|
||||||
|
bat->path_rate_now =
|
||||||
|
g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "current_now", NULL);
|
||||||
|
bat->unit = 'A';
|
||||||
}
|
}
|
||||||
if (!g_file_test(bat->path_energy_now, G_FILE_TEST_EXISTS)) {
|
if (!g_file_test(bat->path_level_now, G_FILE_TEST_EXISTS) ||
|
||||||
|
!g_file_test(bat->path_level_full, G_FILE_TEST_EXISTS) ||
|
||||||
|
!g_file_test(bat->path_rate_now, G_FILE_TEST_EXISTS)) {
|
||||||
|
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||||
goto err1;
|
goto err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bat->energy_in_uamp) {
|
bat->path_status = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "status", NULL);
|
||||||
bat->path_energy_full = g_build_filename("/sys/class/power_supply", entryname, "energy_full", NULL);
|
|
||||||
if (!g_file_test(bat->path_energy_full, G_FILE_TEST_EXISTS))
|
|
||||||
goto err2;
|
|
||||||
} else {
|
|
||||||
bat->path_energy_full = g_build_filename("/sys/class/power_supply", entryname, "charge_full", NULL);
|
|
||||||
if (!g_file_test(bat->path_energy_full, G_FILE_TEST_EXISTS))
|
|
||||||
goto err2;
|
|
||||||
}
|
|
||||||
|
|
||||||
bat->path_power_now = g_build_filename("/sys/class/power_supply", entryname, "power_now", NULL);
|
|
||||||
if (!g_file_test(bat->path_power_now, G_FILE_TEST_EXISTS)) {
|
|
||||||
g_free(bat->path_power_now);
|
|
||||||
bat->path_power_now = g_build_filename("/sys/class/power_supply", entryname, "current_now", NULL);
|
|
||||||
bat->power_in_uamp = TRUE;
|
|
||||||
}
|
|
||||||
if (!g_file_test(bat->path_power_now, G_FILE_TEST_EXISTS)) {
|
|
||||||
goto err3;
|
|
||||||
}
|
|
||||||
|
|
||||||
bat->path_status = g_build_filename("/sys/class/power_supply", entryname, "status", NULL);
|
|
||||||
if (!g_file_test(bat->path_status, G_FILE_TEST_EXISTS)) {
|
if (!g_file_test(bat->path_status, G_FILE_TEST_EXISTS)) {
|
||||||
goto err4;
|
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||||
|
goto err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
err4:
|
|
||||||
g_free(bat->path_status);
|
|
||||||
err3:
|
|
||||||
g_free(bat->path_power_now);
|
|
||||||
err2:
|
err2:
|
||||||
g_free(bat->path_energy_full);
|
g_free(bat->path_status);
|
||||||
err1:
|
err1:
|
||||||
g_free(bat->path_energy_now);
|
g_free(bat->path_level_now);
|
||||||
|
g_free(bat->path_level_full);
|
||||||
|
g_free(bat->path_rate_now);
|
||||||
err0:
|
err0:
|
||||||
g_free(bat->path_present);
|
g_free(bat->path_present);
|
||||||
|
|
||||||
@@ -185,8 +179,9 @@ static gboolean init_linux_mains(struct psy_mains *ac)
|
|||||||
{
|
{
|
||||||
const gchar *entryname = ac->name;
|
const gchar *entryname = ac->name;
|
||||||
|
|
||||||
ac->path_online = g_build_filename("/sys/class/power_supply", entryname, "online", NULL);
|
ac->path_online = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "online", NULL);
|
||||||
if (!g_file_test(ac->path_online, G_FILE_TEST_EXISTS)) {
|
if (!g_file_test(ac->path_online, G_FILE_TEST_EXISTS)) {
|
||||||
|
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||||
g_free(ac->path_online);
|
g_free(ac->path_online);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -199,9 +194,9 @@ static void psy_battery_free(gpointer data)
|
|||||||
struct psy_battery *bat = data;
|
struct psy_battery *bat = data;
|
||||||
g_free(bat->name);
|
g_free(bat->name);
|
||||||
g_free(bat->path_status);
|
g_free(bat->path_status);
|
||||||
g_free(bat->path_power_now);
|
g_free(bat->path_rate_now);
|
||||||
g_free(bat->path_energy_full);
|
g_free(bat->path_level_full);
|
||||||
g_free(bat->path_energy_now);
|
g_free(bat->path_level_now);
|
||||||
g_free(bat->path_present);
|
g_free(bat->path_present);
|
||||||
g_free(bat);
|
g_free(bat);
|
||||||
}
|
}
|
||||||
@@ -232,10 +227,10 @@ static void add_battery(const char *entryname)
|
|||||||
|
|
||||||
if (init_linux_battery(bat)) {
|
if (init_linux_battery(bat)) {
|
||||||
batteries = g_list_append(batteries, bat);
|
batteries = g_list_append(batteries, bat);
|
||||||
fprintf(stdout, "found battery \"%s\"\n", bat->name);
|
fprintf(stdout, GREEN "Found battery \"%s\"" RESET "\n", bat->name);
|
||||||
} else {
|
} else {
|
||||||
g_free(bat);
|
g_free(bat);
|
||||||
fprintf(stderr, RED "failed to initialize battery \"%s\"" RESET "\n", entryname);
|
fprintf(stderr, RED "Failed to initialize battery \"%s\"" RESET "\n", entryname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,10 +241,10 @@ static void add_mains(const char *entryname)
|
|||||||
|
|
||||||
if (init_linux_mains(ac)) {
|
if (init_linux_mains(ac)) {
|
||||||
mains = g_list_append(mains, ac);
|
mains = g_list_append(mains, ac);
|
||||||
fprintf(stdout, "found mains \"%s\"\n", ac->name);
|
fprintf(stdout, GREEN "Found mains \"%s\"" RESET "\n", ac->name);
|
||||||
} else {
|
} else {
|
||||||
g_free(ac);
|
g_free(ac);
|
||||||
fprintf(stderr, RED "failed to initialize mains \"%s\"" RESET "\n", entryname);
|
fprintf(stderr, RED "Failed to initialize mains \"%s\"" RESET "\n", entryname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,10 +256,13 @@ gboolean battery_os_init()
|
|||||||
|
|
||||||
battery_os_free();
|
battery_os_free();
|
||||||
|
|
||||||
directory = g_dir_open("/sys/class/power_supply", 0, &error);
|
gchar *dir_path = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", NULL);
|
||||||
|
directory = g_dir_open(dir_path, 0, &error);
|
||||||
|
g_free(dir_path);
|
||||||
RETURN_ON_ERROR(error);
|
RETURN_ON_ERROR(error);
|
||||||
|
|
||||||
while ((entryname = g_dir_read_name(directory))) {
|
while ((entryname = g_dir_read_name(directory))) {
|
||||||
|
fprintf(stderr, GREEN "Found power device %s" RESET "\n", entryname);
|
||||||
enum psy_type type = power_supply_get_type(entryname);
|
enum psy_type type = power_supply_get_type(entryname);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -287,15 +285,15 @@ gboolean battery_os_init()
|
|||||||
return batteries != NULL;
|
return batteries != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint estimate_power_usage(struct psy_battery *bat, gint old_energy_now, gint64 old_timestamp)
|
static gint estimate_rate_usage(struct psy_battery *bat, gint old_level_now, gint64 old_timestamp)
|
||||||
{
|
{
|
||||||
gint64 diff_power = ABS(bat->energy_now - old_energy_now);
|
gint64 diff_level = ABS(bat->level_now - old_level_now);
|
||||||
gint64 diff_time = bat->timestamp - old_timestamp;
|
gint64 diff_time = bat->timestamp - old_timestamp;
|
||||||
|
|
||||||
/* µW = (µWh * 3600) / (µs / 1000000) */
|
/* µW = (µWh * 3600) / (µs / 1000000) */
|
||||||
gint power = diff_power * 3600 * 1000000 / MAX(1, diff_time);
|
gint rate = diff_level * 3600 * 1000000 / MAX(1, diff_time);
|
||||||
|
|
||||||
return power;
|
return rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean update_linux_battery(struct psy_battery *bat)
|
static gboolean update_linux_battery(struct psy_battery *bat)
|
||||||
@@ -305,15 +303,15 @@ static gboolean update_linux_battery(struct psy_battery *bat)
|
|||||||
gsize datalen;
|
gsize datalen;
|
||||||
|
|
||||||
gint64 old_timestamp = bat->timestamp;
|
gint64 old_timestamp = bat->timestamp;
|
||||||
int old_energy_now = bat->energy_now;
|
int old_level_now = bat->level_now;
|
||||||
gint old_power_now = bat->power_now;
|
gint old_rate_now = bat->rate_now;
|
||||||
|
|
||||||
/* reset values */
|
/* reset values */
|
||||||
bat->present = 0;
|
bat->present = 0;
|
||||||
bat->status = BATTERY_UNKNOWN;
|
bat->status = BATTERY_UNKNOWN;
|
||||||
bat->energy_now = 0;
|
bat->level_now = 0;
|
||||||
bat->energy_full = 0;
|
bat->level_full = 0;
|
||||||
bat->power_now = 0;
|
bat->rate_now = 0;
|
||||||
bat->timestamp = g_get_monotonic_time();
|
bat->timestamp = g_get_monotonic_time();
|
||||||
|
|
||||||
/* present */
|
/* present */
|
||||||
@@ -339,35 +337,35 @@ static gboolean update_linux_battery(struct psy_battery *bat)
|
|||||||
}
|
}
|
||||||
g_free(data);
|
g_free(data);
|
||||||
|
|
||||||
/* energy now */
|
/* level now */
|
||||||
g_file_get_contents(bat->path_energy_now, &data, &datalen, &error);
|
g_file_get_contents(bat->path_level_now, &data, &datalen, &error);
|
||||||
RETURN_ON_ERROR(error);
|
RETURN_ON_ERROR(error);
|
||||||
bat->energy_now = atoi(data);
|
bat->level_now = atoi(data);
|
||||||
g_free(data);
|
g_free(data);
|
||||||
|
|
||||||
/* energy full */
|
/* level full */
|
||||||
g_file_get_contents(bat->path_energy_full, &data, &datalen, &error);
|
g_file_get_contents(bat->path_level_full, &data, &datalen, &error);
|
||||||
RETURN_ON_ERROR(error);
|
RETURN_ON_ERROR(error);
|
||||||
bat->energy_full = atoi(data);
|
bat->level_full = atoi(data);
|
||||||
g_free(data);
|
g_free(data);
|
||||||
|
|
||||||
/* power now */
|
/* rate now */
|
||||||
g_file_get_contents(bat->path_power_now, &data, &datalen, &error);
|
g_file_get_contents(bat->path_rate_now, &data, &datalen, &error);
|
||||||
if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NODEV)) {
|
if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NODEV)) {
|
||||||
/* some hardware does not support reading current power consumption */
|
/* some hardware does not support reading current rate consumption */
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
bat->power_now = estimate_power_usage(bat, old_energy_now, old_timestamp);
|
bat->rate_now = estimate_rate_usage(bat, old_level_now, old_timestamp);
|
||||||
if (bat->power_now == 0 && bat->status != BATTERY_FULL) {
|
if (bat->rate_now == 0 && bat->status != BATTERY_FULL) {
|
||||||
/* If the hardware updates the level slower than our sampling period,
|
/* If the hardware updates the level slower than our sampling period,
|
||||||
* we need to sample more rarely */
|
* we need to sample more rarely */
|
||||||
bat->power_now = old_power_now;
|
bat->rate_now = old_rate_now;
|
||||||
bat->timestamp = old_timestamp;
|
bat->timestamp = old_timestamp;
|
||||||
}
|
}
|
||||||
} else if (error) {
|
} else if (error) {
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
bat->power_now = atoi(data);
|
bat->rate_now = atoi(data);
|
||||||
g_free(data);
|
g_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,9 +392,9 @@ int battery_os_update(BatteryState *state)
|
|||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
gint64 total_energy_now = 0;
|
gint64 total_level_now = 0;
|
||||||
gint64 total_energy_full = 0;
|
gint64 total_level_full = 0;
|
||||||
gint64 total_power_now = 0;
|
gint64 total_rate_now = 0;
|
||||||
gint seconds = 0;
|
gint seconds = 0;
|
||||||
|
|
||||||
gboolean charging = FALSE;
|
gboolean charging = FALSE;
|
||||||
@@ -408,9 +406,9 @@ int battery_os_update(BatteryState *state)
|
|||||||
struct psy_battery *bat = l->data;
|
struct psy_battery *bat = l->data;
|
||||||
update_linux_battery(bat);
|
update_linux_battery(bat);
|
||||||
|
|
||||||
total_energy_now += bat->energy_now;
|
total_level_now += bat->level_now;
|
||||||
total_energy_full += bat->energy_full;
|
total_level_full += bat->level_full;
|
||||||
total_power_now += bat->power_now;
|
total_rate_now += bat->rate_now;
|
||||||
|
|
||||||
charging |= (bat->status == BATTERY_CHARGING);
|
charging |= (bat->status == BATTERY_CHARGING);
|
||||||
discharging |= (bat->status == BATTERY_DISCHARGING);
|
discharging |= (bat->status == BATTERY_DISCHARGING);
|
||||||
@@ -432,17 +430,17 @@ int battery_os_update(BatteryState *state)
|
|||||||
state->state = BATTERY_FULL;
|
state->state = BATTERY_FULL;
|
||||||
|
|
||||||
/* calculate seconds */
|
/* calculate seconds */
|
||||||
if (total_power_now > 0) {
|
if (total_rate_now > 0) {
|
||||||
if (state->state == BATTERY_CHARGING)
|
if (state->state == BATTERY_CHARGING)
|
||||||
seconds = 3600 * (total_energy_full - total_energy_now) / total_power_now;
|
seconds = 3600 * (total_level_full - total_level_now) / total_rate_now;
|
||||||
else if (state->state == BATTERY_DISCHARGING)
|
else if (state->state == BATTERY_DISCHARGING)
|
||||||
seconds = 3600 * total_energy_now / total_power_now;
|
seconds = 3600 * total_level_now / total_rate_now;
|
||||||
seconds = MAX(0, seconds);
|
seconds = MAX(0, seconds);
|
||||||
}
|
}
|
||||||
battery_state_set_time(state, seconds);
|
battery_state_set_time(state, seconds);
|
||||||
|
|
||||||
/* calculate percentage */
|
/* calculate percentage */
|
||||||
state->percentage = energy_to_percent(total_energy_now, total_energy_full);
|
state->percentage = level_to_percent(total_level_now, total_level_full);
|
||||||
|
|
||||||
/* AC state */
|
/* AC state */
|
||||||
state->ac_connected = ac_connected;
|
state->ac_connected = ac_connected;
|
||||||
@@ -450,11 +448,10 @@ int battery_os_update(BatteryState *state)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *energy_human_readable(struct psy_battery *bat)
|
static gchar *level_human_readable(struct psy_battery *bat)
|
||||||
{
|
{
|
||||||
gint now = bat->energy_now;
|
gint now = bat->level_now;
|
||||||
gint full = bat->energy_full;
|
gint full = bat->level_full;
|
||||||
gchar unit = bat->energy_in_uamp ? 'A' : 'W';
|
|
||||||
|
|
||||||
if (full >= 1000000) {
|
if (full >= 1000000) {
|
||||||
return g_strdup_printf("%d.%d / %d.%d %ch",
|
return g_strdup_printf("%d.%d / %d.%d %ch",
|
||||||
@@ -462,30 +459,30 @@ static gchar *energy_human_readable(struct psy_battery *bat)
|
|||||||
(now % 1000000) / 100000,
|
(now % 1000000) / 100000,
|
||||||
full / 1000000,
|
full / 1000000,
|
||||||
(full % 1000000) / 100000,
|
(full % 1000000) / 100000,
|
||||||
unit);
|
bat->unit);
|
||||||
} else if (full >= 1000) {
|
} else if (full >= 1000) {
|
||||||
return g_strdup_printf("%d.%d / %d.%d m%ch",
|
return g_strdup_printf("%d.%d / %d.%d m%ch",
|
||||||
now / 1000,
|
now / 1000,
|
||||||
(now % 1000) / 100,
|
(now % 1000) / 100,
|
||||||
full / 1000,
|
full / 1000,
|
||||||
(full % 1000) / 100,
|
(full % 1000) / 100,
|
||||||
unit);
|
bat->unit);
|
||||||
} else {
|
} else {
|
||||||
return g_strdup_printf("%d / %d µ%ch", now, full, unit);
|
return g_strdup_printf("%d / %d µ%ch", now, full, bat->unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *power_human_readable(struct psy_battery *bat)
|
static gchar *rate_human_readable(struct psy_battery *bat)
|
||||||
{
|
{
|
||||||
gint power = bat->power_now;
|
gint rate = bat->rate_now;
|
||||||
gchar unit = bat->power_in_uamp ? 'A' : 'W';
|
gchar unit = bat->unit;
|
||||||
|
|
||||||
if (power >= 1000000) {
|
if (rate >= 1000000) {
|
||||||
return g_strdup_printf("%d.%d %c", power / 1000000, (power % 1000000) / 100000, unit);
|
return g_strdup_printf("%d.%d %c", rate / 1000000, (rate % 1000000) / 100000, unit);
|
||||||
} else if (power >= 1000) {
|
} else if (rate >= 1000) {
|
||||||
return g_strdup_printf("%d.%d m%c", power / 1000, (power % 1000) / 100, unit);
|
return g_strdup_printf("%d.%d m%c", rate / 1000, (rate % 1000) / 100, unit);
|
||||||
} else if (power > 0) {
|
} else if (rate > 0) {
|
||||||
return g_strdup_printf("%d µ%c", power, unit);
|
return g_strdup_printf("%d µ%c", rate, unit);
|
||||||
} else {
|
} else {
|
||||||
return g_strdup_printf("0 %c", unit);
|
return g_strdup_printf("0 %c", unit);
|
||||||
}
|
}
|
||||||
@@ -510,16 +507,16 @@ char *battery_os_tooltip()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *power = power_human_readable(bat);
|
gchar *rate = rate_human_readable(bat);
|
||||||
gchar *energy = energy_human_readable(bat);
|
gchar *level = level_human_readable(bat);
|
||||||
gchar *state = (bat->status == BATTERY_UNKNOWN) ? "Level" : chargestate2str(bat->status);
|
gchar *state = (bat->status == BATTERY_UNKNOWN) ? "energy" : chargestate2str(bat->status);
|
||||||
|
|
||||||
guint8 percentage = energy_to_percent(bat->energy_now, bat->energy_full);
|
guint8 percentage = level_to_percent(bat->level_now, bat->level_full);
|
||||||
|
|
||||||
g_string_append_printf(tooltip, "\t%s: %s (%u %%)\n\tPower: %s", state, energy, percentage, power);
|
g_string_append_printf(tooltip, "\t%s: %s (%u %%)\n\trate: %s", state, level, percentage, rate);
|
||||||
|
|
||||||
g_free(power);
|
g_free(rate);
|
||||||
g_free(energy);
|
g_free(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (l = mains; l != NULL; l = l->next) {
|
for (l = mains; l != NULL; l = l->next) {
|
||||||
|
|||||||
13
src/tint.c
13
src/tint.c
@@ -422,9 +422,22 @@ void init(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} else if (i + 1 == argc) {
|
} else if (i + 1 == argc) {
|
||||||
config_path = strdup(argv[i]);
|
config_path = strdup(argv[i]);
|
||||||
|
}
|
||||||
|
#ifdef ENABLE_BATTERY
|
||||||
|
else if (strcmp(argv[i], "--battery-sys-prefix") == 0) {
|
||||||
|
if (i + 1 < argc) {
|
||||||
|
i++;
|
||||||
|
battery_sys_prefix = strdup(argv[i]);
|
||||||
} else {
|
} else {
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
else {
|
||||||
|
error = 1;
|
||||||
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
printf("Usage: tint2 [[-c] <config_file>]\n");
|
printf("Usage: tint2 [[-c] <config_file>]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|||||||
163
test/acer-chromebook-c100pa/out.txt
Normal file
163
test/acer-chromebook-c100pa/out.txt
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
/sys/class/power_supply/bq27500-0/
|
||||||
|
cat: /sys/class/power_supply/bq27500-0/: Is a directory
|
||||||
|
/sys/class/power_supply/bq27500-0/temp
|
||||||
|
236
|
||||||
|
/sys/class/power_supply/bq27500-0/type
|
||||||
|
Battery
|
||||||
|
/sys/class/power_supply/bq27500-0/power_avg
|
||||||
|
65324
|
||||||
|
/sys/class/power_supply/bq27500-0/power
|
||||||
|
cat: /sys/class/power_supply/bq27500-0/power: Is a directory
|
||||||
|
/sys/class/power_supply/bq27500-0/power/control
|
||||||
|
auto
|
||||||
|
/sys/class/power_supply/bq27500-0/power/async
|
||||||
|
disabled
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup_abort_count
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup_active
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup_type
|
||||||
|
unknown
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup_total_time_ms
|
||||||
|
46
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup_active_count
|
||||||
|
3
|
||||||
|
/sys/class/power_supply/bq27500-0/power/runtime_enabled
|
||||||
|
disabled
|
||||||
|
/sys/class/power_supply/bq27500-0/power/runtime_active_kids
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/bq27500-0/power/runtime_active_time
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup_max_time_ms
|
||||||
|
16
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup_count
|
||||||
|
3
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup_last_time_ms
|
||||||
|
264291
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup
|
||||||
|
enabled
|
||||||
|
/sys/class/power_supply/bq27500-0/power/autosuspend_delay_ms
|
||||||
|
cat: /sys/class/power_supply/bq27500-0/power/autosuspend_delay_ms: Input/output error
|
||||||
|
/sys/class/power_supply/bq27500-0/power/runtime_status
|
||||||
|
unsupported
|
||||||
|
/sys/class/power_supply/bq27500-0/power/runtime_usage
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/bq27500-0/power/wakeup_expire_count
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/bq27500-0/power/runtime_suspended_time
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/bq27500-0/charge_full_design
|
||||||
|
8180000
|
||||||
|
/sys/class/power_supply/bq27500-0/current_now
|
||||||
|
-498000
|
||||||
|
/sys/class/power_supply/bq27500-0/charge_now
|
||||||
|
7253000
|
||||||
|
/sys/class/power_supply/bq27500-0/charge_full
|
||||||
|
7323000
|
||||||
|
/sys/class/power_supply/bq27500-0/device
|
||||||
|
cat: /sys/class/power_supply/bq27500-0/device: Is a directory
|
||||||
|
/sys/class/power_supply/bq27500-0/capacity
|
||||||
|
98
|
||||||
|
/sys/class/power_supply/bq27500-0/health
|
||||||
|
Good
|
||||||
|
/sys/class/power_supply/bq27500-0/subsystem
|
||||||
|
cat: /sys/class/power_supply/bq27500-0/subsystem: Is a directory
|
||||||
|
/sys/class/power_supply/bq27500-0/capacity_level
|
||||||
|
Normal
|
||||||
|
/sys/class/power_supply/bq27500-0/status
|
||||||
|
Discharging
|
||||||
|
/sys/class/power_supply/bq27500-0/voltage_now
|
||||||
|
4260000
|
||||||
|
/sys/class/power_supply/bq27500-0/uevent
|
||||||
|
POWER_SUPPLY_NAME=bq27500-0
|
||||||
|
POWER_SUPPLY_STATUS=Discharging
|
||||||
|
POWER_SUPPLY_PRESENT=1
|
||||||
|
POWER_SUPPLY_VOLTAGE_NOW=4260000
|
||||||
|
POWER_SUPPLY_CURRENT_NOW=-498000
|
||||||
|
POWER_SUPPLY_CAPACITY=98
|
||||||
|
POWER_SUPPLY_CAPACITY_LEVEL=Normal
|
||||||
|
POWER_SUPPLY_TEMP=236
|
||||||
|
POWER_SUPPLY_TIME_TO_EMPTY_NOW=40980
|
||||||
|
POWER_SUPPLY_TIME_TO_EMPTY_AVG=0
|
||||||
|
POWER_SUPPLY_TIME_TO_FULL_NOW=441780
|
||||||
|
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||||
|
POWER_SUPPLY_CHARGE_FULL=7323000
|
||||||
|
POWER_SUPPLY_CHARGE_NOW=7253000
|
||||||
|
POWER_SUPPLY_CHARGE_FULL_DESIGN=8180000
|
||||||
|
POWER_SUPPLY_CYCLE_COUNT=46
|
||||||
|
POWER_SUPPLY_ENERGY_NOW=7253000
|
||||||
|
POWER_SUPPLY_POWER_AVG=65324
|
||||||
|
POWER_SUPPLY_HEALTH=Good
|
||||||
|
POWER_SUPPLY_MANUFACTURER=Texas Instruments
|
||||||
|
POWER_SUPPLY_MODEL_NAME=C100-80
|
||||||
|
/sys/class/power_supply/bq27500-0/energy_now
|
||||||
|
7253000
|
||||||
|
/sys/class/power_supply/bq27500-0/model_name
|
||||||
|
C100-80
|
||||||
|
/sys/class/power_supply/bq27500-0/manufacturer
|
||||||
|
Texas Instruments
|
||||||
|
/sys/class/power_supply/bq27500-0/technology
|
||||||
|
Li-ion
|
||||||
|
/sys/class/power_supply/bq27500-0/cycle_count
|
||||||
|
46
|
||||||
|
/sys/class/power_supply/bq27500-0/time_to_full_now
|
||||||
|
441780
|
||||||
|
/sys/class/power_supply/bq27500-0/time_to_empty_avg
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/bq27500-0/time_to_empty_now
|
||||||
|
40980
|
||||||
|
/sys/class/power_supply/bq27500-0/present
|
||||||
|
1
|
||||||
|
/sys/class/power_supply/gpio-charger/
|
||||||
|
cat: /sys/class/power_supply/gpio-charger/: Is a directory
|
||||||
|
/sys/class/power_supply/gpio-charger/type
|
||||||
|
Mains
|
||||||
|
/sys/class/power_supply/gpio-charger/power
|
||||||
|
cat: /sys/class/power_supply/gpio-charger/power: Is a directory
|
||||||
|
/sys/class/power_supply/gpio-charger/power/control
|
||||||
|
auto
|
||||||
|
/sys/class/power_supply/gpio-charger/power/async
|
||||||
|
disabled
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup_abort_count
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup_active
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup_type
|
||||||
|
unknown
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup_total_time_ms
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup_active_count
|
||||||
|
1
|
||||||
|
/sys/class/power_supply/gpio-charger/power/runtime_enabled
|
||||||
|
disabled
|
||||||
|
/sys/class/power_supply/gpio-charger/power/runtime_active_kids
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/power/runtime_active_time
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup_max_time_ms
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup_count
|
||||||
|
1
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup_last_time_ms
|
||||||
|
349
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup
|
||||||
|
enabled
|
||||||
|
/sys/class/power_supply/gpio-charger/power/autosuspend_delay_ms
|
||||||
|
cat: /sys/class/power_supply/gpio-charger/power/autosuspend_delay_ms: Input/output error
|
||||||
|
/sys/class/power_supply/gpio-charger/power/runtime_status
|
||||||
|
unsupported
|
||||||
|
/sys/class/power_supply/gpio-charger/power/runtime_usage
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/power/wakeup_expire_count
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/power/runtime_suspended_time
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/device
|
||||||
|
cat: /sys/class/power_supply/gpio-charger/device: Is a directory
|
||||||
|
/sys/class/power_supply/gpio-charger/subsystem
|
||||||
|
cat: /sys/class/power_supply/gpio-charger/subsystem: Is a directory
|
||||||
|
/sys/class/power_supply/gpio-charger/online
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/gpio-charger/uevent
|
||||||
|
POWER_SUPPLY_NAME=gpio-charger
|
||||||
|
POWER_SUPPLY_ONLINE=0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
98
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Normal
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
7323000
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
8180000
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
7253000
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
-498000
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
46
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
7253000
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Good
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Texas Instruments
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
C100-80
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
disabled
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
auto
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
disabled
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
unsupported
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
enabled
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
264291
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
16
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
46
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
unknown
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
65324
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Discharging
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Li-ion
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
236
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
40980
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
441780
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Battery
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
POWER_SUPPLY_NAME=bq27500-0
|
||||||
|
POWER_SUPPLY_STATUS=Discharging
|
||||||
|
POWER_SUPPLY_PRESENT=1
|
||||||
|
POWER_SUPPLY_VOLTAGE_NOW=4260000
|
||||||
|
POWER_SUPPLY_CURRENT_NOW=-498000
|
||||||
|
POWER_SUPPLY_CAPACITY=98
|
||||||
|
POWER_SUPPLY_CAPACITY_LEVEL=Normal
|
||||||
|
POWER_SUPPLY_TEMP=236
|
||||||
|
POWER_SUPPLY_TIME_TO_EMPTY_NOW=40980
|
||||||
|
POWER_SUPPLY_TIME_TO_EMPTY_AVG=0
|
||||||
|
POWER_SUPPLY_TIME_TO_FULL_NOW=441780
|
||||||
|
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||||
|
POWER_SUPPLY_CHARGE_FULL=7323000
|
||||||
|
POWER_SUPPLY_CHARGE_NOW=7253000
|
||||||
|
POWER_SUPPLY_CHARGE_FULL_DESIGN=8180000
|
||||||
|
POWER_SUPPLY_CYCLE_COUNT=46
|
||||||
|
POWER_SUPPLY_ENERGY_NOW=7253000
|
||||||
|
POWER_SUPPLY_POWER_AVG=65324
|
||||||
|
POWER_SUPPLY_HEALTH=Good
|
||||||
|
POWER_SUPPLY_MANUFACTURER=Texas Instruments
|
||||||
|
POWER_SUPPLY_MODEL_NAME=C100-80
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
4260000
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
disabled
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
auto
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
disabled
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
unsupported
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
enabled
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
349
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
unknown
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Mains
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
POWER_SUPPLY_NAME=gpio-charger
|
||||||
|
POWER_SUPPLY_ONLINE=0
|
||||||
37
test/expand.py
Executable file
37
test/expand.py
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
|
# Creates directory tree printed by:
|
||||||
|
# bash -c "for d in /sys/class/power_supply/* ; do find $d/ -exec sh -c 'echo {} ; cat {} ' ';' ; done" 2>&1 | tee out.txt
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def flush(path, content):
|
||||||
|
if not path:
|
||||||
|
return
|
||||||
|
if content.startswith("cat: %s: Is a directory" % path):
|
||||||
|
try:
|
||||||
|
os.makedirs("./" + path)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
elif content.startswith("cat: %s:" % path):
|
||||||
|
with open("./" + path, "w") as f:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
with open("./" + path, "w") as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
|
|
||||||
|
with open(sys.argv[1], "r") as f:
|
||||||
|
path = None
|
||||||
|
content = ""
|
||||||
|
for line in f:
|
||||||
|
if line.startswith("/"):
|
||||||
|
flush(path, content)
|
||||||
|
content = ""
|
||||||
|
path = line.strip()
|
||||||
|
else:
|
||||||
|
content += line
|
||||||
|
if content:
|
||||||
|
flush(path, content)
|
||||||
154
test/lenovo/out.txt
Normal file
154
test/lenovo/out.txt
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
/sys/class/power_supply/BAT0/
|
||||||
|
cat: /sys/class/power_supply/BAT0/: Is a directory
|
||||||
|
/sys/class/power_supply/BAT0/type
|
||||||
|
Battery
|
||||||
|
/sys/class/power_supply/BAT0/power_now
|
||||||
|
16382000
|
||||||
|
/sys/class/power_supply/BAT0/alarm
|
||||||
|
2446000
|
||||||
|
/sys/class/power_supply/BAT0/power
|
||||||
|
cat: /sys/class/power_supply/BAT0/power: Is a directory
|
||||||
|
/sys/class/power_supply/BAT0/power/control
|
||||||
|
auto
|
||||||
|
/sys/class/power_supply/BAT0/power/async
|
||||||
|
disabled
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_enabled
|
||||||
|
disabled
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_active_kids
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_active_time
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/power/autosuspend_delay_ms
|
||||||
|
cat: /sys/class/power_supply/BAT0/power/autosuspend_delay_ms: Input/output error
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_status
|
||||||
|
unsupported
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_usage
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_suspended_time
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/device
|
||||||
|
cat: /sys/class/power_supply/BAT0/device: Is a directory
|
||||||
|
/sys/class/power_supply/BAT0/capacity
|
||||||
|
97
|
||||||
|
/sys/class/power_supply/BAT0/subsystem
|
||||||
|
cat: /sys/class/power_supply/BAT0/subsystem: Is a directory
|
||||||
|
/sys/class/power_supply/BAT0/capacity_level
|
||||||
|
Normal
|
||||||
|
/sys/class/power_supply/BAT0/status
|
||||||
|
Discharging
|
||||||
|
/sys/class/power_supply/BAT0/voltage_now
|
||||||
|
12144000
|
||||||
|
/sys/class/power_supply/BAT0/uevent
|
||||||
|
POWER_SUPPLY_NAME=BAT0
|
||||||
|
POWER_SUPPLY_STATUS=Discharging
|
||||||
|
POWER_SUPPLY_PRESENT=1
|
||||||
|
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||||
|
POWER_SUPPLY_CYCLE_COUNT=0
|
||||||
|
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
|
||||||
|
POWER_SUPPLY_VOLTAGE_NOW=12144000
|
||||||
|
POWER_SUPPLY_POWER_NOW=16382000
|
||||||
|
POWER_SUPPLY_ENERGY_FULL_DESIGN=86580000
|
||||||
|
POWER_SUPPLY_ENERGY_FULL=48920000
|
||||||
|
POWER_SUPPLY_ENERGY_NOW=47660000
|
||||||
|
POWER_SUPPLY_CAPACITY=97
|
||||||
|
POWER_SUPPLY_CAPACITY_LEVEL=Normal
|
||||||
|
POWER_SUPPLY_MODEL_NAME=45N1029
|
||||||
|
POWER_SUPPLY_MANUFACTURER=LGC
|
||||||
|
POWER_SUPPLY_SERIAL_NUMBER= 494
|
||||||
|
/sys/class/power_supply/BAT0/energy_now
|
||||||
|
47660000
|
||||||
|
/sys/class/power_supply/BAT0/model_name
|
||||||
|
45N1029
|
||||||
|
/sys/class/power_supply/BAT0/manufacturer
|
||||||
|
LGC
|
||||||
|
/sys/class/power_supply/BAT0/technology
|
||||||
|
Li-ion
|
||||||
|
/sys/class/power_supply/BAT0/cycle_count
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/energy_full_design
|
||||||
|
86580000
|
||||||
|
/sys/class/power_supply/BAT0/voltage_min_design
|
||||||
|
11100000
|
||||||
|
/sys/class/power_supply/BAT0/serial_number
|
||||||
|
494
|
||||||
|
/sys/class/power_supply/BAT0/energy_full
|
||||||
|
48920000
|
||||||
|
/sys/class/power_supply/BAT0/present
|
||||||
|
1
|
||||||
|
/sys/class/power_supply/BAT0/
|
||||||
|
cat: /sys/class/power_supply/BAT0/: Is a directory
|
||||||
|
/sys/class/power_supply/BAT0/type
|
||||||
|
Battery
|
||||||
|
/sys/class/power_supply/BAT0/power_now
|
||||||
|
16382000
|
||||||
|
/sys/class/power_supply/BAT0/alarm
|
||||||
|
2446000
|
||||||
|
/sys/class/power_supply/BAT0/power
|
||||||
|
cat: /sys/class/power_supply/BAT0/power: Is a directory
|
||||||
|
/sys/class/power_supply/BAT0/power/control
|
||||||
|
auto
|
||||||
|
/sys/class/power_supply/BAT0/power/async
|
||||||
|
disabled
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_enabled
|
||||||
|
disabled
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_active_kids
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_active_time
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/power/autosuspend_delay_ms
|
||||||
|
cat: /sys/class/power_supply/BAT0/power/autosuspend_delay_ms: Input/output error
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_status
|
||||||
|
unsupported
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_usage
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/power/runtime_suspended_time
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/device
|
||||||
|
cat: /sys/class/power_supply/BAT0/device: Is a directory
|
||||||
|
/sys/class/power_supply/BAT0/capacity
|
||||||
|
97
|
||||||
|
/sys/class/power_supply/BAT0/subsystem
|
||||||
|
cat: /sys/class/power_supply/BAT0/subsystem: Is a directory
|
||||||
|
/sys/class/power_supply/BAT0/capacity_level
|
||||||
|
Normal
|
||||||
|
/sys/class/power_supply/BAT0/status
|
||||||
|
Discharging
|
||||||
|
/sys/class/power_supply/BAT0/voltage_now
|
||||||
|
12144000
|
||||||
|
/sys/class/power_supply/BAT0/uevent
|
||||||
|
POWER_SUPPLY_NAME=BAT0
|
||||||
|
POWER_SUPPLY_STATUS=Discharging
|
||||||
|
POWER_SUPPLY_PRESENT=1
|
||||||
|
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||||
|
POWER_SUPPLY_CYCLE_COUNT=0
|
||||||
|
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
|
||||||
|
POWER_SUPPLY_VOLTAGE_NOW=12144000
|
||||||
|
POWER_SUPPLY_POWER_NOW=16382000
|
||||||
|
POWER_SUPPLY_ENERGY_FULL_DESIGN=86580000
|
||||||
|
POWER_SUPPLY_ENERGY_FULL=48920000
|
||||||
|
POWER_SUPPLY_ENERGY_NOW=47660000
|
||||||
|
POWER_SUPPLY_CAPACITY=97
|
||||||
|
POWER_SUPPLY_CAPACITY_LEVEL=Normal
|
||||||
|
POWER_SUPPLY_MODEL_NAME=45N1029
|
||||||
|
POWER_SUPPLY_MANUFACTURER=LGC
|
||||||
|
POWER_SUPPLY_SERIAL_NUMBER= 494
|
||||||
|
/sys/class/power_supply/BAT0/energy_now
|
||||||
|
47660000
|
||||||
|
/sys/class/power_supply/BAT0/model_name
|
||||||
|
45N1029
|
||||||
|
/sys/class/power_supply/BAT0/manufacturer
|
||||||
|
LGC
|
||||||
|
/sys/class/power_supply/BAT0/technology
|
||||||
|
Li-ion
|
||||||
|
/sys/class/power_supply/BAT0/cycle_count
|
||||||
|
0
|
||||||
|
/sys/class/power_supply/BAT0/energy_full_design
|
||||||
|
86580000
|
||||||
|
/sys/class/power_supply/BAT0/voltage_min_design
|
||||||
|
11100000
|
||||||
|
/sys/class/power_supply/BAT0/serial_number
|
||||||
|
494
|
||||||
|
/sys/class/power_supply/BAT0/energy_full
|
||||||
|
48920000
|
||||||
|
/sys/class/power_supply/BAT0/present
|
||||||
|
1
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/alarm
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/alarm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
2446000
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/capacity
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/capacity
Normal file
@@ -0,0 +1 @@
|
|||||||
|
97
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/capacity_level
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/capacity_level
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Normal
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/cycle_count
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/cycle_count
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/energy_full
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/energy_full
Normal file
@@ -0,0 +1 @@
|
|||||||
|
48920000
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
86580000
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/energy_now
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/energy_now
Normal file
@@ -0,0 +1 @@
|
|||||||
|
47660000
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/manufacturer
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/manufacturer
Normal file
@@ -0,0 +1 @@
|
|||||||
|
LGC
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/model_name
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/model_name
Normal file
@@ -0,0 +1 @@
|
|||||||
|
45N1029
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/power/async
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/power/async
Normal file
@@ -0,0 +1 @@
|
|||||||
|
disabled
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/power/control
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/power/control
Normal file
@@ -0,0 +1 @@
|
|||||||
|
auto
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
disabled
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
unsupported
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/power_now
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/power_now
Normal file
@@ -0,0 +1 @@
|
|||||||
|
16382000
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/present
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/present
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/serial_number
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/serial_number
Normal file
@@ -0,0 +1 @@
|
|||||||
|
494
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/status
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/status
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Discharging
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/technology
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/technology
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Li-ion
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/type
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/type
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Battery
|
||||||
16
test/lenovo/sys/class/power_supply/BAT0/uevent
Normal file
16
test/lenovo/sys/class/power_supply/BAT0/uevent
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
POWER_SUPPLY_NAME=BAT0
|
||||||
|
POWER_SUPPLY_STATUS=Discharging
|
||||||
|
POWER_SUPPLY_PRESENT=1
|
||||||
|
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||||
|
POWER_SUPPLY_CYCLE_COUNT=0
|
||||||
|
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
|
||||||
|
POWER_SUPPLY_VOLTAGE_NOW=12144000
|
||||||
|
POWER_SUPPLY_POWER_NOW=16382000
|
||||||
|
POWER_SUPPLY_ENERGY_FULL_DESIGN=86580000
|
||||||
|
POWER_SUPPLY_ENERGY_FULL=48920000
|
||||||
|
POWER_SUPPLY_ENERGY_NOW=47660000
|
||||||
|
POWER_SUPPLY_CAPACITY=97
|
||||||
|
POWER_SUPPLY_CAPACITY_LEVEL=Normal
|
||||||
|
POWER_SUPPLY_MODEL_NAME=45N1029
|
||||||
|
POWER_SUPPLY_MANUFACTURER=LGC
|
||||||
|
POWER_SUPPLY_SERIAL_NUMBER= 494
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
11100000
|
||||||
1
test/lenovo/sys/class/power_supply/BAT0/voltage_now
Normal file
1
test/lenovo/sys/class/power_supply/BAT0/voltage_now
Normal file
@@ -0,0 +1 @@
|
|||||||
|
12144000
|
||||||
Reference in New Issue
Block a user