Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 23 Apr 2014, 11:32
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How do I make a simple GTK windows for CPU temp?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [6 Posts]  
Author Message
joel


Joined: 26 Feb 2009
Posts: 185
Location: Buffalo, NY & Nottingham, England

PostPosted: Mon 10 May 2010, 15:29    Post subject:  How do I make a simple GTK windows for CPU temp?
Subject description: How do I make a simple GTK windows for CPU temp?
 

I was wondering if anyone knew how to make a simple GTK window?. What I am looking to do it this. I have an odd computer any CPU temp widgets never work right with it. Not Pwidgets, KDE, E17 none of them. But I do know that in /proc/acpi/thermal_zone/TZ1 there is a file that accurately displays my CPU temp so I know my computer had the sensor. Therefore I made a simple script to call that info up. It ran:


Code:

#!/bin/sh

rxvt -T Temperature -bg darkgreen -fg white -geometry 34x2+747+669 -e bash -c "cat /proc/acpi/thermal_zone/TZ1/temperature  ; read a " &



That works fine and all but what I really would like to do is make it come up in a GTK window and repeat the command to call the temp info at a set interval. I tried this through bask like this:

Code:

#!/bin/sh

while [ 1 ]; do
  rxvt -T Temperature -bg darkgreen -fg white -geometry 34x2+747+669 -e bash -c "cat /proc/acpi/thermal_zone/TZ1/temperature  ; read a " &
  sleep 1
  killall
done


That just made it multiply like rabbits. Therefore I'd really like to just make a simple GTK window (which could be themed along with the rest of GTK and look nice), plus have the script repeat without multiplying the windows over and over.

Anyone have any idea on how to do this? I saw that some of the experienced members did some work with this, and I know zigbert is using GTK a lot with all the Stardust menus.[/code]

_________________
I am not a Mac, not a PC... I am a Puppy. Idea
Back to top
View user's profile Send private message 
jemimah


Joined: 26 Aug 2009
Posts: 4309
Location: Tampa, FL

PostPosted: Mon 10 May 2010, 17:24    Post subject:  

Have you tried traytemp?
http://www.murga-linux.com/puppy/viewtopic.php?t=50696

Otherwise

Code:
Xdialog --msgbox "your message here" 0 0


That will still pop up a bunch of windows, but you should program it to only pop up when the temperature gets too high.

Otherwise you should write a script that works on the command line, then pop up an rxvt that calls your script.
Back to top
View user's profile Send private message Visit poster's website 
joel


Joined: 26 Feb 2009
Posts: 185
Location: Buffalo, NY & Nottingham, England

PostPosted: Mon 10 May 2010, 17:40    Post subject:  

well i was hoping to make a GTK window, other wise when i click on the icon rxvt comes up and its good enough. Thanks though. BTW i use enlightenment so its not so easy to use a tray program
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4134

PostPosted: Thu 13 May 2010, 12:54    Post subject:  

All the pieces/parts are here:
http://www.murga-linux.com/puppy/viewtopic.php?t=54661

get the cpu temperature from /proc/...

use the code for generating an xpm image for your graphic

integrate them into an Xdialog or gtkdialog script

from memory I think it should be something like
Xdialog --icon /tmp/CPU_TEMP.xpm --infobox "CPU temperature $cpu_temp" 0 0

if not
Xdialog --help

unfortunately neither program has a means of updating/refreshing the icon AFAIK, so you may need to use the --geometry settings to redraw it as necessary

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2171

PostPosted: Thu 13 May 2010, 13:38    Post subject:  

Using the Xdialog progressbar or guage you can maybe update the image or use some updated text.

I'll post several examples I came up with a long time ago.
guage1:
Code:
#!/bin/sh
DIALOG=Xdialog

FILE_SIZE=30000
EST_TIME=`expr $FILE_SIZE / 1000`
echo $EST_TIME
PERCENT=`expr 0`
echo $PERCENT
INTERVAL=`expr $EST_TIME / 10`
INCREMENT=10
echo $INTERVAL

