]> Dogcows Code - chaz/tint2/commitdiff
issue 87 : another try
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 31 May 2009 17:32:49 +0000 (17:32 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 31 May 2009 17:32:49 +0000 (17:32 +0000)
src/battery/battery.c
src/tint2

index c07f072a8e11dd0ba7da2d4772d23f8043f6454e..f0bb1ff0a0749efa3cf24c583065d230c17e6b58 100644 (file)
@@ -140,10 +140,27 @@ void init_battery()
                }
        }
        if (battery_dir != 0) {
-               path_energy_now = g_build_filename(battery_dir, "energy_now", NULL);
-               path_energy_full = g_build_filename(battery_dir, "energy_full", NULL);
+               char *path1 = g_build_filename(battery_dir, "energy_now", NULL);
+               if (g_file_test (path1, G_FILE_TEST_EXISTS)) {
+                       path_energy_now = g_build_filename(battery_dir, "energy_now", NULL);
+                       path_energy_full = g_build_filename(battery_dir, "energy_full", NULL);
+               }
+               else {
+                       char *path2 = g_build_filename(battery_dir, "charge_now", NULL);
+                       if (g_file_test (path2, G_FILE_TEST_EXISTS)) {
+                               path_energy_now = g_build_filename(battery_dir, "charge_now", NULL);
+                               path_energy_full = g_build_filename(battery_dir, "charge_full", NULL);
+                       }
+                       else {
+                               g_free(battery_dir);
+                               battery_dir = 0;
+                               fprintf(stderr, "ERROR: can't found energy_* or charge_*\n");
+                       }
+                       g_free(path2);
+               }
                path_current_now = g_build_filename(battery_dir, "current_now", NULL);
                path_status = g_build_filename(battery_dir, "status", NULL);
+               g_free(path1);
        }
 
        FILE *fp;
index 5f9d2354e3960c0f03b4f077299e6b371fdc2af8..b9e7d04d71ee303fa6a38a120ad8371e12180ea4 100755 (executable)
Binary files a/src/tint2 and b/src/tint2 differ
This page took 0.028505 seconds and 4 git commands to generate.