]> Dogcows Code - chaz/tint2/blobdiff - src/battery/battery.c
*fix* issue 319
[chaz/tint2] / src / battery / battery.c
index fd4d59b26be8612418840b840b90266a969a3bb6..04c993486b8740c7938cbb401ac194a7580f783e 100644 (file)
@@ -194,8 +194,14 @@ void init_battery()
                }
                g_free(path2);
        }
-       if (path_energy_now && path_energy_full) {
+
+       path_current_now = g_build_filename(battery_dir, "power_now", NULL);
+       if (!g_file_test (path_current_now, G_FILE_TEST_EXISTS)) {
+               g_free(path_current_now);
                path_current_now = g_build_filename(battery_dir, "current_now", NULL);
+       }
+
+       if (path_energy_now && path_energy_full) {
                path_status = g_build_filename(battery_dir, "status", NULL);
 
                // check file
@@ -237,6 +243,8 @@ void init_battery_panel(void *p)
        battery->area._draw_foreground = draw_battery;
        battery->area.size_mode = SIZE_BY_CONTENT;
        battery->area._resize = resize_battery;
+       battery->area.on_screen = 1;
+       battery->area.resize = 1;
 }
 
 
@@ -452,8 +460,8 @@ int resize_battery(void *obj)
                if (new_size > battery->area.width || new_size < (battery->area.width-2)) {
                        // we try to limit the number of resize
                        battery->area.width =  new_size;
-                       battery->bat1_posy = ((battery->area.height - bat_percentage_height) / 2) - ((bat_time_height_ink + 2) / 2);
-                       battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2 - (bat_percentage_height - bat_percentage_height_ink)/2 - (bat_time_height - bat_time_height_ink)/2;
+                       battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height)/2;
+                       battery->bat2_posy = battery->bat1_posy + bat_percentage_height;
                        ret = 1;
                }
        }
@@ -461,8 +469,8 @@ int resize_battery(void *obj)
                int new_size = bat_percentage_height + bat_time_height + (2 * (battery->area.paddingxlr + battery->area.bg->border.width));
                if (new_size > battery->area.height || new_size < (battery->area.height-2)) {
                        battery->area.height =  new_size;
-                       battery->bat1_posy = ((battery->area.height - bat_percentage_height) / 2) - ((bat_time_height_ink + 2) / 2);
-                       battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2 - (bat_percentage_height - bat_percentage_height_ink)/2 - (bat_time_height - bat_time_height_ink)/2;
+                       battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2)/2;
+                       battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2;
                        ret = 1;
                }
        }
This page took 0.020998 seconds and 4 git commands to generate.