aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2015-04-13 23:39:05 +1200
committerDavid Phillips <dbphillipsnz@gmail.com>2015-04-13 23:39:05 +1200
commit0c7da473eeb91750319b334f580fe10173f673df (patch)
tree360d4e8b43fec19d304f96ec63745e9a3c5f61db
parent153535632125325eedc781332b29b0ce0f114f94 (diff)
downloadparamano-0c7da473eeb91750319b334f580fe10173f673df.tar.xz
Fixed false time of 1 hour when battery info file wasn't found
-rw-r--r--bat_tray.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/bat_tray.c b/bat_tray.c
index 2de7ed2..3424037 100644
--- a/bat_tray.c
+++ b/bat_tray.c
@@ -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())