[NTLUG:Discuss] More shell scripting madness

. Daniel xdesign at hotmail.com
Thu Jul 5 12:17:10 CDT 2007


Thanks for the shell script suggestions.  I'll study them and see what I 
can figure out.  I like that single-line approach.  Simple makes me happy. 
:)

As for the GUI utility approach, I have installed gi8k and it has automated 
functions based on temp and all that, but they don't seem to actually work. 
 There seem to be other forces at play and I have yet to figure those out.  
So rather than actually figure those things out, I have elected to just run 
the fanloop. :)  Simple solution to a problem based on complex stuff.  The 
gi8k also offers manual control over the fans but I have found that there 
is "something else" that steps in and over-rides what the applet does.  The 
loop, then, over-rides what was over-ridden and the over-rider. :)

I welcome more shell script suggestions on this and when I have "quiet 
time" I'll study the ideas presented to me already.  I'm sure one or both 
are winners.  It'll be the one that doesn't make my head spin to understand 
that wins. :)  Thanks all!


>Greetings.
>
>If you are using a GUI desktop, there is an i8k plugin for gkrellm.
>Smart enough to detect if you are on battery or AC, and sets the
>appropriate temperature ranges.  Rechecks every 5 seconds.  Only
>downside, i8k reports "2 2" even when fans are below max RPMs (fans are
>variable speed, with the left fan reporting "2" at anything over about
>8500rpm, with a Max of a little over 11600RPM).
>
>Also gives a whole mess of other nice snapshots, including CPU 
temperature.
>
>Regards,
>Steve
>
>. Daniel wrote:
> > I know it's hard to see, but I'm actually starting to learn this stuff
> > little by little.
> >
> > Here's the purpose:
> >
> > I upgraded the processor and video in my laptop.  Now it gets warmer 
than I
> > like, especially during game play, which slows down when the processor 
and
> > video heat up.  While I intend to improve the actual heatsink materials
> > (Copper is surprisingly hard to get in the form I need it... and 
EXPENSIVE)
> > I would like to keep the processor fans running.
> >
> > As it turns out, the system is controlling the fans by itself based on
> > certain criteria.  But there is also a handy little utility to simply 
turn
> > on the fan!  It's called "i8kfan."  Run i8kfan without parameters and 
it
> > will simply return with two numbers indicating the mode of the fans at 
that
> > moment.  The values are 0, 1 and 2.  So if both fans are off, it will
> > return "0 0" and if both are on high speed it will return "2 2".
> >
> > So I wrote a loop that checks the fan status every two seconds and if 
it's
> > not "2 2" it will set the fans to "2 2" and go back to sleep.  I then 
set
> > up an icon on my panel to start the process when I want to play a game 
so I
> > can prolong my "cool time."
> >
> > Here's the problem though:  Gnome shortcuts no longer seem to want to
> > launch processes in terminal.  In earlier versions, there was a check 
box
> > to select this option.  It was a good option to use when you were 
debugging
> > because you could see error messages streaming by or whatever.  Now 
it's
> > gone and I can't run the script in a terminal window expect by hand...
> > which, of course, I don't wanna do.
> >
> > So here's the script as simple as it is:
> >
> > "i8kfanloop.sh"
> > -----
> > #!/bin/bash
> >
> > loop=1
> >
> > while [ loop ]
> > do
> >   status=`i8kfan`
> >   if [ "$status" != "2 2" ]
> >   then
> >      i8kfan 2 2
> >   fi
> >   sleep 2
> > done
> > -----
> >
> > That's some pretty simple bash code right?
> >
> > Here's what I'd like to add to it.  I'd like to add some code that will
> > detect if a previous instance of this script is currently running and 
if it
> > is, kill it and exit.  If it's not running, just go into the loop.  So 
the
> > result would be, if I click the icon once, it runs the loop.  If I 
click
> > the icon again, it will stop the loop.
> >
> > I imagine some code that will get the shell script's process ID number 
and
> > stores it somewhere, say "/tmp/$username_i8kfanloop.pid" or something 
like
> > that.  Then at the beginning of the script, it will look for said file 
and
> > compare the process ID recorded in the file with the process listing to 
see
> > if the process ID is there and actually the same script.
> >
> > If the filename doesn't exist, create the PID file and enter the loop.
> > If the filename exists but the process doesn't, it should erase the 
file,
> > create a new PID file and enter the loop.
> > If the filename exists and the process exists but the PID doesn't match 
up
> > with the script name, then erase the file, create a new PID file and 
enter
> > the loop.
> >
> > I feel confident that if I messed with this for a few hours, I'd be 
able to
> > cobble up something that works.  But before I spend my work day on my
> > personal stuff, I'm willing to bet someone already has or knows about 
some
> > shell code out there that does this already.  And I'm hoping that 
someone
> > will be kind and generous enough to paste their code into a reply so 
that I
> > could learn and adapt my skills further. :)
> >
> > _________________________________________________________________
> > IE6の機能を強化した最新版ブラウザがMSNユーザー向けになって登場!
> > http://promotion.msn.co.jp/ie7/
> >
> >
> > _______________________________________________
> > http://www.ntlug.org/mailman/listinfo/discuss
>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.2 (GNU/Linux)
>Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
>
>iD8DBQFGjR71PtiPEDq7o8YRAm9TAJ4jsqWjNZZCQ/5RY2uz8CkjFBaRMgCeIRL3
>TCqHYDw8vkXjgVHNQLzlTro=
>=pWfx
>-----END PGP SIGNATURE-----
>
>_______________________________________________
>http://www.ntlug.org/mailman/listinfo/discuss

_________________________________________________________________
IE6の機能を強化した最新版ブラウザがMSNユーザー向けになって登場! 
http://promotion.msn.co.jp/ie7/ 




More information about the Discuss mailing list