aboutsummaryrefslogtreecommitdiff
path: root/src/device.c
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2021-04-01 12:50:12 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-05-03 22:57:55 +0200
commitf94ffac7f36831dd8a79f30d5b94de9758fcd3a6 (patch)
treea40946ba71c5a46c036065bb8da438c1f0bbf535 /src/device.c
parent773cf3e9005941241a8f4ee3caefd30650970967 (diff)
downloadayatana-indicator-power-f94ffac7f36831dd8a79f30d5b94de9758fcd3a6.tar.gz
ayatana-indicator-power-f94ffac7f36831dd8a79f30d5b94de9758fcd3a6.tar.bz2
ayatana-indicator-power-f94ffac7f36831dd8a79f30d5b94de9758fcd3a6.zip
Fix percentage for mice and keyboards
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/device.c b/src/device.c
index 05eb15e..91d7cf1 100644
--- a/src/device.c
+++ b/src/device.c
@@ -773,6 +773,15 @@ get_menuitem_text (const IndicatorPowerDevice * device,
time_str = get_expanded_time_remaining (device);
}
+ if (p->percentage > 0.01 && time_str != NULL)
+ {
+ if (g_str_equal(time_str, _("estimating…")) || g_str_equal(time_str, _("unknown")))
+ {
+ g_free(time_str);
+ time_str = NULL;
+ }
+ }
+
if (time_str && *time_str)
{
/* TRANSLATORS: example: "battery (time remaining)" */
@@ -780,7 +789,14 @@ get_menuitem_text (const IndicatorPowerDevice * device,
}
else
{
- str = g_strdup (kind_str);
+ if (p->percentage > 0.01)
+ {
+ str = g_strdup_printf("%s (%.0lf%%)", kind_str, p->percentage);
+ }
+ else
+ {
+ str = g_strdup (kind_str);
+ }
}
g_free (time_str);