Debian Lenny Thinkpad config without Gnome - part 2
The next step in my thinkpad drama is hardware monitoring. It’s a laptop, right? I found a way to get battery state, battery charge, system load, CPU tempurature and date/time. DWM is clever with it’s “toolbar” in that it takes a text string via stdin and shoves it into the top right status bar. So how do I get all of this hardware info into a nicely formated single line of text? Here’s how.
Download and compile the tp-smapi kernel modules.
Install this script, taken from minimalblue.com
#!/bin/sh
battery() {
case `cat /sys/bus/platform/devices/smapi/BAT0/state` in
idle)
charge_type="="
time_left="==="
;;
charging)
charge_type="+"
time_left=`cat /sys/bus/platform/devices/smapi/BAT0/remaining_charging_time`
;;
discharging)
charge_type="-"
time_left=`cat /sys/bus/platform/devices/smapi/BAT0/remaining_running_time`
;;
*)
charge_type="?"
time_left="???"
;;
esac
echo "${charge_type}${time_left}"
}
temp() {
awk '{ print $2 }' /proc/acpi/thermal_zone/THM0/temperature
}
load() {
cut -d' ' -f1 /proc/loadavg
}
echo "temp: `temp`C | sys: `load` | bat: `battery` | `date`"
Now you have to launch DWM with this script as an argument to DWM. This is my .xinitrc, as I’m starting my session through startx.
while true; do
$HOME/.dwm/status
sleep 1
done | dwm
That’ll give you a nice status display at the top.
Next up…capturing the thinkpad keys for suspend and brightness, as well as any other arbitrary command you’d like to call.