Linux

從命令行顯示/proc/acpi/battery/BAT0/info

  • October 1, 2018

在 MacBookPro10,1 上全新安裝 Debian/stable 9.5 時,我試圖從命令行顯示 acpi 資訊。

這是我看到的:

$ find /proc/acpi/
/proc/acpi/
/proc/acpi/button
/proc/acpi/button/lid
/proc/acpi/button/lid/LID0
/proc/acpi/button/lid/LID0/state
/proc/acpi/wakeup

acpi似乎還是看到了電池:

$ acpi -V
Battery 0: Discharging, 46%, 01:17:56 remaining
Battery 0: design capacity 8460 mAh, last full capacity 7415 mAh = 87%
Adapter 0: off-line
Cooling 0: Processor 0 of 17
Cooling 1: Processor 0 of 17
Cooling 2: Processor 0 of 17
Cooling 3: BAT0 no state information available
Cooling 4: Processor 0 of 17
Cooling 5: intel_powerclamp no state information available
Cooling 6: Processor 0 of 17
Cooling 7: Processor 0 of 17
Cooling 8: Processor 0 of 17
Cooling 9: x86_pkg_temp no state information available
Cooling 10: Processor 0 of 17

/proc/acpi為了從界面獲取正確的電池資訊,我在安裝過程中遺漏了什麼?

acpi查看在我的 Ubuntu 上執行的系統呼叫:

~ strace -e open,chdir acpi
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
chdir("/sys/class")                     = 0
chdir("power_supply")                   = 0
open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("BAT0/current_now", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("BAT0/power_now", O_RDONLY)        = 4
open("BAT0/charge_now", O_RDONLY)       = -1 ENOENT (No such file or directory)
open("BAT0/energy_now", O_RDONLY)       = 4
open("BAT0/voltage_now", O_RDONLY)      = 4
...

所以它似乎是從/sys/class/power_supply/*.

由於該功能是在 Debian 核心中提供的,/sys/class/power_supply/*並且是在沒有 Debian 核心的情況下建構的CONFIG_ACPI_PROCFS_POWER

$ grep CONFIG_ACPI_PROCFS_POWER /boot/config-$(uname -r)
# CONFIG_ACPI_PROCFS_POWER is not set

你不會再看到任何東西/proc/acpi/battery/*

引用自:https://unix.stackexchange.com/questions/472516