diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2015-04-13 23:39:05 +1200 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2015-04-13 23:39:05 +1200 |
commit | 0c7da473eeb91750319b334f580fe10173f673df (patch) | |
tree | 360d4e8b43fec19d304f96ec63745e9a3c5f61db | |
parent | 153535632125325eedc781332b29b0ce0f114f94 (diff) | |
download | paramano-0c7da473eeb91750319b334f580fe10173f673df.tar.xz |
Fixed false time of 1 hour when battery info file wasn't found
-rw-r--r-- | bat_tray.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -52,6 +52,11 @@ int get_bat_seconds_left() charge_now = get_int_value_from_file(file); free(file); + if (charge_now == -1 || current_now == -1) + { + return -1; + } + switch(get_battery_state()) { case STATE_CHARGING: @@ -81,11 +86,11 @@ static gboolean update_tooltip(GtkStatusIcon* status_icon,gint x,gint y,gboolean char* time_left; - if (seconds_left != -1) + if (seconds_left == -1) { - asprintf(&time_left, _("%02d:%02d:%02d left"), (int)(seconds_left/3600), (int)((seconds_left%3600)/60), seconds_left%60); - } else { asprintf(&time_left, _("Unknown time left")); + } else { + asprintf(&time_left, _("%02d:%02d:%02d left"), (int)(seconds_left/3600), (int)((seconds_left%3600)/60), seconds_left%60); } switch(get_battery_state()) |