Image 01
profile-image

tomchiverton

tom chiverton
Enhanced Battery Monitor

Plasma 4 Widgets 51 comments

Score 79.3%
Dec 28 2013
Here is the patch updated for the latest release of this widget. Turn on 'show charge information' in the widget prefs to see the time remaining on the battery icon.

$ diff -u batterymonitor.qml.orig batterymonitor.qml
--- batterymonitor.qml.orig 2014-04-13 13:43:57.976169606 +0100
+++ batterymonitor.qml 2014-04-13 13:48:38.216181061 +0100
@@ -85,6 +85,7 @@
property bool hasBattery: view.singleBattery ? batteries.cumulativePluggedin : model["Plugged in"]
property int percent: view.singleBattery ? batteries.cumulativePercent : model["Percent"]
property bool pluggedIn: pmSource.data["AC Adapter"]["Plugged in"]
+ property int remainingMsec: Number(pmSource.data["Battery"]["Remaining msec"])

width: view.width/view.count
height: view.height
@@ -118,7 +119,7 @@

Text {
id: overlayText
- text: i18nc("overlay on the battery, needs to be really tiny", "%1%", percent);
+ text: show_remaining_time?formatDuration2(remainingMsec):i18nc("overlay on the battery, needs to be really tiny", "%1%", percent);
color: theme.textColor
font.pixelSize: Math.max(parent.size/8, 11)
anchors.centerIn: labelRect
@@ -236,4 +237,18 @@
}
}
}
+ function formatDuration2(msec) {
+ if (msec==0)
+ return "";
+
+ var time = new Date(msec);
+ var hours = time.getUTCHours();
+ var minutes = time.getUTCMinutes();
+ if (minutes<10)
+ minutes = "0"+minutes;
+ var str = hours+":"+minutes;
+
+ return str;
+}
+
}
- Apr 13 2014
I'd love to see this as an option, given the KDE developers feel they know better than their users and removed this feature (even as an option) https://bugs.kde.org/show_bug.cgi?id=304510 - Apr 25 2013