tempicon -a tray icon to monitor CPU temp

Miscellaneous tools
Message
Author
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#46 Post by technosaurus »

@micko I recently made an update to sit:
http://murga-linux.com/puppy/viewtopic.php?t=76431
It should work well with tempicon now that it just monitors each icon to see if it is modified via inotify and directly launches the left and right click apps (no need for a monitor loop any more).

Let me know if you are interested in using it. I think I have simplified it to the maximum extent possible (<20 lines of code) but would like some feedback. (for instance, would it make more sense to fork the click actions, so that icons continue to update while the click event is open?)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#47 Post by 01micko »

@techno

using sit2:

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"

But of course the function 'infofunc' doesn't work (see edit), have to create a separate script for sit to call.

Playing with this exposed a bug in tempicon so I'll fix that soon, it's in the main loop.

Thanks

EDIT: working now
Puppy Linux Blog - contact me for access

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#48 Post by 01micko »

Version 0.10 is out.

critical bugfix to kill the main loop if you quit the program


See main post

-

There's one Q I will answer
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)?
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.

I'm hoping this one will build and run on the raspi platform. Since it is passively cooled temperature stats will be interesting.
Puppy Linux Blog - contact me for access

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#49 Post by 01micko »

version -0.11 is posted

-bugfix

The main loop refused to start after X restart or restarting the prog manually

See main post
Puppy Linux Blog - contact me for access

User avatar
Pete22
Posts: 264
Joined: Fri 08 May 2009, 22:59
Location: Utah, USA

Tempicon working great in Saluki 23 with new Xfce desktop

#50 Post by Pete22 »

01micko

Thank you for a great program.
I wanted you to know that it works well with Saluki 23 that has the latest xfce desktop and panel.

I was wandering. Is there a way to change temp to Fahrenheit?

Pete.

User avatar
Pete22
Posts: 264
Joined: Fri 08 May 2009, 22:59
Location: Utah, USA

Its working now. Great.

#51 Post by Pete22 »

i was having trouble getting to work on 3rd machine, But I seem to have solved the problem.

Pete

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#52 Post by 01micko »

Long overdue version 0.13 is posted

See main post
Puppy Linux Blog - contact me for access

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#53 Post by 01micko »

New version 0.16

See main post
Puppy Linux Blog - contact me for access

User avatar
Pete22
Posts: 264
Joined: Fri 08 May 2009, 22:59
Location: Utah, USA

version 0.16 on lighthouse

#54 Post by Pete22 »

01micko:

tempicon works fairly well in lighthouse which is related to slacko.

When Installed, this version starts working without further tweaking.
It even installs to the panel. However, the icon does not show.
I can tell its there because it leaves a space between icons.
When I click on the space it opens tempicon.

On second thought, this may not be tempicon's problem.
I want to use xfce windows manager, which works on the live CD.
But lighthouse refuses to this in a frugal install. It will only work with Openbox.

So I am not sure where the problem lies.

I will send a message to Lhp folks as well.

Pete

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#55 Post by 01micko »

Pete22

I have uploaded a 64 bit version. You will need that one for LHP-64. (unless of course you compiled it yourself). It should work in xfce as long as the system tray module is loaded and working, sorry I can't recall the name of it.

See the main post.

EDIT: works in Slackbones with lxpanel
Puppy Linux Blog - contact me for access

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#56 Post by 01micko »

v 0.17 is out!

Runs better now, couple of bugs fixed and some bloat removed.

Only 32 bit for now, maybe 64 tomorrow.
Puppy Linux Blog - contact me for access

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#57 Post by 01micko »

New version 0.19

See Main post
Puppy Linux Blog - contact me for access

User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#58 Post by pemasu »

01micko. Have you tested tempicon-0.19 pet with jwm-876 ?
Could newest jwm development version be the reason of this behavior. Laptop as toaster invention I mean.

http://www.murga-linux.com/puppy/viewto ... 127#738127

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#59 Post by 01micko »

pemasu wrote:01micko. Have you tested tempicon-0.19 pet with jwm-876 ?
Could newest jwm development version be the reason of this behavior. Laptop as toaster invention I mean.

