tempicon -a tray icon to monitor CPU temp
Posted: Sun 01 Jan 2012, 21:58
This is icewm in Saluki
READ-ONLY Archive
https://oldforum.puppylinux.com/
Excellent. Much easier to read thanks.01micko wrote:I've been sitting on this for awhile..
new svg based tempicon remove older versions first!!!
- See main post
Code: Select all
AMD Family 10h thermal sensors... Success!
(driver `k10temp')
Code: Select all
ver=0.04
Here you go mate.01micko wrote:...Can you post your module please? I'll whack it in PPM.
Code: Select all
#!/bin/ash
awk '{BG = "#00FF00"
if ($2 > 65) BG = "#FFFF00"
if ($2 > 80) BG = "#FF0000"
printf "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"> \
<rect width=\"32\" height=\"22\" x=\"0\" y=\"0\" \
style=\"font-size:%d;fill:%s;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;\" id=\"rect1\" /> \
<text x=\"0\" y=\"18\" style=\"font-size:%d;font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:helvetica;\" id=\"text1\"> \
<tspan id=\"tspan1\">%d°C</tspan> \
</text> \
</svg>",14,BG,14,$2}' /proc/acpi/thermal_zone/TZ01/temperature >test.svg
Tried this and I get:technosaurus wrote:I have made a generic tool to do this using symlinks:
http://www.murga-linux.com/puppy/viewtopic.php?t=76431
you should be able to adjust your backend to only update a single file and the binary is smaller too.
edit: and here is an awk example that I used to generate the svg for my cpuCode: Select all
#!/bin/ash awk '{BG = "#00FF00" if ($2 > 65) BG = "#FFFF00" if ($2 > 80) BG = "#FF0000" printf "<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> \ <rect width="32" height="22" x="0" y="0" \ style="font-size:%d;fill:%s;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;" id="rect1" /> \ <text x="0" y="18" style="font-size:%d;font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:helvetica;" id="text1"> \ <tspan id="tspan1">%d°C</tspan> \ </text> \ </svg>",14,BG,14,$2}' /proc/acpi/thermal_zone/TZ01/temperature >test.svg
Code: Select all
awk: cmd. line:4: printf "<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> \
awk: cmd. line:4: ^ unterminated string
awk: cmd. line:4: printf "<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> \
awk: cmd. line:4: ^ syntax error
Code: Select all
int main() {
char c=127;
while (c-->=-127) {
printf("%d, %c\n",c,c);
}
}
Code: Select all
#!/bin/bash
#set -x
# Records the CPU temp, calls "sit" to display in system tray
# depends: sit[2] (technosaurus http://murga-linux.com/puppy/viewtopic.php?t=76431)
# other unix: +gtkdialog
#########EXPERIMENTAL###########
ver=0.01
PREFIX=`dirname $0`
export PREFIX
PROG=`basename $0`
[ ! -d /tmp/tempsit ] && mkdir /tmp/tempsit
TMPDIR=/tmp/tempsit
#usage
usagefunc(){
echo " -h|-help -show this help and exit "
echo " -v|-version -show the $PROG version and exit"
echo " -t|-togle-startup -Controls if you want to run $PROG at Startup, exits program"
echo "NOTE: Only one argument to $PROG will be allowed"
}
#generate svg
text2svgfunc()
{
FFAMILY=helvetica FFS=14
[ -f /etc/fatdog-version ]&& FFAMILY=sans FFS=13
T=18
[ "$1" -ge "100" ] && T=$FFS
BG="#FF0000" #red (default)
[ "$1" -le "65" ] && BG="#00FF00" #green
[[ "$1" -gt "65" && "$1" -le "80" ]] && BG="#FFFF00" #yellow
echo '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="32"
height="22"
x="0"
y="0"
style="font-size:'${T}';fill:'$BG';fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"
id="rect1" />
<text
x="0"
y="18"
style="font-size:'${T}';font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:'$FFAMILY';"
id="text1">
<tspan
id="tspan1">'"${1}°"'</tspan>
</text>
</svg>' > $TMPDIR/temp.svg
}
#info
#infofunc()
cat > $TMPDIR/info.sh <<_EOF
#!/bin/bash
TMPDIR=/tmp/tempsit
ENCODING="\${LANG#*.}" #check UTF-8
[ "\$ENCODING" ]&& DEG='°' || DEG=' '
[ -f \$TMPDIR/count ] && TEMP=\$(cat \$TMPDIR/count)
TMP=\$TMPDIR/info
echo "Current CPU temperature is \${TEMP}\${DEG}C" > \$TMP
echo >> \$TMP
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null | grep -q ondemand
if [ \$? -eq 0 ]; then
echo "OnDemand CPU Scaling: on" >> \$TMP
else
echo "OnDemand CPU Scaling: off" >> \$TMP
fi
FREQ=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 2>/dev/null`
if [ -n "\$FREQ" ]; then
echo >> \$TMP
echo -n "Current CPU Frequency: " >> \$TMP
echo -n \${FREQ%???} MHz >> \$TMP
fi
echo -e '<window title="tempsit info">
<vbox>
<frame>
<text><input file>'\$TMP'</input></text>
</frame>
<hbox><button ok></button>
</hbox>
</vbox>
</window>' > $TMPDIR/infodisplay
_EOF
chmod 755 $TMPDIR/info.sh
case "$1" in
-h|-*help)usagefunc && exit ;;
-v|-*version)echo "${PROG}-${ver}" && exit ;;
-t|-*toggle-startup)
if [ -h $HOME/Startup/temp2tray ];then rm -f $HOME/Startup/temp2tray
MSG="removing $HOME/Startup/temp2tray"
else
ln -s $0 $HOME/Startup/temp2tray
MSG="creating startup file $HOME/Startup/temp2tray"
fi
echo "$MSG"
exit ;;
infogui)infofunc ;;
esac
[ ! -f $TMPDIR/temp.svg ] && SPID=1
#get cpu temp
cputempfunc(){
while [ ! $SPID = "" ]
do
#echo $SPID #debug
FILE=`find /sys/devices/ -name temp1_input|head -n1`
OUT1=`cat $FILE`
if [ ! $OUT1 ];then
FILE=`find /sys/bus/acpi/devices/ -name temp|head -n1`
OUT1=`cat $FILE`
fi
if [ ! $OUT1 ];then echo "not working" && break
else OUT=`echo ${OUT1%???}`
fi
echo ${OUT} > $TMPDIR/count
text2svgfunc $OUT &
sleep 5 #update at 5 sec intervals
SPID=$(pidof sit)
done
}
cputempfunc &
sleep 1
[ -f $TMPDIR/count ]&& VALUE=`cat $TMPDIR/count`
if [ ! $VALUE ];then
xmessage -c -bg pink "TEMPSIT ERROR: Your system isn't supported."
rm -f $HOME/Startup/temp2tray 2>/dev/null && exit
fi
#all good, run
THEICON=$TMPDIR/temp.svg
TOOLTIP="tempsit
CPU Temperature
Left click for more info
Right click to quit"
LCLICK="$TMPDIR/info.sh;gtkdialog -f $TMPDIR/infodisplay"
RCLICK="killall sit;rm -r $TMPDIR;"
sit "$THEICON" "$TOOLTIP" "$LCLICK" "$RCLICK"
Not off topic at all, the reason is the stability. I wasn't quite happy with it, now I m a little more happy. V 0.06 is currently in the Slacko repo. This version will be taking it's place.davids45 wrote:A little off-topic maybe, but I'm curious why this interesting little utility was not in Slacko (or is it and I couldn't/can't find it)?