# lm-sensors text front end [SOLVED]

## pteppic

Does anyone know of a lm-sensors front end that runs in a terminal, curses or the like? 

All I can find are dock applets or gkrellm.

Thx in advance.....Last edited by pteppic on Mon Mar 27, 2006 4:21 pm; edited 1 time in total

----------

## Headrush

i don't know 100%, but the sensord USE flag looks like it enables support for a daemon which would probably work.

----------

## pteppic

That would probably work, but then I'd have to write something to display the logs on the screen in realtime/readable format.

So I opened up the source for the gnome-sensors applet and found out where it got its info.

80 lines of python later and I have what I need. I'll post it here in case it is useful to others. 

```
#!/usr/bin/python

import curses

from time import sleep

class output:

   cpu={}

   cpu['name']='CPU Temprature:'

   cpu['info']=0

   cpu['ifile']='/sys/devices/platform/i2c-9191/9191-0290/temp2_input'

   cpu['factor']=0.001

   cpu['units']='Celcius'

   cpu['offset']=0

   mbd={}

   mbd['name']='Motherboard Temperature:'

   mbd['info']=0

   mbd['ifile']='/sys/devices/platform/i2c-9191/9191-0290/temp1_input'

   mbd['factor']=0.001

   mbd['units']='Celcius'

   mbd['offset']=0

   

   devlist=(cpu,mbd)

   

   refresh=3 # 0.1-25.5 seconds

   ticker='/-\|'

def __init__():

      global maxlen

      global stdscr

      global tno

      tno=0

      maxlen=0

      for dev in output.devlist:

         a=len(dev['name'])

         if a > maxlen:

            maxlen=a

      maxlen+=4

      stdscr=curses.initscr()

      curses.noecho()

      curses.cbreak()

      stdscr.keypad(1)

      curses.curs_set(0)

      curses.halfdelay(output.refresh*10)

      stdscr.addstr(0,0,'Press any key to force refresh, q to quit.')

      stdscr.refresh()

      stdscr.addstr(0,0,'                                          ')

      sleep(5)

      

      

   

def GetStats():

      for dev in output.devlist:

         devfile=file(dev['ifile'],'r')

         data=devfile.readline()[:-1]

         devfile.close()

         try:

            data=long(data)

            data=data*dev['factor']

            data=data+dev['offset']

         except ValueError: 

            pass

         dev['info']=data

      

def Exit():

      curses.nocbreak()

      stdscr.keypad(0)

      curses.echo()

      curses.endwin()      

def Draw():

      line=1

      for dev in output.devlist:

         stdscr.addstr(0,0,output.ticker[tno])

         stdscr.addstr(line, 1, dev['name'])

         stdscr.addstr(line, maxlen, '%s %s' %(dev['info'],dev['units']))

         line+=1

      stdscr.refresh()

      

def Loop():

      global tno

      while True:

         GetStats()

         Draw()

         c=stdscr.getch()

         if c in (ord('q'),ord('Q')):

            break

         tno+=1

         if tno>3:tno=0

      

__init__()   

Loop()

Exit()
```

----------