http://www.murga-linux.com/puppy/viewto ... 127#738127
Fixed at my end, though the digits will read smaller, sorry but the icons must be square now unless Joe has an easy fix.

See main post
Puppy Linux Blog - contact me for access

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#60 Post by technosaurus »

I think Joe actually did recently fix that...
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#61 Post by 01micko »

Yeah he did so that they render true, except it's broken for svg. Rectangles used to get transformed to squares and that worked ok, but now it just bugs out. I made a report to Joe on github anyway.
Puppy Linux Blog - contact me for access

trefux
Posts: 11
Joined: Sat 04 Jun 2011, 08:13

#62 Post by trefux »

Hello,

I installed the tempicon tray but missing this:

# sensors
sensors: error while loading shared libraries: libsensors.so.4: cannot open shared object file: No such file or directory

Installed packages:
lm-sensor 3.3.4
depend:
init-system-helper 1.14
libsensor4 3.3.4
tempicon
tempiconsvg-0.21-i486.pet

Somebody help?

Use tahrpup 6.0.5, and Jwm.

Thanks

User avatar
davids45
Posts: 1326
Joined: Sun 26 Nov 2006, 23:33
Location: Chatswood, NSW

lib for lm-sensors

#63 Post by davids45 »

G'day trefux,

I have attached in a zip a version of your missing library file but it's slightly older than the string of numbers you quoted.

Before trying this, have you checked your /usr/lib/ directory to see if there is a libsensors.so.4.x.y.z file there, but not the simpler 'libsensors.so.4' (without extra dots and digits)? All you may need is a symlink to tell your computer to use this x.y.z-numbered file as if is was the one it's after.

If not, then the attached zip has the libsensors file from my older version of lm-sensors (3.1.2) plus two symlinks which enable its use as libsensors.so and libsensors.so.4. Unzip the zip and then copy or drag the three unzipped files to your /usr/lib/ directory and see if it works.

If you have no luck with this version of libsensors, delete the three files you've just copied to /usr/lib/ and wait for better help.

Good luck.

David S.
Attachments
lmsensorlib.zip
sensor lib (older version) with links for libsensors.so.4
(25.34 KiB) Downloaded 197 times

trefux
Posts: 11
Joined: Sat 04 Jun 2011, 08:13

#64 Post by trefux »

# find / -name *libsensors*
/usr/share/doc/libsensors4
/usr/share/libsensors4
/root/directsavepath/usr/share/doc/libsensors4
/root/directsavepath/usr/share/libsensors4
/root/directsavepath/usr/lib/i386-linux-gnu/libsensors.so.4.3.2
/root/directsavepath/usr/lib/i386-linux-gnu/libsensors.so.4


I saved your package too. Thanks!

copy to usr/lib
/root/directsavepath/usr/lib/i386-linux-gnu/libsensors.so.4.3.2
/root/directsavepath/usr/lib/i386-linux-gnu/libsensors.so.4


try "sensors"

# sensors
No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are.

Then run "sensors-detect" again, then run "/etc/rc.d/init.d/lm-sensors" but and nothing happened.

Something do wrong?

User avatar
davids45
Posts: 1326
Joined: Sun 26 Nov 2006, 23:33
Location: Chatswood, NSW

Sensors needs modules to read

#65 Post by davids45 »

G'day trefux,

Looking at your posted information, I think you have the sensors package loaded :D .
But now you need to load any modules that will monitor parts of your hardware. It is these modules that "sensors" reads.
# sensors
No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are.

Then run "sensors-detect" again, then run "/etc/rc.d/init.d/lm-sensors" but and nothing happened.
So open a terminal and enter 'sensors-detect'. Scan through all the options as there may be several modules to find.

If you are unlucky, your hardware may have no sensor modules that work. Very old computers often have no modules that are readable by 'sensors' :( . In this case, tempicon will not work on your computer.

Most computers do have at least one module that works but there are many many modules to check through.

Make an exact note of any modules that sensors-detect reports.

You then need to load these modules when your computer starts with Boot Manager (System menu) which has a tab-section to load modules.

Good luck hunting down any modules.

David S.

Post Reply