]> Dogcows Code - chaz/tint2/commitdiff
lower battery drawing : update to 10s and battery_hide config
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Tue, 19 Jan 2010 19:29:28 +0000 (19:29 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Tue, 19 Jan 2010 19:29:28 +0000 (19:29 +0000)
src/battery/battery.c
src/battery/battery.h
src/config.c

index 8d64f825cbf8b36243faa6af85c0013bbeda774a..d10c10163a491f62562ac03ede1255afda805dcf 100644 (file)
@@ -37,6 +37,7 @@ PangoFontDescription *bat1_font_desc=0;
 PangoFontDescription *bat2_font_desc=0;
 struct batstate battery_state;
 int battery_enabled;
+int percentage_hide = 101;
 static timeout* battery_timeout=0;
 
 static char buf_bat_percentage[10];
@@ -54,8 +55,26 @@ void update_batterys(void* arg)
 {
        int i;
        update_battery();
-       for (i=0 ; i < nb_panel ; i++)
+       for (i=0 ; i < nb_panel ; i++) {
+               if (battery_state.percentage >= percentage_hide) {
+                       if (panel1[i].battery.area.on_screen == 1) {
+                               panel1[i].battery.area.on_screen = 0;
+                               // force resize on panel
+                               panel1[i].area.resize = 1;
+                               panel_refresh = 1;
+                       }
+                       continue;
+               }
+               else {
+                       if (panel1[i].battery.area.on_screen == 0) {
+                               panel1[i].battery.area.on_screen = 1;
+                               // force resize on panel
+                               panel1[i].area.resize = 1;
+                               panel_refresh = 1;
+                       }
+               }
                panel1[i].battery.area.resize = 1;
+       }
 }
 
 
@@ -133,7 +152,7 @@ void init_battery()
        g_free(battery_dir);
 
        if (battery_enabled && battery_timeout==0)
-               battery_timeout = add_timeout(10, 5000, update_batterys, 0);
+               battery_timeout = add_timeout(10, 10000, update_batterys, 0);
 }
 
 
index 0fcedb52126011f54c344df66a6f52f851b5c567..39f9b11d30f877eaeaa55164c3d274f268489102 100644 (file)
@@ -51,6 +51,7 @@ extern struct batstate battery_state;
 extern PangoFontDescription *bat1_font_desc;
 extern PangoFontDescription *bat2_font_desc;
 extern int battery_enabled;
+extern int percentage_hide;
 
 extern int8_t battery_low_status;
 extern char *battery_low_cmd;
index 9977574b93b12e91119d4946c7e6f08ac60e191f..c159a30e043da926cfdd4654570ad315401d8c92 100644 (file)
@@ -358,6 +358,13 @@ void add_entry (char *key, char *value)
                panel_config.battery.area.bg = &g_array_index(backgrounds, Background, id);
 #endif
        }
+       else if (strcmp (key, "battery_hide") == 0) {
+#ifdef ENABLE_BATTERY
+               percentage_hide = atoi (value);
+               if (percentage_hide == 0)
+                       percentage_hide = 101;
+#endif
+       }
 
        /* Clock */
        else if (strcmp (key, "time1_format") == 0) {
This page took 0.024773 seconds and 4 git commands to generate.