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

add support for ac power supply #180

Open
ael-code opened this issue Nov 16, 2016 · 5 comments
Open

add support for ac power supply #180

ael-code opened this issue Nov 16, 2016 · 5 comments

Comments

@ael-code
Copy link

It would be really useful for me to see if the AC power supply is plugged and working. What do you think about adding support for it?

My /sys/class/power_supply/AC/uevent:

POWER_SUPPLY_NAME=AC
POWER_SUPPLY_ONLINE=1
@stapelberg
Copy link
Member

Can you clarify how this differs from your battery not discharging? I.e., the battery is not discharging if and only if the power supply is plugged in, so the two are equivalent, right?

@ael-code
Copy link
Author

On 11/17/2016 09:00 AM, Michael Stapelberg wrote:

Can you clarify how this differs from your battery not discharging?
I.e., the battery is not discharging if and only if the power supply is
plugged in, so the two are equivalent, right?

Actually is not exactly like that.

Having a look at the kernel
code

we could have 5 possible status:

POWER_SUPPLY_STATUS_UNKNOWN
POWER_SUPPLY_STATUS_CHARGING,
POWER_SUPPLY_STATUS_DISCHARGING
POWER_SUPPLY_STATUS_NOT_CHARGING
POWER_SUPPLY_STATUS_FULL

There are some thinkpad models that support charging thresholds. e.g.
you can set that your battery should not go above the 60% of capacity to
preserve it.

I think that the POWER_SUPPLY_STATUS_NOT_CHARGING is exactly to
express this condition. e.g. the battery is at 60%, the external power
supply is plugged in and the battery is not CHARGING.

I think that all of these 5 states should be supported by i3status.

@stapelberg
Copy link
Member

Let me rephrase: If you want to know whether your power supply is plugged in, check whether i3status displays “Discharging” as status. If not, then your power supply is plugged in.

I don’t think it’s necessary to implement a special case for the not_charging state.

@ael-code
Copy link
Author

ael-code commented Nov 19, 2016

On 11/19/2016 02:54 PM, Michael Stapelberg wrote:

Let me rephrase: If you want to know whether your power supply is
plugged in, check whether i3status displays “Discharging” as status. If
not, then your power supply is plugged in.

That's a good point, but what about the custom status string? I like
them because you can use icons in them that requires less time to read.

Looking at the code I find out that:

The kernel is providing 5 different states, the internal code of
i3status is mapping them in 4 different states and these states are then
mapped to 3 custom messages:

 STATUS_UNKNOWN         -> CS_UNKNOWN     -> status_bat
 STATUS_CHARGING        -> CS_CHARGING    -> status_chr
 STATUS_DISCHARGING     -> CS_DISCHARGING -> status_bat
 STATUS_NOT_DISCHARGING -> CS_UNKNOWN     -> status_bat
 STATUS_FULL            -> CS_FULL        -> status_full

Thus I think that it is impossible, using the custom strings, to
differentiate the two kernel status DISCHARGING and NOT_DISCHARGING.

Am I wrong?

I don’t think it’s necessary to implement a special case for the
not_charging state.

@stapelberg
Copy link
Member

Thus I think that it is impossible, using the custom strings, to
differentiate the two kernel status DISCHARGING and NOT_DISCHARGING

Correct, you cannot use the status_* options by themselves. You would need to use the %status format string. Issue #119 is related.

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

No branches or pull requests

3 participants