This is a convention I wish somebody else had thought of and publicized widely a long time ago... there should be one memorable command to see the most relevant power and sensor info on every Linux box. My convention is to call this pow
. It has to be implemented differently on different systems, although that could be automated in some kind of complicated "pow" package which noone has written, AFAIK.
ACPI-compatible PCs
A shell alias might be good enough:
alias pow='cat /proc/acpi/battery/BAT1/info | grep last | cat - /proc/acpi/battery/BAT1/state /proc/acpi/thermal_zone/THRM/temperature'
or you could use a script:
#!/bin/sh CHARGE_NOW=`cat /sys/class/power_supply/BAT0/charge_now` CHARGE_FULL=`cat /sys/class/power_supply/BAT0/charge_full` CHARGE_PERCENT=$(( $CHARGE_NOW * 100 / $CHARGE_FULL )) CHARGE_NOW=`cat /proc/acpi/battery/BAT0/state | grep remaining | cut -c26-` CHARGE_FULL=`cat /proc/acpi/battery/BAT0/info | grep last | cut -c26-` cat /proc/acpi/battery/BAT0/state | grep -v remaining echo "Charge: $CHARGE_NOW / $CHARGE_FULL = $CHARGE_PERCENT%" cat /proc/acpi/thermal_zone/TZS0/temperature /proc/acpi/thermal_zone/TZS1/temperature
which produces output like this:
[acer][02:10:26 PM] pow present: yes capacity state: ok charging state: charging present rate: 2200 mA present voltage: 11663 mV Charge: 1606 mAh / 3799 mAh = 42% temperature: 45 C temperature: 48 C
Apple Intel systems
Apple uses SMC (system management whatchamacallit) rather than ACPI. If the kernel has support for that, there will be some nodes under /sys/devices/platform/applesmc.768
on a mac mini; not sure if the 768 is different on other systems, or what. Here's another crude script (which would be better re-written in python):
#!/bin/sh for s in `ls /sys/devices/platform/applesmc.*/temp*` do integer=`cat $s | cut -c1-2` fraction=`cat $s | cut -c3-5` echo "temperature: $integer.$fraction" done for s in `ls /sys/devices/platform/applesmc.*/fan*output` do partial_path=`echo $s | cut -d'_' -f1` name=`echo $partial_path | cut -d'/' -f6` current=`cat $s` min=`cat ${partial_path}_min` max=`cat ${partial_path}_max` echo "$name: $current RPM (range $min - $max)" done
and its output looks like this:
[mini][03:40:05 PM] pow temperature: 59.750 temperature: 55.000 fan1: 1566 RPM (range 1000 - 5500)