-
-
Notifications
You must be signed in to change notification settings - Fork 7
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 full support for acpi #12
Conversation
oops! i found although my linux don't have |
because we just only wanna know if the battery is charging, not the method of |
https://github.com/lambdalisue/battery.vim/blob/master/autoload/battery/backend/linux.vim#L2 let s:Job = vital#battery#import('System.Job')
|
I'll check it in this weekend. Ping me if I've not replied even after the weekend. |
Well... What is the conclusion? It seems the code tried to glob from Additionally, do you have documentation about each path? It seems Yes, it's not used here. |
thanks. i have deleted this line which is not used.
you are right. now i have rewrited it.
According to Linux|Android)
# See https://sourceforge.net/projects/acpiclient.
local -a bats=( /sys/class/power_supply/(CMB*|BAT*|battery)/(FN) ) the original documents can be found in |
autoload/battery/backend/linux.vim
Outdated
let s:bat_files = glob('/sys/class/power_supply/{CMD*,BAT*,battery}/{status,capacity}', 0, 1) | ||
let s:bat_status = get(s:bat_files, 0, '') | ||
let s:bat_capacity = get(s:bat_files, 1, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s:bat_capacity
might get wrong path when there are several match on the first pattern.
Assume that you have
├── a
│ ├── a
│ ├── b
│ └── c
└── b
├── a
├── b
└── c
And then
:echo glob('./{a,b}/{a,b}', 0, 1)
['./a/a/', './a/b/', './b/a/', './b/b/']
Probably, it's better to use glob in each variables like
let s:bat_files = glob('/sys/class/power_supply/{CMD*,BAT*,battery}/{status,capacity}', 0, 1) | |
let s:bat_status = get(s:bat_files, 0, '') | |
let s:bat_capacity = get(s:bat_files, 1, '') | |
let s:bat_status = get(glob('/sys/class/power_supply/{CMD*,BAT*,battery}/status', 0, 1), 0, '') | |
let s:bat_capacity = get(glob('/sys/class/power_supply/{CMD*,BAT*,battery}/capacity', 0, 1), 0, '') |
great. now it can work. |
👍 |
Not all acpi client of linux use
/sys/class/power_supply/AC*/online
to showif the battery is charging (at least my distribution).
/sys/class/power_supply/BAT*/status
can did the same function.after this change, now it can work in my linux.
And not only
/sys/class/power_supply/BAT*/status
, refer https://github.com/romkatv/powerlevel10k/blob/master/internal/p10k.zsh#L1326:for example, my android use
/sys/class/power_supply/battery/status
not
/sys/class/power_supply/BAT*/status
.the backend can also work for android which work for root user (in android,
only root can have privilege to read
/sys
). for android work for non-rootuser, the #9 is also a
valid substitution.
thanks for your review.