noctalia-shell icon indicating copy to clipboard operation
noctalia-shell copied to clipboard

[FEATURE] Battery/Power Profiles Lockscreen Widget Noctalia v5

Open IndigoTeddy13 opened this issue 1 month ago • 3 comments

Submission checklist

  • [x] I have searched existing issues and confirmed this has not been requested before.
  • [x] I have checked existing pull requests for similar changes.

Feature type

Configuration / customization

Feature summary

I would like to be able to see my battery state while the screen is locked. I could not find such a lockscreen-compatible widget in the default list, hence why I am making a feature request.

Motivation / use case

Such a widget would allow me to see the battery charge/discharge status while the screen is locked. Ideally, it would also quickly toggle between power profiles (ie: turn on power-saver). I do not believe it should be necessary to depend on the security practices of a community plugin just to monitor the battery.

Proposed solution

If possible, could you please take the existing logic behind your native battery and power-profiles widgets and package them into a lockscreen-compatible widget? It does not need to be exceptionally large (ie: a small horizontal rectangle just to have the options visible). Could you potentially merge and extend something like yocraft/battery-widget (in Issue #3436) to the main project to achieve this?

Alternatives considered

I have attempted to use a solution I used back when I was using hyprlock, by reusing a script to try to rewrite the contents of a label/button (it did not work). I also tried to translate the logic to Noctalia's Luau syntax, but did not understand the Noctalia-specific schema well enough to do so. hyprlock.conf segment concerning battery display (default hyprlock lacks a native battery widget):

# Battery Info
label {
    monitor =
    text = cmd[update:1000] echo -e "$(~/.config/hypr/show-battery.sh)"
    color = rgba(255, 255, 255, 1)
    font_size = 20
    font_family = JetBrains Mono ExtraBold
    position = 850, 540
    halign = center
    valign = center
}

show-battery.sh script:

#!/usr/bin/env bash

# Get current battery percentage
batteryPercentage=$(cat /sys/class/power_supply/BAT0/capacity)

# Get battery status (Charging or Discharging)
batteryStatus=$(cat /sys/class/power_supply/BAT0/status)

# Define the battery icons for each 10% segment
batteryIcons=("󰂃" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰁹")

# Define the charging icon
chargingIcon="󰂄"

# Calculate the index for the icon array
iconIndex=$((batteryPercentage / 10))

# Get the corresponding icon
currentIcon=${batteryIcons[iconIndex]}

# Check if the battery is charging
if [ "$batteryStatus" = "Charging" ]; then
	currentIcon="$chargingIcon"
fi

# Output the battery percentage and icon
echo "$batteryPercentage% $currentIcon"

References / related projects

No response

Additional context

Thank you in advance for your support, and I hope you will have a great day.

IndigoTeddy13 avatar Oct 21 '26 14:10 IndigoTeddy13

What is the issue with it being a plugin ? There is no security issue, Noctalia plugins are trusted, even community plugins are all reviewed by the devs on each update. A plugin author can't push an update without the devs approving it.

If you are missing some features in the plugin, feel free to request them and I will add them, there is already a lot of options and nothing should be missing from the built-in bar widget.

Yocraft-2000 avatar Oct 21 '26 16:10 Yocraft-2000

Thank you for clarifying the security situation with community plugins. I was unsure if they were handled differently from official plugins, since they were separated out in the web store. To clarify, I was talking about desktop/lockscreen widgets. I agree that the built-in bar widget is more than enough when logged in; however, not every bar widget has an equivalent lockscreen counterpart, hence the original question. If possible, would you be willing to consider a button to the existing yocraft/battery-widget plugin to toggle power profiles? Otherwise, I am satisfied, and am OK with closing this issue.

IndigoTeddy13 avatar Oct 23 '26 01:10 IndigoTeddy13

I will add configurable click actions to the plugin.

Yocraft-2000 avatar Oct 23 '26 09:10 Yocraft-2000