{
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL && PERCENT=`expr $PERCENT + $INCREMENT`
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
} |
$DIALOG --title "GAUGE" --gauge "Hi, this is a gauge widget" 8 30

if [ "$?" = 255 ] ; then
   echo ""
   echo "Box closed !"
fi


guage2:
Code:
#!/bin/sh
DIALOG=Xdialog

FILE_SIZE=30000
EST_TIME=`expr $FILE_SIZE / 1000`
echo $EST_TIME
PERCENT=`expr 0`
COMPLETE=0
echo $PERCENT
INTERVAL=`expr $EST_TIME / 10`
INCREMENT=10
echo $INTERVAL

{
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; # sleep $INTERVAL && \
while [[ $COMPLETE -lt 100 ]] ; do
echo "XXX" ; echo "$PERCENT percent" ; echo "\\n" ; echo "uncompressed"; echo "XXX"
echo "$PERCENT" ; sleep $INTERVAL
PERCENT=`expr $PERCENT + $INCREMENT`
COMPLETE=`expr $COMPLETE - $PERCENT`
done
} |
$DIALOG --title "GAUGE" --gauge "Hi, this is a gauge widget" 8 30

if [ "$?" = 255 ] ; then
   echo ""
   echo "Box closed !"
fi


progress1:
Code:
#!/bin/sh
MAX_DOTS=2000
MSG_LENGTH=10
proc_dot()
{
  p=$1
  while [ -d /proc/$p ]
  do
    echo -n .
   sleep .5
  done
}

( ( slocate -u -e /mnt & proc_dot $! ) ; sleep .5 ) | \
Xdialog --title "SqueezeMe" --no-close \
--progress "Please wait while building database...\n\n" 0 0 \
   $MAX_DOTS $MSG_LENGTH


progress2:
Code:
#!/bin/sh
MAX_DOTS=1000
MSG_LENGTH=9
proc_dot()
{
  p=$1
  while [ -d /proc/$p ]
  do
    echo -n .
   sleep .5
  done
}

# Xdialog --title "SqueezeMe" --no-buttons \
#    --infobox "Preparing to run..." 0 0 0 |
(
echo "FileName" ;
( slocate -u -e /mnt & proc_dot $! ) ;
# sleep 1 ;
# echo "New File Name" ;
) |
Xdialog --title "SqueezeMe" \
--progress "Please wait while building database...\n\n" 0 0 \
   $MAX_DOTS $MSG_LENGTH


spinner:
Code:
#!/bin/sh
MAX_DOTS=1000
MSG_LENGTH=9
proc_dot()
{
  p=$1
  while [ -d /proc/$p ]
  do
   echo -en "/" ; sleep .05
    echo -en "-" ; sleep .05
    echo -en '\' ; sleep .05
    echo -en "|" ; sleep .05
  done
}

# Xdialog --title "SqueezeMe" --no-buttons \
#    --infobox "Preparing to run..." 0 0 0 |
# (
# echo "FileName" ;
# ( slocate -u -e /mnt & proc_dot $! )


(
slocate -u -e /mnt &
p2=$1
while [ -d /proc/$p2 ]
do
echo "XXX" ; echo -en "/" ; sleep .05 ; echo "XXX"
echo "XXX" ; echo -en "-" ; sleep .05 ; echo "XXX"
echo "XXX" ; echo -en '\' ; sleep .05 ; echo "XXX"
echo "XXX" ; echo -en "|" ; sleep .05 ; echo "XXX"
done
) |
Xdialog --title "SqueezeMe" \
--infobox "Please wait while building database...\n\n" 0 0 0



The key to making any guage or progressbar to work is the pipe: '|'
Back to top
View user's profile Send private message 
joel


Joined: 26 Feb 2009
Posts: 185
Location: Buffalo, NY & Nottingham, England

PostPosted: Thu 13 May 2010, 15:10    Post subject:  

thanks for all the suggestions, Ill try those tonight and report back.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [6 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0801s ][ Queries: 12 (0.0207s) ][ GZIP on ]