This is how I do it;

#!/bin/sh
#
# Script used for giving system information
# Last modified: 27-01-2008

while : ;
do
        cpuspeed0=$(sysctl -n hw.cpuspeed)
        cputempe0=$(sysctl -n hw.sensors.cpu0.temp0)
        systempe0=$(sysctl -n hw.sensors.acpitz0.temp0)
        battcapa0=$(sysctl -n hw.sensors.acpibat0.amphour3)
        battchar0=$(sysctl -n hw.sensors.acpibat0.raw0)

        if [ "$cpuspeed1" != "$cpuspeed0" ] || [ "$cputempe1" != "$cputempe0" ] 
|| [ "$systempe1" != "$systempe0" ] || [ "$battcapa1" != "$battcapa0" ] || [ 
"$battchar1" != "$battchar0" ]; then
                cpuspeed1=$cpuspeed0
                cputempe1=$cputempe0
                systempe1=$systempe0
                battcapa1=$battcapa0
                battchar1=$battchar0

                battcapa1=$(echo $battcapa0 | sed 's/ Ah (.*//')
                percentage=$(echo "scale=2; $battcapa1*100/7.2" | bc)
                battinfo=$(echo $battchar0 | sed 's/.*(//' | sed 's/).*//')

                clear

                echo "OpenBSD Kernel version: $(sysctl -n kern.version)"
                echo ""
                echo "System speed             :   $cpuspeed0 Mhz"
                echo "Processor temperature    :   $cputempe0    "
                echo "System temperature       :   $systempe0    "
                echo "Battery information      :   $percentage %, $battcapa1 Ah 
($battinfo)"
        fi
        sleep 10
done

Reply via email to