all repos — tint2 @ 3de424b129f87fbe0d6924a2797dfc96d99d39fc

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Allow batteries that do not provide the charging rate
o9000 mrovi9000@gmail.com
commit

3de424b129f87fbe0d6924a2797dfc96d99d39fc

parent

d8c289e0ccdbaa48bbda2c348d8f5a6a9117f5d0

1 files changed, 17 insertions(+), 15 deletions(-)

jump to
M src/battery/linux.csrc/battery/linux.c

@@ -73,11 +73,11 @@ reinit_battery();

} static struct uevent_notify psy_plug = {UEVENT_ADD | UEVENT_REMOVE, "power_supply", NULL, uevent_battery_plug}; -#define RETURN_ON_ERROR(err) \ - if (err) { \ - g_error_free(err); \ +#define RETURN_ON_ERROR(err) \ + if (err) { \ + g_error_free(err); \ fprintf(stderr, RED "tint2: %s:%d: errror" RESET "\n", __FILE__, __LINE__); \ - return FALSE; \ + return FALSE; \ } static GList *batteries = NULL;

@@ -96,12 +96,13 @@ gchar *type;

gsize typelen; g_file_get_contents(path_type, &type, &typelen, &error); - g_free(path_type); if (error) { - fprintf(stderr, RED "tint2: %s:%d: read failed" RESET "\n", __FILE__, __LINE__); + fprintf(stderr, RED "tint2: %s:%d: read failed for %s" RESET "\n", __FILE__, __LINE__, path_type); + g_free(path_type); g_error_free(error); return PSY_UNKNOWN; } + g_free(path_type); if (!g_strcmp0(type, "Battery\n")) { g_free(type);

@@ -124,7 +125,7 @@ const gchar *entryname = bat->name;

bat->path_present = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "present", NULL); if (!g_file_test(bat->path_present, G_FILE_TEST_EXISTS)) { - fprintf(stderr, RED "tint2: %s:%d: read failed" RESET "\n", __FILE__, __LINE__); + fprintf(stderr, RED "tint2: %s:%d: read failed for %s" RESET "\n", __FILE__, __LINE__, bat->path_present); goto err0; }

@@ -136,8 +137,7 @@ bat->path_rate_now = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "power_now", NULL);

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_file_test(bat->path_level_full, G_FILE_TEST_EXISTS)) { g_free(bat->path_level_now); g_free(bat->path_level_full); g_free(bat->path_rate_now);

@@ -149,16 +149,18 @@ 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_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 "tint2: %s:%d: read failed" RESET "\n", __FILE__, __LINE__); + if (!g_file_test(bat->path_level_now, G_FILE_TEST_EXISTS)) { + fprintf(stderr, RED "tint2: %s:%d: read failed for %s" RESET "\n", __FILE__, __LINE__, bat->path_level_now); + goto err1; + } + if (!g_file_test(bat->path_level_full, G_FILE_TEST_EXISTS)) { + fprintf(stderr, RED "tint2: %s:%d: read failed for %s" RESET "\n", __FILE__, __LINE__, bat->path_level_full); goto err1; } bat->path_status = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "status", NULL); if (!g_file_test(bat->path_status, G_FILE_TEST_EXISTS)) { - fprintf(stderr, RED "tint2: %s:%d: read failed" RESET "\n", __FILE__, __LINE__); + fprintf(stderr, RED "tint2: %s:%d: read failed for %s" RESET "\n", __FILE__, __LINE__, bat->path_status); goto err2; }

@@ -182,7 +184,7 @@ const gchar *entryname = ac->name;

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)) { - fprintf(stderr, RED "tint2: %s:%d: read failed" RESET "\n", __FILE__, __LINE__); + fprintf(stderr, RED "tint2: %s:%d: read failed for %s" RESET "\n", __FILE__, __LINE__, ac->path_online); g_free(ac->path_online); return FALSE; }