Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Battery device level reporting when fully charged - consistency between applets & settings. #742

Open
l-const opened this issue Nov 1, 2024 · 0 comments

Comments

@l-const
Copy link
Contributor

l-const commented Nov 1, 2024

In continuation to the fix of #561 , from analysis of what gnome does here:

Gnome-shell's implementation here: https://github.com/GNOME/gnome-shell/blob/d60bdc95faf3607ec579558074cf1ca919db041a/js/ui/status/system.js#L19-L85

const BUS_NAME = 'org.freedesktop.UPower';
const OBJECT_PATH = '/org/freedesktop/UPower/devices/DisplayDevice';

 // The icons
        let chargingState = this._proxy.State === UPower.DeviceState.CHARGING
            ? '-charging' : '';
        let fillLevel = 10 * Math.floor(this._proxy.Percentage / 10);
        const charged =
            this._proxy.State === UPower.DeviceState.FULLY_CHARGED ||
            (this._proxy.State === UPower.DeviceState.CHARGING && fillLevel === 100);
        const icon = charged
            ? 'battery-level-100-charged-symbolic'
            : `battery-level-${fillLevel}${chargingState}-symbolic`;

we should add an additional check for DeviceState.FULLY_CHARGED to not render any time to empty / time to full. & also render the thunder icon:

 const charged =
            this._proxy.State === UPower.DeviceState.FULLY_CHARGED ||
            (this._proxy.State === UPower.DeviceState.CHARGING && fillLevel === 100);
        const icon = charged
            ? 'battery-level-100-charged-symbolic'

i can see that we do not have a battery-level-100-charged-symbolic' but essentially it would be the equivalent of the -charging- one in our case. Here is a screenshot of the existing icons:

Screenshot 2024-11-01 at 6 45 07 PM Screenshot 2024-11-01 at 6 46 22 PM

Note: Checking that the battery-level == 100 to denote that it is fully-charged is a valid way to go from what i understand from this original implementation:
https://gitlab.freedesktop.org/upower/upower/-/blob/master/src/linux/up-device-idevice.c?ref_type=heads#L285-294

/* get charging status */
	node = plist_dict_get_item (dict, "BatteryIsCharging");
	if (!node) {
		plist_free(dict);
		goto out;
	}
	plist_get_bool_val (node, &charging);

	if (percentage == 100)
		state = UP_DEVICE_STATE_FULLY_CHARGED;
	else if (percentage == 0)
		state = UP_DEVICE_STATE_EMPTY;
	else if (charging)
		state = UP_DEVICE_STATE_CHARGING;
	else
		state = UP_DEVICE_STATE_DISCHARGING; /* upower doesn't have a "not charging" state */

Somebody with a laptop that could test this thoroughly should pick this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant