From a94ba7634d312728e25f888ff252e7c8a731a578 Mon Sep 17 00:00:00 2001 From: reinelt Date: Thu, 15 Jan 2004 04:29:45 +0000 Subject: [lcd4linux @ 2004-01-15 04:29:45 by reinelt] moved lcd4linux.conf.sample to *.old lcd4linux.conf.sample with new layout new plugins 'loadavg' and 'meminfo' text widget have pre- and postfix git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@311 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- Makefile.am | 2 + Makefile.in | 14 +- lcd4linux.conf.sample | 399 +++++++++------------------------------------- lcd4linux.conf.sample.old | 323 +++++++++++++++++++++++++++++++++++++ plugin.c | 12 +- plugin_cpuinfo.c | 10 +- plugin_loadavg.c | 82 ++++++++++ plugin_meminfo.c | 119 ++++++++++++++ widget_text.c | 36 ++++- widget_text.h | 57 +++++++ 10 files changed, 719 insertions(+), 335 deletions(-) create mode 100644 lcd4linux.conf.sample.old create mode 100644 plugin_loadavg.c create mode 100644 plugin_meminfo.c create mode 100644 widget_text.h diff --git a/Makefile.am b/Makefile.am index 3afc2ed..da198e3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,7 +31,9 @@ plugin_math.c \ plugin_string.c \ plugin_cfg.c \ plugin_uname.c \ +plugin_loadavg.c \ plugin_cpuinfo.c \ +plugin_meminfo.c \ plugin_i2c_sensors.c \ plugin_xmms.c \ system.c system.h \ diff --git a/Makefile.in b/Makefile.in index 89fcd4a..4389cfc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -106,7 +106,7 @@ lcd4linux_LDADD = @DRIVERS@ @DRVLIBS@ #remove next line for liblcd4linux lcd4linux_DEPENDENCIES = @DRIVERS@ -lcd4linux_SOURCES = lcd4linux.c pid.c pid.h hash.c hash.h parser.c parser.h processor.c processor.h layout.c layout.h timer.c timer.h evaluator.c evaluator.h widget.c widget.h widget_text.c plugin.c plugin.h plugin_math.c plugin_string.c plugin_cfg.c plugin_uname.c plugin_cpuinfo.c plugin_i2c_sensors.c plugin_xmms.c system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h display.c display.h drv.c drv.h debug.c debug.h cfg.c cfg.h lock.c lock.h pixmap.c pixmap.h bar.c bar.h icon.c icon.h fontmap.c fontmap.h udelay.c udelay.h +lcd4linux_SOURCES = lcd4linux.c pid.c pid.h hash.c hash.h parser.c parser.h processor.c processor.h layout.c layout.h timer.c timer.h evaluator.c evaluator.h widget.c widget.h widget_text.c plugin.c plugin.h plugin_math.c plugin_string.c plugin_cfg.c plugin_uname.c plugin_loadavg.c plugin_cpuinfo.c plugin_meminfo.c plugin_i2c_sensors.c plugin_xmms.c system.c system.h isdn.c isdn.h wifi.c wifi.h mail.c mail.h seti.c seti.h battery.c battery.h dvb.c dvb.h filter.c filter.h exec.c exec.h expr.c expr.h mail2.c socket.c socket.h imon.c imon.h display.c display.h drv.c drv.h debug.c debug.h cfg.c cfg.h lock.c lock.h pixmap.c pixmap.h bar.c bar.h icon.c icon.h fontmap.c fontmap.h udelay.c udelay.h #liblcd4linux_la_DEPENDENCIES = @DRIVERS@ @@ -150,7 +150,8 @@ lcd4linux_OBJECTS = lcd4linux.$(OBJEXT) pid.$(OBJEXT) hash.$(OBJEXT) \ parser.$(OBJEXT) processor.$(OBJEXT) layout.$(OBJEXT) timer.$(OBJEXT) \ evaluator.$(OBJEXT) widget.$(OBJEXT) widget_text.$(OBJEXT) \ plugin.$(OBJEXT) plugin_math.$(OBJEXT) plugin_string.$(OBJEXT) \ -plugin_cfg.$(OBJEXT) plugin_uname.$(OBJEXT) plugin_cpuinfo.$(OBJEXT) \ +plugin_cfg.$(OBJEXT) plugin_uname.$(OBJEXT) plugin_loadavg.$(OBJEXT) \ +plugin_cpuinfo.$(OBJEXT) plugin_meminfo.$(OBJEXT) \ plugin_i2c_sensors.$(OBJEXT) plugin_xmms.$(OBJEXT) system.$(OBJEXT) \ isdn.$(OBJEXT) wifi.$(OBJEXT) mail.$(OBJEXT) seti.$(OBJEXT) \ battery.$(OBJEXT) dvb.$(OBJEXT) filter.$(OBJEXT) exec.$(OBJEXT) \ @@ -183,10 +184,11 @@ DEP_FILES = .deps/BeckmannEgle.P .deps/Crystalfontz.P .deps/Cwlinux.P \ .deps/imon.P .deps/isdn.P .deps/layout.P .deps/lcd4linux.P .deps/lock.P \ .deps/mail.P .deps/mail2.P .deps/parport.P .deps/parser.P .deps/pid.P \ .deps/pixmap.P .deps/plugin.P .deps/plugin_cfg.P .deps/plugin_cpuinfo.P \ -.deps/plugin_i2c_sensors.P .deps/plugin_math.P .deps/plugin_string.P \ -.deps/plugin_uname.P .deps/plugin_xmms.P .deps/processor.P .deps/seti.P \ -.deps/socket.P .deps/system.P .deps/timer.P .deps/udelay.P \ -.deps/widget.P .deps/widget_text.P .deps/wifi.P +.deps/plugin_i2c_sensors.P .deps/plugin_loadavg.P .deps/plugin_math.P \ +.deps/plugin_meminfo.P .deps/plugin_string.P .deps/plugin_uname.P \ +.deps/plugin_xmms.P .deps/processor.P .deps/seti.P .deps/socket.P \ +.deps/system.P .deps/timer.P .deps/udelay.P .deps/widget.P \ +.deps/widget_text.P .deps/wifi.P SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES) OBJECTS = $(lcd4linux_OBJECTS) diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index e012f60..780876e 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -1,323 +1,76 @@ -# -# /etc/lcd4linux.conf -# configuration file for lcd4linux -# -# http://lcd4linux.sourceforge.net -# -# for the complete lcd4linux documentation please refer to -# http://lcd4linux.sourceforge.net/manual.html - - -# driver-specific options -# -# Display: -# the name of a display driver -# -# every driver has its own configuration options -# (e.g. 'Port', 'Speed', ...) -# for a detailed description of every option which is -# available for a specific driver please refer to -# http://lcd4linux.sourceforge.net/display/main.html -# -#Display LCD2041 -#Port /dev/ttyS2 -#Speed 19200 -#Contrast 160 -# -#Display HD44780 -#Port /dev/parport0 -#Size 24x2 -#Delay 503 -# -#Display BLC100x -#Port /dev/ttyS2 -#Type 20x4 -# -#Display USBLCD -#Port /dev/usb/usblcd -#Size 20x4 -# -#Display PalmPilot -#Port /dev/ttyS2 -#Speed 4800 -#size 20x4 -#font 6x8 -#pixel 1+0 -#gap 0x0 -#border 2 -# -#Display PPM -#size 20x4 -#font 5x8 -#pixel 3+0 -#gap -1x-1 -#border 10 -#foreground \#102000 -#halfground \#70c000 -#background \#80d000 -# -#Display PNG -#size 20x4 -#font 5x8 -#pixel 2+0 -#gap -1x-1 -#border 5 -#foreground \#102000 -#halfground \#70c000 -#background \#80d000 -# -#Display X11 -#size 20x5 -#font 5x8 -#pixel 1+0 -#gap -1x-1 -#border 1 -#foreground \#102000 -#halfground \#90c000 -#background \#a0d000 -# -#Display Text -#size 40x8 -#TextBar 1 -# -#Display SIN -#Port /dev/tty9 - - -# timing options - all values are milliseconds -# -# please note that starting with 0.9.11 the settings tick, -# tack, tau are marked as obsolete and replaced by the -# following ones: -# -# Tick.Text: -# time between text updates - default is 500 -# -# Tick.bar : -# time between bar updates - default is 100 -# -# Tick.icon: -# time between icon updates - default is 100 -# -# Tick.gpo : -# time between gpo updates - default is 100 -# -#Tick.Text 500 -#Tick.bar 100 -#Tick.icon 100 -#Tick.gpo 100 - - -# data-specific options -# -# Overload: -# load average threshold and bar scaling -# -# SetiDir: -# directory where seti@home stores its data files -# -# Battwarning: -# flash bp-bar if running below Battwarning -# I use: Row6 "Bat%bp%bs%bd$r10bp+bp" -# which gives a nice flash effect - default is 10 -# -Overload 2.0 -SetiDir /etc/setiathome -#Battwarning 10 - - -# mail/news related options -# -# Mailbox[1..9]: -# defines the mailbox for querying -# the string may be a plain mbox file or a pop3/imap4/nntp -# server string with the following format: -# pop3:[user[:pass]@]machine[:port] -# imap4:[user[:pass]@]machine[:port][/dir] -# nntp:[user[:pass]@]machine[:port][/dir] -# quering a plain (local) mbox file is achieved by giving -# the full path/name to the mbox file -# port defaults to 110 (pop3 query) and 143 (imap query) -# if [/dir] is not given, INBOX is assumed -# if [/dir] is given for nntp it should be a valid group name -# with '.' separating items -# if [/dir] is not given for nntp all/unread news of subscribed -# groups from Newsrc are calculated. -# -# Delay_e[1..9]: -# delay in seconds for querying Mailbox[1..9] - default is 5 -# -# Newsrc: -# path/name of your .newsrc file containing subscribed news -# please note that authorization on newsservers is currently untested -# user and pass may not contain a '/' with above syntax -# -#Mailbox1 /var/spool/mail/michi -#Delay_e1 5 -# -#Mailbox2 pop3:user:pass@machine -#Delay_e2 20 -# -#Mailbox3 imap4:user:pass@machine/folder -#Delay_e3 20 -# -#Mailbox4 nntp:server/at.linux -#Delay_e4 120 - - -# temperature sensors -# -# Sensor[1..9]: -# path to temperature file [1...9] -# -# Sensor[1..9]_min: -# temperature where the corresponding bar starts -# -# Sensor[1..9]_max: -# temperature where bar ends -# -# Sensor[1..9]_factor: -# formula to calculate real temperature -# (display_value=raw_value*factor+offset) -# lookup these values in /etc/sensors.conf -# -# Sensor[1..9]_offset: -# offset to calculate the real temperature -# -#Sensor1 /proc/sys/dev/sensors/as99127f-i2c-0-2d/temp1 -#Sensor1_min 30 -#Sensor1_max 50 -# -#Sensor2 /proc/sys/dev/sensors/as99127f-i2c-0-2d/temp2 -#Sensor2_min 30 -#Sensor2_max 50 -# -#Sensor3 /proc/sys/dev/sensors/as99127f-i2c-0-2d/temp3 -#Sensor3_min 30 -#Sensor3_max 50 - - - -# plugins -# -# x[1..9]: -# command to execute. predefined $PATH: -# PATH=/usr/local/bin:/usr/bin:/bin -# $X[1..9] is the result of command x[1..9] in environment -# -# Tick_x[1..9]: -# delay in ticks (overrides Delay_x[1..9]) -# -# Delay_x[1..9]: -# delay in seconds - default is 1 -# -# Max_x[1..9]: -# max value for scaling bars - default is 100 (value should be numeric) -# -# Min_x[1..9]: -# min value for bars - default is 0 (should be != Max_x[1..9]) -# -#x1 tail -1 /var/log/messages -#Tick_x1 10 -#Delay_x1 1 -#Max_x1 50 -#Min_x1 10 -# -#x2 echo $X1 | cut -b25- - - -# display options -# -# Row[1..9]: -# text to display in row [1..9] -# -# the text to be displayed can contain specific directives which will -# be replaced by the appropriate values or will create bars or icons. -# for a detailed description of every possible directive please refer to -# http://lcd4linux.sourceforge.net/manual.html or -# /usr/share/doc/packages/lcd4linux/README.Rows -# -Row1 "Busy %cb%% $r14cs+cb" -Row2 "Load%l1%L$r14l1" -# -#Row1 "$u3l1$u3cb$u3cs $u3mu$u3ma$u3ms $u3dr$u3dw $u3nr$u3nw $u3ii$u3io" -#Row2 " " -#Row3 " " -#Row4 "CPU MEM IO IP" -# -#Row1 "*** %o %v ***" -#Row2 "%p CPU %r MB RAM" -#Row3 "Busy %cb%% $r10cs+cb" -#Row4 "Load%l1%L$r10l1" -# -#Row1 "Load%l1%L$r10cs+cb" -#Row2 "Disk%dm $R10dr+dw" -#Row3 "Net %nm $R10nr+nw" -#Row4 "ISDN%im $r10ii+io" -#Row4 "DSL %tm $r10ti+to" -#Row5 "Temp%s2°$r10s1+s2" -# -#Row5 %x1 -#Row6 %x2 -# -#Row6 "Mails %e3/%u3" - - -# icons -# -# Icons: -# number of icons -# -# every icon you are reserving here is no longer available -# for bars. As most displays have only eight user-defineable -# characters, and a dual-bar needs at least five of them -# you should not use more than 3 icons in parallel -# with bars... -# -# Icon.Bitmap: -# bitmap row 'row' for icon 'num' -# -# for a detailed description of how to use icons please refer to -# http://lcd4linux.sourceforge.net/display/main.html -# -#Icons 1 -# -#Icon1.Bitmap1 ..... -#Icon1.Bitmap2 .*.*. -#Icon1.Bitmap3 ***** -#Icon1.Bitmap4 ***** -#Icon1.Bitmap5 .***. -#Icon1.Bitmap6 .***. -#Icon1.Bitmap7 ..*.. -#Icon1.Bitmap8 ..... - - -# virtual rows -# -# Rows: -# number of rows to use (maybe greater than your displays rows) -# -# Scroll: -# number of rows to scroll -# -# Turn: -# time in milliseconds between scrolling events -# -#Rows 10 -#Scroll 2 -#Turn 5000 - - -# general purpose outputs -# -# GPOs: -# number of outputs to use -# -# GPO[1..max]: -# token to use for GPO[1..max] -# -# the token should return a numeric value. If this value is greater -# than zero the output will be enabled otherwise disabled. -# please refer to the corresponding documentation under -# http://lcd4linux.sourceforge.net/display/main.html to -# find out if GPOs are supported with your display +Display LK204 { + Driver 'MatrixOrbital' + Model 'LK204-24-USB' + Port '/dev/usb/tts/0' + Port '/dev/tts/0' + Speed 19200 + Contrast 256/2 +} + +Widget OS { + class 'Text' + expression '*** '.uname('sysname').' '.uname('release').' ***' + width 20 + align 'C' + update tick +} + +Widget CPU { + class 'Text' + expression uname('machine') + postfix ' CPU' + width 10 + align 'L' + update tick +} + + +Widget RAM { + class 'Text' + expression meminfo('MemTotal')/1024 + postfix ' MB RAM' + width 5 + precision 0 + align 'R' + update tick +} + +Widget Disk { + class 'text' + expression Pi + width 10 + precision 2 + align 'R' + update tick +} + + +Widget LAN { + class 'text' + expression "12.12345678" + width 10 + precision 2 + align 'M' + update tick + speed tack +} + + +Layout Default { + Row1 { + Col1 'OS' + } + Row02 { + Col1 'CPU' + Col10 'RAM' + } +} + +Display 'LK204' +Layout 'Default' + + +Variables { + tick 500 + tack 100 +} diff --git a/lcd4linux.conf.sample.old b/lcd4linux.conf.sample.old new file mode 100644 index 0000000..e012f60 --- /dev/null +++ b/lcd4linux.conf.sample.old @@ -0,0 +1,323 @@ +# +# /etc/lcd4linux.conf +# configuration file for lcd4linux +# +# http://lcd4linux.sourceforge.net +# +# for the complete lcd4linux documentation please refer to +# http://lcd4linux.sourceforge.net/manual.html + + +# driver-specific options +# +# Display: +# the name of a display driver +# +# every driver has its own configuration options +# (e.g. 'Port', 'Speed', ...) +# for a detailed description of every option which is +# available for a specific driver please refer to +# http://lcd4linux.sourceforge.net/display/main.html +# +#Display LCD2041 +#Port /dev/ttyS2 +#Speed 19200 +#Contrast 160 +# +#Display HD44780 +#Port /dev/parport0 +#Size 24x2 +#Delay 503 +# +#Display BLC100x +#Port /dev/ttyS2 +#Type 20x4 +# +#Display USBLCD +#Port /dev/usb/usblcd +#Size 20x4 +# +#Display PalmPilot +#Port /dev/ttyS2 +#Speed 4800 +#size 20x4 +#font 6x8 +#pixel 1+0 +#gap 0x0 +#border 2 +# +#Display PPM +#size 20x4 +#font 5x8 +#pixel 3+0 +#gap -1x-1 +#border 10 +#foreground \#102000 +#halfground \#70c000 +#background \#80d000 +# +#Display PNG +#size 20x4 +#font 5x8 +#pixel 2+0 +#gap -1x-1 +#border 5 +#foreground \#102000 +#halfground \#70c000 +#background \#80d000 +# +#Display X11 +#size 20x5 +#font 5x8 +#pixel 1+0 +#gap -1x-1 +#border 1 +#foreground \#102000 +#halfground \#90c000 +#background \#a0d000 +# +#Display Text +#size 40x8 +#TextBar 1 +# +#Display SIN +#Port /dev/tty9 + + +# timing options - all values are milliseconds +# +# please note that starting with 0.9.11 the settings tick, +# tack, tau are marked as obsolete and replaced by the +# following ones: +# +# Tick.Text: +# time between text updates - default is 500 +# +# Tick.bar : +# time between bar updates - default is 100 +# +# Tick.icon: +# time between icon updates - default is 100 +# +# Tick.gpo : +# time between gpo updates - default is 100 +# +#Tick.Text 500 +#Tick.bar 100 +#Tick.icon 100 +#Tick.gpo 100 + + +# data-specific options +# +# Overload: +# load average threshold and bar scaling +# +# SetiDir: +# directory where seti@home stores its data files +# +# Battwarning: +# flash bp-bar if running below Battwarning +# I use: Row6 "Bat%bp%bs%bd$r10bp+bp" +# which gives a nice flash effect - default is 10 +# +Overload 2.0 +SetiDir /etc/setiathome +#Battwarning 10 + + +# mail/news related options +# +# Mailbox[1..9]: +# defines the mailbox for querying +# the string may be a plain mbox file or a pop3/imap4/nntp +# server string with the following format: +# pop3:[user[:pass]@]machine[:port] +# imap4:[user[:pass]@]machine[:port][/dir] +# nntp:[user[:pass]@]machine[:port][/dir] +# quering a plain (local) mbox file is achieved by giving +# the full path/name to the mbox file +# port defaults to 110 (pop3 query) and 143 (imap query) +# if [/dir] is not given, INBOX is assumed +# if [/dir] is given for nntp it should be a valid group name +# with '.' separating items +# if [/dir] is not given for nntp all/unread news of subscribed +# groups from Newsrc are calculated. +# +# Delay_e[1..9]: +# delay in seconds for querying Mailbox[1..9] - default is 5 +# +# Newsrc: +# path/name of your .newsrc file containing subscribed news +# please note that authorization on newsservers is currently untested +# user and pass may not contain a '/' with above syntax +# +#Mailbox1 /var/spool/mail/michi +#Delay_e1 5 +# +#Mailbox2 pop3:user:pass@machine +#Delay_e2 20 +# +#Mailbox3 imap4:user:pass@machine/folder +#Delay_e3 20 +# +#Mailbox4 nntp:server/at.linux +#Delay_e4 120 + + +# temperature sensors +# +# Sensor[1..9]: +# path to temperature file [1...9] +# +# Sensor[1..9]_min: +# temperature where the corresponding bar starts +# +# Sensor[1..9]_max: +# temperature where bar ends +# +# Sensor[1..9]_factor: +# formula to calculate real temperature +# (display_value=raw_value*factor+offset) +# lookup these values in /etc/sensors.conf +# +# Sensor[1..9]_offset: +# offset to calculate the real temperature +# +#Sensor1 /proc/sys/dev/sensors/as99127f-i2c-0-2d/temp1 +#Sensor1_min 30 +#Sensor1_max 50 +# +#Sensor2 /proc/sys/dev/sensors/as99127f-i2c-0-2d/temp2 +#Sensor2_min 30 +#Sensor2_max 50 +# +#Sensor3 /proc/sys/dev/sensors/as99127f-i2c-0-2d/temp3 +#Sensor3_min 30 +#Sensor3_max 50 + + + +# plugins +# +# x[1..9]: +# command to execute. predefined $PATH: +# PATH=/usr/local/bin:/usr/bin:/bin +# $X[1..9] is the result of command x[1..9] in environment +# +# Tick_x[1..9]: +# delay in ticks (overrides Delay_x[1..9]) +# +# Delay_x[1..9]: +# delay in seconds - default is 1 +# +# Max_x[1..9]: +# max value for scaling bars - default is 100 (value should be numeric) +# +# Min_x[1..9]: +# min value for bars - default is 0 (should be != Max_x[1..9]) +# +#x1 tail -1 /var/log/messages +#Tick_x1 10 +#Delay_x1 1 +#Max_x1 50 +#Min_x1 10 +# +#x2 echo $X1 | cut -b25- + + +# display options +# +# Row[1..9]: +# text to display in row [1..9] +# +# the text to be displayed can contain specific directives which will +# be replaced by the appropriate values or will create bars or icons. +# for a detailed description of every possible directive please refer to +# http://lcd4linux.sourceforge.net/manual.html or +# /usr/share/doc/packages/lcd4linux/README.Rows +# +Row1 "Busy %cb%% $r14cs+cb" +Row2 "Load%l1%L$r14l1" +# +#Row1 "$u3l1$u3cb$u3cs $u3mu$u3ma$u3ms $u3dr$u3dw $u3nr$u3nw $u3ii$u3io" +#Row2 " " +#Row3 " " +#Row4 "CPU MEM IO IP" +# +#Row1 "*** %o %v ***" +#Row2 "%p CPU %r MB RAM" +#Row3 "Busy %cb%% $r10cs+cb" +#Row4 "Load%l1%L$r10l1" +# +#Row1 "Load%l1%L$r10cs+cb" +#Row2 "Disk%dm $R10dr+dw" +#Row3 "Net %nm $R10nr+nw" +#Row4 "ISDN%im $r10ii+io" +#Row4 "DSL %tm $r10ti+to" +#Row5 "Temp%s2°$r10s1+s2" +# +#Row5 %x1 +#Row6 %x2 +# +#Row6 "Mails %e3/%u3" + + +# icons +# +# Icons: +# number of icons +# +# every icon you are reserving here is no longer available +# for bars. As most displays have only eight user-defineable +# characters, and a dual-bar needs at least five of them +# you should not use more than 3 icons in parallel +# with bars... +# +# Icon.Bitmap: +# bitmap row 'row' for icon 'num' +# +# for a detailed description of how to use icons please refer to +# http://lcd4linux.sourceforge.net/display/main.html +# +#Icons 1 +# +#Icon1.Bitmap1 ..... +#Icon1.Bitmap2 .*.*. +#Icon1.Bitmap3 ***** +#Icon1.Bitmap4 ***** +#Icon1.Bitmap5 .***. +#Icon1.Bitmap6 .***. +#Icon1.Bitmap7 ..*.. +#Icon1.Bitmap8 ..... + + +# virtual rows +# +# Rows: +# number of rows to use (maybe greater than your displays rows) +# +# Scroll: +# number of rows to scroll +# +# Turn: +# time in milliseconds between scrolling events +# +#Rows 10 +#Scroll 2 +#Turn 5000 + + +# general purpose outputs +# +# GPOs: +# number of outputs to use +# +# GPO[1..max]: +# token to use for GPO[1..max] +# +# the token should return a numeric value. If this value is greater +# than zero the output will be enabled otherwise disabled. +# please refer to the corresponding documentation under +# http://lcd4linux.sourceforge.net/display/main.html to +# find out if GPOs are supported with your display diff --git a/plugin.c b/plugin.c index 6328ea9..4fc6de3 100644 --- a/plugin.c +++ b/plugin.c @@ -1,4 +1,4 @@ -/* $Id: plugin.c,v 1.11 2004/01/14 11:33:00 reinelt Exp $ +/* $Id: plugin.c,v 1.12 2004/01/15 04:29:45 reinelt Exp $ * * plugin handler for the Evaluator * @@ -22,6 +22,12 @@ * * * $Log: plugin.c,v $ + * Revision 1.12 2004/01/15 04:29:45 reinelt + * moved lcd4linux.conf.sample to *.old + * lcd4linux.conf.sample with new layout + * new plugins 'loadavg' and 'meminfo' + * text widget have pre- and postfix + * * Revision 1.11 2004/01/14 11:33:00 reinelt * new plugin 'uname' which does what it's called * text widget nearly finished @@ -107,7 +113,9 @@ int plugin_init_math (void); int plugin_init_string (void); int plugin_init_cfg (void); int plugin_init_uname (void); +int plugin_init_loadavg (void); int plugin_init_cpuinfo (void); +int plugin_init_meminfo (void); int plugin_init_i2c_sensors (void); int plugin_init_xmms (void); @@ -118,7 +126,9 @@ int plugin_init (void) plugin_init_string(); plugin_init_cfg(); plugin_init_uname(); + plugin_init_loadavg(); plugin_init_cpuinfo(); + plugin_init_meminfo(); // MR: segfaults here // plugin_init_i2c_sensors(); plugin_init_xmms(); diff --git a/plugin_cpuinfo.c b/plugin_cpuinfo.c index 60b0880..e9d4036 100644 --- a/plugin_cpuinfo.c +++ b/plugin_cpuinfo.c @@ -1,4 +1,4 @@ -/* $Id: plugin_cpuinfo.c,v 1.2 2004/01/14 11:33:00 reinelt Exp $ +/* $Id: plugin_cpuinfo.c,v 1.3 2004/01/15 04:29:45 reinelt Exp $ * * plugin for /proc/cpuinfo parsing * @@ -23,6 +23,12 @@ * * * $Log: plugin_cpuinfo.c,v $ + * Revision 1.3 2004/01/15 04:29:45 reinelt + * moved lcd4linux.conf.sample to *.old + * lcd4linux.conf.sample with new layout + * new plugins 'loadavg' and 'meminfo' + * text widget have pre- and postfix + * * Revision 1.2 2004/01/14 11:33:00 reinelt * new plugin 'uname' which does what it's called * text widget nearly finished @@ -86,7 +92,7 @@ static void my_cpuinfo (RESULT *result, RESULT *arg1) // strip leading blanks from key while (isspace(*key)) *key++='\0'; // strip trailing blanks from key - while (isspace(*--c)) *c='\0'; + do *c='\0'; while (isspace(*--c)); // strip leading blanks from value while (isspace(*val)) *val++='\0'; // strip trailing blanks from value diff --git a/plugin_loadavg.c b/plugin_loadavg.c new file mode 100644 index 0000000..2a78bcf --- /dev/null +++ b/plugin_loadavg.c @@ -0,0 +1,82 @@ +/* $Id: plugin_loadavg.c,v 1.1 2004/01/15 04:29:45 reinelt Exp $ + * + * plugin for load average + * + * Copyright 2003 Michael Reinelt + * Copyright 2004 The LCD4Linux Team + * + * This file is part of LCD4Linux. + * + * LCD4Linux is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * LCD4Linux is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * $Log: plugin_loadavg.c,v $ + * Revision 1.1 2004/01/15 04:29:45 reinelt + * moved lcd4linux.conf.sample to *.old + * lcd4linux.conf.sample with new layout + * new plugins 'loadavg' and 'meminfo' + * text widget have pre- and postfix + * + */ + +/* + * exported functions: + * + * int plugin_init_loadavg (void) + * adds functions for load average + * + */ + + +#include +#include +#include +#include + +#include "debug.h" +#include "plugin.h" + + +static void my_loadavg (RESULT *result, RESULT *arg1) +{ + int nelem, index; + double loadavg[3]; + + nelem=getloadavg(loadavg, 3); + if (nelem<0) { + error ("getloadavg() failed!"); + SetResult(&result, R_STRING, ""); + return; + } + + index=R2N(arg1); + if (index<1 || index>nelem) { + error ("loadavg(%d): index out of range!", index); + SetResult(&result, R_STRING, ""); + return; + } + + SetResult(&result, R_NUMBER, &(loadavg[index-1])); + return; + +} + + +int plugin_init_loadavg (void) +{ + AddFunction ("loadavg", 1, my_loadavg); + return 0; +} + diff --git a/plugin_meminfo.c b/plugin_meminfo.c new file mode 100644 index 0000000..6115515 --- /dev/null +++ b/plugin_meminfo.c @@ -0,0 +1,119 @@ +/* $Id: plugin_meminfo.c,v 1.1 2004/01/15 04:29:45 reinelt Exp $ + * + * plugin for /proc/meminfo parsing + * + * Copyright 2003 Michael Reinelt + * Copyright 2004 The LCD4Linux Team + * + * This file is part of LCD4Linux. + * + * LCD4Linux is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * LCD4Linux is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * $Log: plugin_meminfo.c,v $ + * Revision 1.1 2004/01/15 04:29:45 reinelt + * moved lcd4linux.conf.sample to *.old + * lcd4linux.conf.sample with new layout + * new plugins 'loadavg' and 'meminfo' + * text widget have pre- and postfix + * + */ + +/* + * exported functions: + * + * int plugin_init_meminfo (void) + * adds functions to access /proc/meminfo + * + */ + + +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "plugin.h" +#include "hash.h" + + +static void my_meminfo (RESULT *result, RESULT *arg1) +{ + static HASH MemInfo = { 0, 0, NULL }; + + static time_t now=0; + char *key, *val; + int line; + + // reread every second only + if (time(NULL)!=now) { + FILE *stream; + + // destroy previous hash table + hash_destroy (&MemInfo); + + stream=fopen("/proc/meminfo", "r"); + if (stream==NULL) { + error ("fopen(/proc/meminfo) failed: %s", strerror(errno)); + SetResult(&result, R_STRING, ""); + return; + } + + line=0; + while (!feof(stream)) { + char buffer[256]; + char *c; + fgets (buffer, sizeof(buffer), stream); + c=strchr(buffer, ':'); + if (c==NULL) continue; + key=buffer; val=c+1; + // strip leading blanks from key + while (isspace(*key)) *key++='\0'; + // strip trailing blanks from key + do *c='\0'; while (isspace(*--c)); + // strip leading blanks from value + while (isspace(*val)) *val++='\0'; + // strip trailing blanks from value + for (c=val; *c!='\0';c++); + while (isspace(*--c)) *c='\0'; + // skip lines that do not end with " kB" + if (*c=='B' && *(c-1)=='k' && *(c-2)==' ') { + // strip trailing " kB" from value + *(c-2)='\0'; + // add entry to hash table + hash_set (&MemInfo, key, val); + } + } + fclose (stream); + time(&now); + } + + key=R2S(arg1); + val=hash_get(&MemInfo, key); + if (val==NULL) val=""; + + SetResult(&result, R_STRING, val); +} + + +int plugin_init_meminfo (void) +{ + AddFunction ("meminfo", 1, my_meminfo); + return 0; +} + diff --git a/widget_text.c b/widget_text.c index 95401ed..5f91c5d 100644 --- a/widget_text.c +++ b/widget_text.c @@ -1,4 +1,4 @@ -/* $Id: widget_text.c,v 1.4 2004/01/14 11:33:00 reinelt Exp $ +/* $Id: widget_text.c,v 1.5 2004/01/15 04:29:45 reinelt Exp $ * * simple text widget handling * @@ -21,6 +21,12 @@ * * * $Log: widget_text.c,v $ + * Revision 1.5 2004/01/15 04:29:45 reinelt + * moved lcd4linux.conf.sample to *.old + * lcd4linux.conf.sample with new layout + * new plugins 'loadavg' and 'meminfo' + * text widget have pre- and postfix + * * Revision 1.4 2004/01/14 11:33:00 reinelt * new plugin 'uname' which does what it's called * text widget nearly finished @@ -136,7 +142,26 @@ void widget_text_update (void *Self) WIDGET *W = (WIDGET*)Self; WIDGET_TEXT *T = W->data; RESULT result = {0, 0.0, NULL}; - char *value; + char *prefix, *postfix, *value; + + // evaluate prefix + if (T->prefix!=NULL && strlen(T->prefix)>0) { + Eval(T->prefix, &result); + prefix=strdup(R2S(&result)); + DelResult (&result); + } else { + prefix=strdup(""); + } + + // evaluate postfix + if (T->postfix!=NULL && *(T->postfix)!='\0') { + debug ("Eval_postfix(%s)", T->postfix); + Eval(T->postfix, &result); + postfix=strdup(R2S(&result)); + DelResult (&result); + } else { + postfix=strdup(""); + } // evaluate expression Eval(T->expression, &result); @@ -171,6 +196,8 @@ void widget_text_update (void *Self) snprintf (value, size+1, "%.*f", precision, number); } } + + DelResult (&result); // has value changed? if (T->value == NULL || strcmp(T->value, value)!=0) { @@ -190,7 +217,6 @@ void widget_text_update (void *Self) free (value); } - DelResult (&result); } @@ -208,6 +234,10 @@ int widget_text_init (WIDGET *Self) T=malloc(sizeof(WIDGET_TEXT)); memset (T, 0, sizeof(WIDGET_TEXT)); + // get raw pre- and postfix (we evaluate it ourselves) + T->prefix = cfg_get_raw (section, "prefix", NULL); + T->postfix = cfg_get_raw (section, "prefix", NULL); + // get raw expression (we evaluate it ourselves) T->expression = cfg_get_raw (section, "expression", "''"); diff --git a/widget_text.h b/widget_text.h new file mode 100644 index 0000000..7d678e8 --- /dev/null +++ b/widget_text.h @@ -0,0 +1,57 @@ +/* $Id: widget_text.h,v 1.1 2004/01/15 04:29:45 reinelt Exp $ + * + * simple text widget handling + * + * Copyright 2003,2004 Michael Reinelt + * Copyright 2004 The LCD4Linux Team + * + * This file is part of LCD4Linux. + * + * LCD4Linux is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * LCD4Linux is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * $Log: widget_text.h,v $ + * Revision 1.1 2004/01/15 04:29:45 reinelt + * moved lcd4linux.conf.sample to *.old + * lcd4linux.conf.sample with new layout + * new plugins 'loadavg' and 'meminfo' + * text widget have pre- and postfix + * + */ + + +#ifndef _WIDGET_TEXT_H_ +#define _WIDGET_TEXT_H_ + +typedef enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE } ALIGN; + +typedef struct WIDGET_TEXT { + char *prefix; // label on the left side + char *postfix; // label on the right side + char *expression; // expression that delivers the value + char *value; // evaluated value from expression + char *buffer; // string with 'width+1' bytes allocated + int width; // field width + int precision; // number of digits after the decimal point + ALIGN align; // alignment: L, C, R, M(arquee) + int update; // update interval + int scroll; // marquee starting point + int speed; // marquee scrolling speed +} WIDGET_TEXT; + + +extern WIDGET_CLASS Widget_Text; + +#endif -- cgit v1.2.3