Add plugin: Battery & Power Management#864
Conversation
- Percentage & remaining time - Popup controls in a padded pill
This comment was marked as resolved.
This comment was marked as resolved.
7fa2f19 to
9593250
Compare
This comment was marked as resolved.
This comment was marked as resolved.
9593250 to
a5f28c9
Compare
spiros132
left a comment
There was a problem hiding this comment.
Some feedback about the PR! :)
| # ------------------------------ | ||
| set -e | ||
|
|
||
| RULE_FILE="99-battery-threshold.rules" |
There was a problem hiding this comment.
Is this rules file supposed to be in this directory as well?
There was a problem hiding this comment.
The file was missing. Now it's fixed, no need for the file, the script writes it itself.
|
|
||
| ## Installation & Setup | ||
|
|
||
| ### 1\. Copy the Assets |
There was a problem hiding this comment.
This part isn't correct, the user needs only to go to their settings and install the plugin from there.
| Once permissions are initialized, trigger a reload or restart your Noctalia desktop interface instance to initialize the components: | ||
|
|
||
| killall quickshell | ||
| noctalia |
There was a problem hiding this comment.
This is not at all how you re-run noctalia.
There was a problem hiding this comment.
Removed, setting the udev rule requires logout and login so it was redundant
|
|
||
| readonly property string screenName: screen ? (screen.name ?? "") : "" | ||
| readonly property real capsuleHeight: (typeof Style !== "undefined" && typeof Style.getCapsuleHeightForScreen === "function") ? Style.getCapsuleHeightForScreen(root.screenName) : 26 | ||
| readonly property real barFontSize: (typeof Style !== "undefined" && typeof Style.getBarFontSizeForScreen === "function") ? Style.getBarFontSizeForScreen(root.screenName) : 10 |
There was a problem hiding this comment.
Style should never be undefined. You don't need to check if it is or not.
| readonly property string screenName: screen ? (screen.name ?? "") : "" | ||
| readonly property real capsuleHeight: (typeof Style !== "undefined" && typeof Style.getCapsuleHeightForScreen === "function") ? Style.getCapsuleHeightForScreen(root.screenName) : 26 | ||
| readonly property real barFontSize: (typeof Style !== "undefined" && typeof Style.getBarFontSizeForScreen === "function") ? Style.getBarFontSizeForScreen(root.screenName) : 10 | ||
| readonly property string fixedFont: (typeof Settings !== "undefined" && Settings.data?.ui?.fontFixed) ? Settings.data.ui.fontFixed : "monospace" |
There was a problem hiding this comment.
Here neither, Style will always be defined if the imports are correct.
| Layout.preferredHeight: 64 * Style.uiScaleRatio | ||
|
|
||
| color: (typeof Color !== "undefined") ? Color.mSurfaceVariant : "#313244" | ||
| radius: (typeof Style !== "undefined") ? (Style.capsuleRadius ?? Style.radiusM) : 6 |
There was a problem hiding this comment.
Same thing as before here.
| if (root.mainWidget.batStatus === "Charging") { | ||
| return "Time to full: " + root.mainWidget.timeRemaining; | ||
| } else if (root.mainWidget.batStatus === "Discharging") { | ||
| return "Remaining: " + root.mainWidget.timeRemaining; |
There was a problem hiding this comment.
Shouldn't these be included in the translation?
There was a problem hiding this comment.
Yes, included translations. English and Italian
| } | ||
|
|
||
| Item { | ||
| id: customSlider |
There was a problem hiding this comment.
Is there a reason why this custom slider is needed? Why not use the noctalia slider?
There was a problem hiding this comment.
The noctalia default slider was a bit too big. But I fixed the poupo width and used the default slider.
| pointSize: Style.fontSizeS | ||
| color: parent.active | ||
| ? ((typeof Color !== "undefined") ? Color.mOnPrimary : "#ffffff") | ||
| : (parent.containsMouse ? ((typeof Color !== "undefined") ? Color.mPrimary : "#3355ff") : ((typeof Color !== "undefined") ? Color.mOnSurfaceVariant : "#a6adc8")) |
There was a problem hiding this comment.
As before, Color should never be undefined.
| "System", | ||
| "Indicator", | ||
| "Utility", | ||
| "Battery" |
There was a problem hiding this comment.
There's no tag called Battery
There was a problem hiding this comment.
"New tags can be added on a case-by-case basis. If your plugin doesn't fit the existing tags, feel free to propose a new one in your pull request."
I thought that this was the correct way to propose a new tag. I'll remove this by now.
There was a problem hiding this comment.
No no you are correct, although I personally would have expected to see a I would like to propose to add the Battery tag in the PR description.
Maybe Battery would be a good fit as a tag since there are some plugins that have to do with battery. If you want add the tag back and I'll merge it in with the new tag.
|
Thanks for the feedback. I'll work on them! |
…ns) and setup_rules.sh (now it creates the udev rule file)
spiros132
left a comment
There was a problem hiding this comment.
Looks great, just some minor things :)
| id: profileSetter | ||
| onExited: (code) => { | ||
| updatePowerProfile(); | ||
| if (code !== 0) console.warn("Error writing battery threshold."); |
There was a problem hiding this comment.
Do not use console.warn, always use Logger
| return root.mainWidget.wattNum.toFixed(1) + " W"; | ||
| } | ||
| if (root.mainWidget.batStatus === pluginApi?.tr("battery.status_charging")) return pluginApi?.tr("battery.time_to_full") + root.mainWidget.timeRemaining; | ||
| else if (root.mainWidget.batStatus === pluginApi?.tr("battery.status_discharging")) return pluginApi?.tr("battery.remaining") + root.mainWidget.timeRemaining; |
There was a problem hiding this comment.
On these two, instead of using string concatenation, prefer to use translation interpolation.
Description
This PR introduces the
Battery & Power Mangementplugin for the Noctalia desktop shell. It provides real-time battery diagnostics and power optimization directly from the panel.Features Included
W).powerprofilesctlbackend to alternate betweenpower-saver,balanced, andperformanceprofiles./sys/class/power_supply/BAT0/charge_control_end_threshold(clamped between 50% and 100%).README.htmldetailing setup instructions, prerequisites, and mandatory udev configurations for unprivileged sysfs writes.Testing Status
BarWidget.qmlandBatteryPopup.qml.