aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tray.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/tray.c b/tray.c
index 058f741..0db6fb8 100644
--- a/tray.c
+++ b/tray.c
@@ -242,10 +242,23 @@ static void update_icon()
**********************************************************************/
static gboolean update()
{
+ static int last_bat_state = -1;
+ int now_bat_state = STATE_UNKNOWN;
unsigned int i;
- switch ( get_battery_state() )
+
+ update_tooltip_cache();
+ update_icon();
+
+ now_bat_state = get_battery_state();
+ if (now_bat_state == last_bat_state)
+ return true;
+
+ last_bat_state = now_bat_state;
+
+ switch ( now_bat_state )
{
case STATE_DISCHARGING:
+ fprintf(stderr, "discharging\n");
if (DEFAULT_BAT_GOV)
{
for (i = 0; i < gc_number(); i++)
@@ -255,6 +268,7 @@ static gboolean update()
case STATE_CHARGING:
case STATE_FULL:
+ fprintf(stderr, "ac power\n");
if (DEFAULT_AC_GOV)
{
for (i = 0; i < gc_number(); i++)
@@ -263,9 +277,6 @@ static gboolean update()
break;
}
-
- update_tooltip_cache();
- update_icon();
return true;
}