diff options
author | Reinhard Tartler <siretart@tauware.de> | 2011-04-27 19:24:15 +0200 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2011-04-27 19:24:15 +0200 |
commit | 181cec4348da40331b3e8ab365732c025ec149b2 (patch) | |
tree | e2e749be67c8253a8096aaf92aab9c51f1a17f7f /lcd4linux.c | |
download | lcd4linux-181cec4348da40331b3e8ab365732c025ec149b2.tar.gz |
Import upstream version 0.11.0~svn1143
Diffstat (limited to '')
-rw-r--r-- | lcd4linux.c | 440 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 1328 |
2 files changed, 1768 insertions, 0 deletions
diff --git a/lcd4linux.c b/lcd4linux.c new file mode 100644 index 0000000..842f653 --- /dev/null +++ b/lcd4linux.c @@ -0,0 +1,440 @@ +/* $Id: lcd4linux.c 1106 2010-02-07 14:03:46Z mzuther $ + * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/lcd4linux.c $ + * + * LCD4Linux + * + * Copyright (C) 1999, 2000, 2001, 2002, 2003 Michael Reinelt <michael@reinelt.co.at> + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> + * + * 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. + * + */ + +#include "config.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <signal.h> +#include <time.h> +#include <sys/types.h> /* umask() */ +#include <sys/stat.h> /* umask() */ + +#include "svn_version.h" +#include "cfg.h" +#include "debug.h" +#include "qprintf.h" +#include "pid.h" +#include "udelay.h" +#include "drv.h" +#include "timer.h" +#include "timer_group.h" +#include "layout.h" +#include "plugin.h" +#include "thread.h" +#include "event.h" +#include "widget.h" +#include "widget_timer.h" + +#ifdef WITH_DMALLOC +#include <dmalloc.h> +#endif + +#define PIDFILE "/var/run/lcd4linux.pid" + +static char *release = "LCD4Linux " VERSION "-" SVN_VERSION; +static char *copyright = + "Copyright (C) 2005, 2006, 2007, 2008, 2009 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>"; +static char **my_argv; +extern char *output; + +int got_signal = 0; + + +static void usage(void) +{ + printf("%s\n", release); + printf("%s\n", copyright); + printf("\n"); + printf("usage:\n"); + printf(" lcd4linux [-h]\n"); + printf(" lcd4linux [-l]\n"); + printf(" lcd4linux [-c key=value] [-i] [-f config-file] [-v] [-p pid-file]\n"); + printf(" lcd4linux [-c key=value] [-F] [-f config-file] [-o output-file] [-q] [-v]\n"); + printf("\n"); + printf("options:\n"); + printf(" -h help\n"); + printf(" -l list available display drivers and plugins\n"); + printf(" -c <key>=<value> overwrite entries from the config-file\n"); + printf(" -i enter interactive mode (after display initialisation)\n"); + printf(" -ii enter interactive mode (before display initialisation)\n"); + printf(" -f <config-file> use configuration from <config-file> instead of /etc/lcd4linux.conf\n"); + printf(" -v generate info messages\n"); + printf(" -vv generate debugging messages\n"); + printf(" -p <pid-file> specify a different pid-file location (default is /var/run/lcd4linux.pid)\n"); + printf(" -F do not fork and detach (run in foreground)\n"); + printf(" -o <output-file> write picture to file (raster driver only)\n"); + printf(" -q suppress startup and exit splash screen\n"); +#ifdef WITH_X11 + printf("special X11 options:\n"); + printf(" -display <X11 display name> preceeds X connection given in $DISPLAY\n"); + printf(" -synchronous use synchronized communication with X server (for debugging)\n"); + printf("\n"); + printf("\n"); + printf("\n"); +#endif +} + +static void interactive_mode(void) +{ + char line[1024]; + void *tree; + RESULT result = { 0, 0, 0, NULL }; + + printf("\neval> "); + for (fgets(line, sizeof(line), stdin); !feof(stdin); fgets(line, sizeof(line), stdin)) { + if (line[strlen(line) - 1] == '\n') + line[strlen(line) - 1] = '\0'; + if (strlen(line) > 0) { + if (Compile(line, &tree) != -1) { + Eval(tree, &result); + if (result.type == R_NUMBER) { + printf("%g\n", R2N(&result)); + } else if (result.type == R_STRING) { + printf("'%s'\n", R2S(&result)); + } else if (result.type == (R_NUMBER | R_STRING)) { + printf("'%s' (%g)\n", R2S(&result), R2N(&result)); + } else { + printf("internal error: unknown result type %d\n", result.type); + } + DelResult(&result); + } + DelTree(tree); + } + printf("eval> "); + } + printf("\n"); +} + + +void handler(int signal) +{ + debug("got signal %d", signal); + got_signal = signal; +} + + +static void daemonize(void) +{ + + /* thanks to Petri Damsten, we now follow the guidelines from the UNIX Programming FAQ */ + /* 1.7 How do I get my program to act like a daemon? */ + /* http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16 */ + /* especially the double-fork solved the 'lcd4linux dying when called from init' problem */ + + pid_t i; + int fd; + + + /* Step 1: fork() so that the parent can exit */ + i = fork(); + if (i < 0) { + error("fork(#1) failed: %s", strerror(errno)); + exit(1); + } + if (i != 0) + exit(0); + + /* Step 2: setsid() to become a process group and session group leader */ + setsid(); + + /* Step 3: fork() again so the parent (the session group leader) can exit */ + i = fork(); + if (i < 0) { + error("fork(#2) failed: %s", strerror(errno)); + exit(1); + } + if (i != 0) + exit(0); + + /* Step 4: chdir("/") to ensure that our process doesn't keep any directory in use */ + if (chdir("/") != 0) { + error("chdir(\"/\") failed: %s", strerror(errno)); + exit(1); + } + + /* Step 5: umask(0) so that we have complete control over the permissions of anything we write */ + umask(0); + + /* Step 6: Establish new open descriptors for stdin, stdout and stderr */ + /* detach stdin */ + if (freopen("/dev/null", "r", stdin) == NULL) { + error("freopen (/dev/null) failed: %s", strerror(errno)); + exit(1); + } + + /* detach stdout and stderr */ + fd = open("/dev/null", O_WRONLY, 0666); + if (fd == -1) { + error("open (/dev/null) failed: %s", strerror(errno)); + exit(1); + } + fflush(stdout); + dup2(fd, STDOUT_FILENO); + fflush(stderr); + dup2(fd, STDERR_FILENO); + close(fd); + +} + + +int main(int argc, char *argv[]) +{ + char *cfg = "/etc/lcd4linux.conf"; + char *pidfile = PIDFILE; + char *display, *driver, *layout; + char section[32]; + int c; + int quiet = 0; + int interactive = 0; + int list_mode = 0; + int pid; + + /* save arguments for restart */ + my_argv = malloc(sizeof(char *) * (argc + 1)); + for (c = 0; c < argc; c++) { + my_argv[c] = strdup(argv[c]); + } + my_argv[c] = NULL; + + /* save original arguments pointer for threads */ + thread_argv = argv; + thread_argc = argc; + + running_foreground = 0; + running_background = 0; + +#ifdef WITH_X11 + drv_X11_parseArgs(&argc, argv); + if (argc != thread_argc) { + /* info() will not work here because verbose level is not known */ + printf("recognized special X11 parameters\n"); + } +#endif + while ((c = getopt(argc, argv, "c:Ff:hilo:qvp:")) != EOF) { + + switch (c) { + case 'c': + if (cfg_cmd(optarg) < 0) { + fprintf(stderr, "%s: illegal argument -c '%s'\n", argv[0], optarg); + exit(2); + } + break; + case 'F': + running_foreground++; + break; + case 'f': + cfg = optarg; + break; + case 'h': + usage(); + exit(0); + case 'i': + interactive++; + break; + case 'l': + list_mode++; + break; + case 'o': + output = optarg; + break; + case 'q': + quiet++; + break; + case 'v': + verbose_level++; + break; + case 'p': + pidfile = optarg; + break; + default: + exit(2); + } + } + + if (optind < argc) { + fprintf(stderr, "%s: illegal option %s\n", argv[0], argv[optind]); + exit(2); + } + + /* do not fork in interactive mode */ + if (interactive) { + running_foreground = 1; + } + + if (list_mode > 0) { + printf("%s\n", release); + printf("%s\n", copyright); + printf("\n"); + drv_list(); + printf("\n"); + plugin_list(); + printf("\n"); + exit(0); + } + + info("%s starting", release); + if (!running_foreground && (my_argv[0] == NULL || my_argv[0][0] != '/')) { + info("invoked without full path; restart may not work!"); + } + + if (cfg_init(cfg) == -1) { + error("Error reading configuration. Exit!"); + exit(1); + } + + if (plugin_init() == -1) { + error("Error initializing plugins. Exit!"); + exit(1); + } + + display = cfg_get(NULL, "Display", NULL); + if (display == NULL || *display == '\0') { + error("missing 'Display' entry in %s!", cfg_source()); + exit(1); + } + + qprintf(section, sizeof(section), "Display:%s", display); + free(display); + driver = cfg_get(section, "Driver", NULL); + if (driver == NULL || *driver == '\0') { + error("missing '%s.Driver' entry in %s!", section, cfg_source()); + exit(1); + } + + if (!running_foreground) { + + debug("going background..."); + + daemonize(); + + /* ignore nasty signals */ + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + + /* create PID file */ + if ((pid = pid_init(pidfile)) != 0) { + error("lcd4linux already running as process %d", pid); + exit(1); + } + + /* now we are a daemon */ + running_background = 1; + } + + /* go into interactive mode before display initialization */ + if (interactive >= 2) { + interactive_mode(); + pid_exit(pidfile); + cfg_exit(); + exit(0); + } + + /* check the conf to see if quiet startup is wanted */ + if (!quiet) { + cfg_number(NULL, "Quiet", 0, 0, 1, &quiet); + } + + debug("initializing driver %s", driver); + if (drv_init(section, driver, quiet) == -1) { + error("Error initializing driver %s: Exit!", driver); + pid_exit(pidfile); + exit(1); + } + free(driver); + + /* register timer widget */ + widget_timer_register(); + + /* go into interactive mode (display has been initialized) */ + if (interactive >= 1) { + interactive_mode(); + drv_quit(quiet); + pid_exit(pidfile); + cfg_exit(); + exit(0); + } + + /* check for new-style layout */ + layout = cfg_get(NULL, "Layout", NULL); + if (layout == NULL || *layout == '\0') { + error("missing 'Layout' entry in %s!", cfg_source()); + exit(1); + } + + layout_init(layout); + free(layout); + + debug("starting main loop"); + + + /* now install our own signal handler */ + signal(SIGHUP, handler); + signal(SIGINT, handler); + signal(SIGQUIT, handler); + signal(SIGTERM, handler); + + while (got_signal == 0) { + struct timespec delay; + if (timer_process(&delay) < 0) + break; + event_process(&delay); + } + + debug("leaving main loop"); + + drv_quit(quiet); + pid_exit(pidfile); + cfg_exit(); + plugin_exit(); + timer_exit_group(); + timer_exit(); + + if (got_signal == SIGHUP) { + long fd; + debug("restarting..."); + /* close all files on exec */ + for (fd = sysconf(_SC_OPEN_MAX); fd > 2; fd--) { + int flag; + if ((flag = fcntl(fd, F_GETFD, 0)) != -1) + fcntl(fd, F_SETFD, flag | FD_CLOEXEC); + } + execv(my_argv[0], my_argv); + error("execv() failed: %s", strerror(errno)); + exit(1); + } + + for (c = 0; my_argv[c] != NULL; c++) { + free(my_argv[c]); + } + free(my_argv); + + exit(0); +} diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample new file mode 100644 index 0000000..cf90750 --- /dev/null +++ b/lcd4linux.conf.sample @@ -0,0 +1,1328 @@ +# $Id: lcd4linux.conf.sample 1133 2010-11-19 09:02:34Z harbaum $ +# $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/lcd4linux.conf.sample $ + + +Variables { + tick 500 + tack 100 + minute 60000 +} + +Display G15 { + Driver 'G-15' + Font '6x8' + Contrast 10 + Inverted 0 + UInput '/dev/input/uinput' + SingleKeyPress 1 +} + + +Display SerDispLib { + Driver 'serdisplib' + Port 'PAR:/dev/parports/0' + #Port '/dev/tts/0' + Model 'OPTREX323' + Options '' +} + + +Display Trefon { + Driver 'TREFON' + Size '16x2' + Backlight 1 + Icons 1 +} + + +Display LCD-Linux { + Driver 'LCD-Linux' + Size '20x2' + UseBusy 0 +} + +Display IRLCD { + Driver 'IRLCD' + Size '16x2' + Backlight 0 + Icons 1 +} + +Display LCD2USB { + Driver 'LCD2USB' + Size '20x2' + Backlight 1 + Icons 1 +} + +Display GLCD2USB { + Driver 'GLCD2USB' + Brightness 255 +} + +Display ABP08-16x3 { + Driver 'LW_ABP' + Port '/dev/tts/0' + Speed 19200 + Size '16x3' +} + +Display LCD2041 { + Driver 'MatrixOrbital' + Model 'LCD2041' + Port '/dev/tts/0' + Speed 19200 + Contrast 160 +} + +Display LK202 { + Driver 'MatrixOrbital' + Model 'LK202-24-USB' + Port '/dev/tts/USB0' + Speed 19200 + Contrast 256/2 +} + +Display LK204 { + Driver 'MatrixOrbital' + Model 'LK204-24-USB' + Port '/dev/usb/tts/0' +# Port '/dev/tts/0' + Speed 19200 + Contrast 256/2 +} + + +Display MI240 { + Driver 'MilfordInstruments' + Model 'MI240' + Port '/dev/tts/0' + Speed 19200 +} + + +Display CW12232 { + Driver 'Cwlinux' + Model 'CW12232' + Port '/dev/usb/tts/0' + Speed 19200 + Brightness 2 + Icons 1 +} + + +Display CF631 { + Driver 'Crystalfontz' + Model '631' + Port '/dev/tts/USB0' + Speed 115200 + Contrast 95 + Backlight 50 + Icons 1 +} + +Display CF632 { + Driver 'Crystalfontz' + Model '632' + Port '/dev/tts/0' + Speed 19200 + Icons 1 +} + +Display CF633 { + Icons 1 + Driver 'Crystalfontz' + Model '633' + Port '/dev/tts/0' + Speed 19200 + Contrast 16 + Backlight 50 +} + +Display CF635 { + Icons 1 + Driver 'Crystalfontz' + Model '635' + Port '/dev/ttyUSB0' + Speed 115200 + Contrast 100 + Backlight 128 +} + +Display Curses { + Driver 'Curses' + Size '20x6' +} + +# generic HD44780 display (LCD4Linux wiring) +Display HD44780-generic { + Driver 'HD44780' + Model 'generic' + Port '/dev/parports/0' + Size '8x2' + asc255bug 0 + GPOs 8 + Wire { + RW 'GND' + RS 'AUTOFD' + ENABLE 'STROBE' + ENABLE2 'GND' + GPO 'INIT' + POWER 'GND' + } +} + +# generic HD44780 display (WinAmp wiring) +Display HD44780-winamp { + Driver 'HD44780' + Model 'generic' + UseBusy 1 + Port '/dev/parports/0' + Size '20x4' + asc255bug 1 + Wire { + RW 'AUTOFD' + RS 'INIT' + ENABLE 'STROBE' + ENABLE2 'GND' + GPO 'GND' + POWER 'GND' + } + Timing { + # fuzz timings by value (100 = no change) + fuzz 100 + # low-level communication [ns] + CY 1000 # Enable cycle time + PW 450 # Enable pulse width + AS 140 # Address setup time + AH 20 # Address hold time + # HD44780 execution timings [us] + INIT1 4100 # first init sequence: 4.1 msec + INIT2 100 # second init sequence: 100 usec + EXEC 80 # normal execution time + WRCG 120 # CG RAM Write + CLEAR 2250 # Clear Display + HOME 2250 # Return Cursor Home + ONOFF 2250 # Display On/Off Control + # GPO timing [ns] + GPO_ST 20 # 74HCT573 set-up time + GPO_PW 230 # 74HCT573 enable pulse width + # Power supply timing [ms] + POWER 500 # power-on delay + } +} + +# HD44780 display 4-Bit mode +Display HD44780-4bit { + Driver 'HD44780' + Model 'generic' + Port '/dev/parports/0' + Size '16x1' + Bits 4 + UseBusy 0 + asc255bug 0 + Wire { + RW 'GND' + RS 'DB4' + ENABLE 'DB6' + GPO 'GND' + } +} + +# Dual-HD44780 display from Pollin +Display WDC2704M { + Driver 'HD44780' + Model 'generic' + Controllers 2 + UseBusy 1 + Port '/dev/parports/0' + Size '27x4' + Wire { + RW 'AUTOFD' + RS 'INIT' + ENABLE 'STROBE' + ENABLE2 'SLCTIN' + GPO 'GND' + POWER 'GND' + } +} + +# HD44780 display from www.kernelconcepts.de +Display HD44780-kernelconcepts { + Driver 'HD44780' + Model 'HD66712' + UseBusy 1 + Port '/dev/parports/0' + Size '20x4' + Wire { + RW 'AUTOFD' + RS 'INIT' + ENABLE 'STROBE' + ENABLE2 'GND' + GPO 'GND' + POWER 'GND' + } +} + +Display picoLCD { + Driver 'picoLCD' + Size '20x2' + Contrast 0 + Backlight 1 + Icons 1 +} + +Display picoLCDGraphic { + Driver 'picoLCDGraphic' + Size '256x64' + Contrast 0 + Backlight 100 +} + +Display SC1602D { + Driver 'HD44780' + Port '/dev/parports/0' + Bits '8' + Size '16x2' + asc255bug 0 + Icons 1 + Wire { + RW 'GND' + RS 'AUTOFD' + ENABLE 'STROBE' + GPO 'INIT' + POWER 'GND' + } +} + + +Display LCM-162 { + Driver 'HD44780' + Model 'LCM-162' +# Bus 'parport' + Port '/dev/parports/0' + Size '16x2' + UseBusy 1 + asc255bug 0 + Icons 1 +} + + +Display HD44780-I2C { + Driver 'HD44780' + Model 'generic' + Bus 'i2c' + Port '/dev/i2c-0' + Device '70' + Bits '4' + Size '20x4' + asc255bug 0 + Icons 1 + Wire { + RW 'DB5' + RS 'DB4' + ENABLE 'DB6' + GPO 'GND' + } +} + + +Display LCDTerm { + Driver 'LCDTerm' + Port '/dev/tts/0' + Speed 19200 + Size '20x4' + Icons 1 +} + +Display SimpleLCD { + Driver 'SimpleLCD' + Port '/dev/tts/0' + Speed 1200 + Options 0 + Size '20x2' +} + +Display PHAnderson { + Driver 'PHAnderson' + Port '/dev/tts/0' + Speed 19200 + Size '24x2' + Blackligth 100 + Bootscreen '123456789012345678901234ABCDEFGHIJKLMNOPQRSTUVWX' +} + +Display BA63 { + Driver 'WincorNixdorf' + Model 'BA63' + Port '/dev/tts/0' +# Port '/dev/tts/USB0' + Speed 9600 + BarChar 219 + SelfTest 0 +} + +Display M50530-24x8 { + Driver 'M50530' + Port '/dev/parports/0' +# Port '0x378' + Size '24x8' + Font '5x7' + Duty 2 + Wire.RW 'INIT' + Wire.EX 'STROBE' + Wire.IOC1 'SLCTIN' + Wire.IOC2 'AUTOFD' + Wire.GPO 'GND' + UseBusy 1 + Timing.fuzz 100 +} + + +Display CT20x4 { + Driver 'Beckmann+Egle' + Model 'CT20x4' + Port '/dev/tts/0' +# Size '16x2' +# Contrast 7 +# Backlight 1 + Icons 1 +} + + +Display ULA200 { + Driver 'ULA200' + Size '20x4' + Icons 0 + Backlight 1 +} + +Display USBLCD { + Driver 'USBLCD' +# Port '/dev/lcd0' + Port 'libusb' + Size '20x4' + asc255bug 1 + Icons 1 +} + + +Display BWCT { + Driver 'BWCT' + Size '20x4' + Contrast 220 + asc255bug 1 + Icons 1 +} + + +Display T6963-240x64 { + Driver 'T6963' + Port '/dev/parports/0' + Size '240x64' + DualScan 0 + Cell 6 + Wire.CE 'STROBE' + Wire.CD 'SLCTIN' + Wire.RD 'AUTOFD' + Wire.WR 'INIT' + Timing.fuzz 120 + Font '6x8' +} + +Display T6963-240x128 { + Driver 'T6963' + Port '/dev/parports/0' + Size '240x128' + DualScan 0 + Cell 6 + Wire.CE 'STROBE' + Wire.CD 'SLCTIN' + Wire.RD 'AUTOFD' + Wire.WR 'INIT' + Timing.fuzz 120 + Font '6x8' +} + +Display T6963-240x128D { + Driver 'T6963' + Port '/dev/parports/0' + Size '240x128' + DualScan 1 + Cell 6 + Wire.CE 'STROBE' + Wire.CD 'SLCTIN' + Wire.RD 'AUTOFD' + Wire.WR 'INIT' + Timing.fuzz 120 + Font '6x8' +} + + +Display LPH7508 { + Driver 'LPH7508' + Port '/dev/parports/0' + Font '6x8' + Contrast 15 + Inverted 0 +} + +Display LPH7508-serdisplib { + Driver 'serdisplib' + Port 'PAR:/dev/parports/0' + Model 'LPH7508' +} + +Display ctinclud { + Driver 'serdisplib' + Port 'USB:7c0/1501' + Model 'CTINCLUD' + Options '' + Inverted 0 +} + +Display ASTUSB { + Driver 'ASTUSB' + Size '20x4' + Backlight 1 +} + +Display XWindow { + Driver 'X11' + Size '120x32' + Font '5x8' + Pixel '4+1' + Gap '-1x-1' + Border 20 + Buttons 2 + Foreground '000000cc' + Background '00000022' + Basecolor '80d000' + Bordercolor '90e000' +} + +Display Image { + Driver 'Image' +# Format 'PPM' + Format 'PNG' + Size '120x32' + Font '6x8' + Pixel '4+1' + Gap '-1x-1' + Border 20 +# Foreground '#000000' +# Background '#80d000' +# Halfground '#70c000' + Foreground '000000cc' + Background '00000022' + Basecolor '80d000' +} + +Display VNC { + Driver 'VNC' + Font '6x8' + Port '5900' + Xres '320' + Yres '140' + Bpp '4' + Maxclients '2' + Buttons '4' + Keypadxofs '40' + Keypadyofs '70' + Keypadygap '10' + Keypadcol '8745877' + Osd_showtime '2000' +# Password 'password' + Maxfps '25' +# HttpDir '/path/to/classfiles' + HttpPort '5800' +} + +#Plugin KVV { +# StationID '12_701' +# Refresh 30 +# Proxy 'igate' +# Port 8080; +#} + +Plugin Seti { + Directory '/root/setiathome-3.08.i686-pc-linux-gnu' +} + + +Plugin MySQL { + server 'gsmlandia.com' # if none, localhost assumed + port 3306 # if none, MySQL default assumed + user 'lcd4linux' # if none, lcd4linux unix owner assumed + password 'lcd4linux' # if none, empty password assumed + database 'lcd4linux' # MUST be specified +} + +Plugin Pop3 { + server1 'localhost' + port1 110 + user1 'michael' + password1 'secret' +} + + +Plugin DBus { + # signal 0 is displayed IM msg + # + signal0sender 'im.pidgin.purple.PurpleService' # should be in the form com.domain.app.service, + # the :1.23 form given by dbus-monitor will NOT work, + # if unsure skip it + signal0path '/im/pidgin/purple/PurpleObject' # find using dbus-monitor + signal0interface 'im.pidgin.purple.PurpleInterface' # find using dbus-monitor + signal0member 'DisplayedImMsg' # find using dbus-monitor + signal0eventname 'got_im' # make something up, all Text widgets with an + # event option matching this will be updated +} + + +#this example prints the second argument of signal# 0 +#(in this case it prints the message displayed) +Widget Pidgin { + class 'Text' + expression dbus::argument(0, 1) . ': ' . dbus::argument(0, 2)) + width 20 + align 'R' + event 'got_im' +} + + +Widget OS { + class 'Text' + expression '*** '.uname('sysname').' '.uname('release').' ***' + width 20 + align 'M' + style 'bold' + speed 50 + update tick +} + +Widget CPU { + class 'Text' + expression uname('machine') + prefix 'CPU ' + width 9 + align 'L' + style test::onoff(7)>0?'bold':'norm' + update tick +} + + +Widget CPUinfo { + class 'Text' + expression cpuinfo('model name') + prefix '' + width 20 + align 'M' + speed 100 + update tick +} + + +Widget RAM { + class 'Text' + expression meminfo('MemTotal')/1024 + postfix ' MB RAM' + width 11 + precision 0 + align 'R' + update tick +} + +Widget Busy { + class 'Text' + expression proc_stat::cpu('busy', 500) + prefix 'Busy' + postfix '%' + width 9 + precision 1 + align 'R' + update tick +} + +Widget BusyBar { + class 'Bar' + expression proc_stat::cpu('busy', 500) + expression2 proc_stat::cpu('system', 500) + length 10 + direction 'E' + update tack +} + +Widget Load { + class 'Text' + expression loadavg(1) + prefix 'Load' + postfix loadavg(1)>1.0?'!':' ' + width 10 + precision 1 + align 'R' + update tick +} + +Widget LoadBar { + class 'Bar' + expression loadavg(1) + max 2.0 + length 10 + direction 'E' + update tack +} + + +Widget Disk { + class 'Text' + # disk.[rw]blk return blocks, we assume a blocksize of 512 + # to get the number in kB/s we would do blk*512/1024, which is blk/2 + # expression (proc_stat::disk('.*', 'rblk', 500)+proc_stat::disk('.*', 'wblk', 500))/2 + # with kernel 2.6, disk_io disappeared from /proc/stat but moved to /proc/diskstat + # therefore you have to use another function called 'diskstats': + expression diskstats('hd.', 'read_sectors', 500) + diskstats('hd.', 'write_sectors', 500) + prefix 'disk' + postfix ' ' + width 10 + precision 0 + align 'R' + update tick +} + +Widget DiskBar { + class 'Bar' + #expression proc_stat::disk('.*', 'rblk', 500) + #expression2 proc_stat::disk('.*', 'wblk', 500) + # for kernel 2.6: + expression diskstats('hd.', 'read_sectors', 500) + expression2 diskstats('hd.', 'write_sectors', 500) + length 14 + direction 'E' + update tack +} + +Widget Eth0 { + class 'Text' + expression (netdev('eth0', 'Rx_bytes', 500)+netdev('eth0', 'Tx_bytes', 500))/1024 + prefix 'eth0' + postfix ' ' + width 10 + precision 0 + align 'R' + update tick +} + +Widget Eth0Bar { + class 'Bar' + expression netdev('eth0', 'Rx_bytes', 500) + expression2 netdev('eth0', 'Tx_bytes', 500) + length 14 + direction 'E' + update tack +} + +Widget PPP { + class 'Text' + expression (ppp('Rx:0', 500)+ppp('Tx:0', 500)) + prefix 'PPP' + width 9 + precision 0 + align 'R' + update tick +} + +Widget Temp { + class 'Text' + expression i2c_sensors('temp_input3')*1.0324-67 + prefix 'Temp' + width 9 + precision 1 + align 'R' + update tick +} + +Widget TempBar { + class 'Bar' + expression i2c_sensors('temp_input3')*1.0324-67 + min 40 + max 80 + length 10 + direction 'E' + update tack +} + +Widget MySQLtest1 { + class 'Text' + expression MySQL::query('SELECT id FROM table1') + width 20 + align 'R' + prefix 'MySQL test:' + update minute +} + +Widget MySQLtest2 { + class 'Text' + expression MySQL::status() + width 20 + align 'M' + prefix 'Status: ' + update minute +} + +Widget Uptime { + class 'Text' + expression uptime('%d days %H:%M:%S') + width 20 + align 'R' + prefix 'Up ' + update 1000 +} + +Widget mpris_TrackPosition_bar { + class 'Bar' + expression mpris_dbus::method_PositionGet('org.kde.amarok') + length 40 + min 0 + max 100 + direction 'E' + style 'H' + update 200 +} + +# debugging widgets + +Widget BarTest { + class 'Bar' + # test::bar(barno,maxval,startval,delta) - move a test value between 0 and max. + # delta= step to change value by each time it's read. + # barno - ten different test bar values can be set up, with barno=0..9 + # if delta=0, just returns the value of bar n instead of changing it. + expression test::bar(0,30,25,1) + expression2 test::bar(1,30,0,1) + length 8 + # max 50 + direction 'E' + update 10 +} + +Widget BarTestVal { + class 'Text' + expression test::bar(0,100,50,0) + prefix 'Test ' + width 9 + update 200 +} + +Widget LightningTest { + class 'icon' + speed 500 + visible test::onoff(0) + bitmap { + row1 '...***' + row2 '..***.' + row3 '.***..' + row4 '.****.' + row5 '..**..' + row6 '.**...' + row7 '**....' + row8 '*.....' + } +} + + +# Icons + +Widget Heartbeat { + class 'Icon' + speed 800 + Bitmap { + Row1 '.....|.....' + Row2 '.*.*.|.*.*.' + Row3 '*****|*.*.*' + Row4 '*****|*...*' + Row5 '.***.|.*.*.' + Row6 '.***.|.*.*.' + Row7 '..*..|..*..' + Row8 '.....|.....' + } +} + +Widget EKG { + class 'Icon' + speed 50 + Bitmap { + Row1 '.....|.....|.....|.....|.....|.....|.....|.....' + Row2 '.....|....*|...*.|..*..|.*...|*....|.....|.....' + Row3 '.....|....*|...*.|..*..|.*...|*....|.....|.....' + Row4 '.....|....*|...**|..**.|.**..|**...|*....|.....' + Row5 '.....|....*|...**|..**.|.**..|**...|*....|.....' + Row6 '.....|....*|...*.|..*.*|.*.*.|*.*..|.*...|*....' + Row7 '*****|*****|****.|***..|**..*|*..**|..***|.****' + Row8 '.....|.....|.....|.....|.....|.....|.....|.....' + } +} +Widget Karo { + class 'Icon' + speed 200 + Bitmap { + Row1 '.....|.....|.....|.....|..*..|.....|.....|.....' + Row2 '.....|.....|.....|..*..|.*.*.|..*..|.....|.....' + Row3 '.....|.....|..*..|.*.*.|*...*|.*.*.|..*..|.....' + Row4 '.....|..*..|.*.*.|*...*|.....|*...*|.*.*.|..*..' + Row5 '.....|.....|..*..|.*.*.|*...*|.*.*.|..*..|.....' + Row6 '.....|.....|.....|..*..|.*.*.|..*..|.....|.....' + Row7 '.....|.....|.....|.....|..*..|.....|.....|.....' + Row8 '.....|.....|.....|.....|.....|.....|.....|.....' + } +} +Widget Heart { + class 'Icon' + speed 250 + Bitmap { + Row1 '.....|.....|.....|.....|.....|.....' + Row2 '.*.*.|.....|.*.*.|.....|.....|.....' + Row3 '*****|.*.*.|*****|.*.*.|.*.*.|.*.*.' + Row4 '*****|.***.|*****|.***.|.***.|.***.' + Row5 '.***.|.***.|.***.|.***.|.***.|.***.' + Row6 '.***.|..*..|.***.|..*..|..*..|..*..' + Row7 '..*..|.....|..*..|.....|.....|.....' + Row8 '.....|.....|.....|.....|.....|.....' + } +} +Widget Blob { + class 'Icon' + speed 250 + Bitmap { + Row1 '.....|.....|.....' + Row2 '.....|.....|.***.' + Row3 '.....|.***.|*...*' + Row4 '..*..|.*.*.|*...*' + Row5 '.....|.***.|*...*' + Row6 '.....|.....|.***.' + Row7 '.....|.....|.....' + Row8 '.....|.....|.....' + } +} +Widget Wave { + class 'Icon' + speed 100 + Bitmap { + Row1 '..**.|.**..|**...|*....|.....|.....|.....|.....|....*|...**' + Row2 '.*..*|*..*.|..*..|.*...|*....|.....|.....|....*|...*.|..*..' + Row3 '*....|....*|...*.|..*..|.*...|*....|....*|...*.|..*..|.*...' + Row4 '*....|....*|...*.|..*..|.*...|*....|....*|...*.|..*..|.*...' + Row5 '*....|....*|...*.|..*..|.*...|*....|....*|...*.|..*..|.*...' + Row6 '.....|.....|....*|...*.|..*..|.*..*|*..*.|..*..|.*...|*....' + Row7 '.....|.....|.....|....*|...**|..**.|.**..|**...|*....|.....' + Row8 '.....|.....|.....|.....|.....|.....|.....|.....|.....|.....' + } +} +Widget Squirrel { + class 'Icon' + speed 100 + Bitmap { + Row1 '.....|.....|.....|.....|.....|.....' + Row2 '.....|.....|.....|.....|.....|.....' + Row3 '.....|.....|.....|.....|.....|.....' + Row4 '**...|.**..|..**.|...**|....*|.....' + Row5 '*****|*****|*****|*****|*****|*****' + Row6 '...**|..**.|.**..|**...|*....|.....' + Row7 '.....|.....|.....|.....|.....|.....' + Row8 '.....|.....|.....|.....|.....|.....' + } +} + +Widget Lightning { + class 'icon' + speed 100 + visible cpu('busy', 500)-50 + bitmap { + row1 '...***' + row2 '..***.' + row3 '.***..' + row4 '.****.' + row5 '..**..' + row6 '.**...' + row7 '**....' + row8 '*.....' + } +} + +Widget Rain { + class 'icon' + speed 200 + bitmap { + row1 '...*.|.....|.....|.*...|....*|..*..|.....|*....' + row2 '*....|...*.|.....|.....|.*...|....*|..*..|.....' + row3 '.....|*....|...*.|.....|.....|.*...|....*|..*..' + row4 '..*..|.....|*....|...*.|.....|.....|.*...|....*' + row5 '....*|..*..|.....|*....|...*.|.....|.....|.*...' + row6 '.*...|....*|..*..|.....|*....|...*.|.....|.....' + row7 '.....|.*...|....*|..*..|.....|*....|...*.|.....' + row8 '.....|.....|.*...|....*|..*..|.....|*....|...*.' + } +} + +Widget Timer { + class 'Icon' + speed 50 + Bitmap { + Row1 '.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|' + Row2 '.***.|.*+*.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.+++.|.+*+.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|' + Row3 '*****|**+**|**++*|**+++|**++.|**++.|**+++|**+++|**+++|**+++|**+++|+++++|+++++|++*++|++**+|++***|++**.|++**.|++***|++***|++***|++***|++***|*****|' + Row4 '*****|**+**|**+**|**+**|**+++|**+++|**+++|**+++|**+++|**+++|+++++|+++++|+++++|++*++|++*++|++*++|++***|++***|++***|++***|++***|++***|*****|*****|' + Row5 '*****|*****|*****|*****|*****|***++|***++|**+++|*++++|+++++|+++++|+++++|+++++|+++++|+++++|+++++|+++++|+++**|+++**|++***|+****|*****|*****|*****|' + Row6 '.***.|.***.|.***.|.***.|.***.|.***.|.**+.|.*++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.++*.|.+**.|.***.|.***.|.***.|.***.|' + Row7 '.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|' + Row8 '.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|' + + + } +} + +Widget Test { + class 'Text' + expression '1234567890123456789012345678901234567890' + width 40 + foreground 'ff0000ff' +} + +Widget Test1 { + class 'Text' + expression 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' + width 40 + align 'M' + speed 100 +} + +Widget Test2 { + class 'Text' + expression '1234567890abcdefghijklmnopqrstuvwxyz' + width 40 + align 'M' + speed 150 +} + +Widget GPO_Val1 { + class 'Text' + expression LCD::GPO(1) + prefix 'GPO#1' + width 10 + precision 0 + align 'R' + update tick +} + +Widget GPI_Val1 { + class 'Text' + expression LCD::GPI(1) + prefix 'GPI#1' + width 10 + precision 0 + align 'R' + update tick +} + +Widget GPO_Val4 { + class 'Text' + expression LCD::GPO(4) + prefix 'GPO#4' + width 10 + precision 0 + align 'R' + update tick +} + +Widget GPO_Test1 { + class 'GPO' + expression 255*test::onoff(1) + update 300 +} + +Widget GPO_Test255 { + class 'GPO' + expression test::bar(0,255, 0, 1) + update 100 +} + +Widget ImageTest { + class 'Image' + file 'tux.png' + update 1000 + visible 1 + inverted 0 +} + +Widget KVV { + class 'Text' + expression kvv::line(0).' '.kvv::station(0) + width 11 + + align 'L' + update tick + Foreground 'ffff00' + style 'bold' +} + +Widget KVV_TIME { + class 'Text' + expression kvv::time_str(0) + width 2 + + align 'R' + update tick + foreground kvv::time(0) < 2 ? 'FF0000' : ( kvv::time(0) < 5 ? 'FFFF00' : '00FF00' ) + style 'bold' +} + +Layout Default { + Row1 { + Col1 'OS' + } + Row2 { + Col1 'CPU' + Col10 'RAM' + } + Row3 { + Col1 'Busy' + Col10 'Rain' + Col11 'BusyBar' + } + Row4 { + Col1 'Load' + Col11 'LoadBar' + } + Row5 { + Col1 'Disk' + Col11 'DiskBar' + } + Row6 { + Col1 'Eth0' + Col11 'Eth0Bar' + } +} + +Layout TestLayer { + Row1 { + Col1 'OS' + } + Row2 { + Col1 'CPU' + Col10 'RAM' + } + Row3 { + Col1 'Busy' + Col10 'Rain' + Col11 'BusyBar' + } + Row4 { + Col1 'Load' + Col11 'LoadBar' + } + Row5 { + Col1 'Disk' + Col11 'DiskBar' + } + Row6 { + Col1 'Eth0' + Col11 'Eth0Bar' + } + Layer 2 { + X1.Y1 'ImageTest' + } +} + +Layout TestImage { + Layer 2 { + X1.Y1 'ImageTest' + } +} + +Layout L24x8 { + Row1 { + Col1 'Load' + Col11 'BusyBar' + } + Row2 { + } +} + +Layout L8x2 { + Row1 { + Col1 'Busy' + } + Row2 { + Col1 'BarTest' + } +} + +Layout L16x1 { + Row1 { + Col1 'Busy' + Col11 'BusyBar' + } +} + +Layout L16x2 { + Row1 { + Col1 'Busy' + Col11 'BusyBar' + } + Row2 { + Col1 'Disk' + #Col11 'DiskBar' + Col11 'BarTest' + } +} + +Layout L20x2 { + Row1 { + Col1 'CPUinfo' + } + Row2 { + Col1 'Busy' + Col11 'BusyBar' + } +} + +Layout L40x2 { + Row1 { + Col1 'OS' + Col21 'Busy' + Col31 'BusyBar' + } + Row2 { + Col1 'CPU' + Col10 'RAM' + Col21 'Load' + Col31 'LoadBar' + } +} + +Layout Test { + Row01.Col1 'Test1' + Row02.Col1 'Test1' + Row03.Col1 'Test1' + Row04.Col1 'Test1' + Row05.Col1 'Test1' + Row06.Col1 'Test1' + Row07.Col1 'Test1' + Row08.Col1 'Test1' + Row09.Col1 'Test1' + Row10.Col1 'Test1' + Row11.Col1 'Test1' + Row12.Col1 'Test1' + Row13.Col1 'Test1' + Row14.Col1 'Test1' + Row15.Col1 'Test1' + Row16.Col1 'Test1' + Row17.Col1 'Test1' + Row18.Col1 'Test1' + Row19.Col1 'Test1' + Row20.Col1 'Test1' + Row21.Col1 'Test1' + Row22.Col1 'Test1' + Row23.Col1 'Test1' + Row24.Col1 'Test1' +} + +Layout Test2 { + Row01.Col1 'Test1' + #Row02.Col1 'Rain' + Row02.Col1 'Test2' + Row03.Col1 'Test1' + Row04.Col1 'Test2' + Row05.Col1 'Test1' + Row06.Col1 'Test2' + Row07.Col1 'Test1' + Row08.Col1 'Test2' +} + +Layout TestGPO { + Row1.Col1 'GPO_Val1' + Row1.Col10 'GPI_Val1' + Row2.Col1 'GPO_Val4' + GPO1 'GPO_Test255' + GPO4 'GPO_Test1' +} + +Layout TestIcons { + Row1.Col1 'Timer' + Row1.Col2 'Rain' + Row1.Col3 'Squirrel' + Row1.Col4 'Wave' + Row1.Col5 'Blob' + Row1.Col6 'Heart' + Row1.Col7 'Karo' + Row1.Col8 'EKG' +} + +Layout testMySQL { + Row1 { + Col1 'MySQLtest1' + } + Row2 { + Col1 'MySQLtest2' + } +} + +Layout Debug { + #Row09.Col1 'Test' + Row09.Col1 'Heartbeat' +} + + + +#Display 'SerDispLib' +#Display 'LCD-Linux' +#Display 'LCD2041' +#Display 'LK202' +#Display 'LK204' +#Display 'MI240' +#Display 'CW12232' +#Display 'HD44780-generic' +#Display 'HD44780-WinAmp' +#Display 'HD44780-4bit' +#Display 'WDC2704M' +#Display 'SC1602D' +#Display 'LCM-162' +#Display 'CF631' +#Display 'CF632' +#Display 'CF633' +#Display 'Curses' +#Display 'M50530-24x8' +#Display 'LCDTerm' +#Display 'SimpleLCD' +#Display 'BA63' +#Display 'CT20x4' +#Display 'T6963-240x64' +#Display 'T6963-240x128' +#Display 'T6963-240x128D' +#Display 'XWindow' +#Display 'IRLCD' +#Display 'USBLCD' +#Display 'BWCT' +#Display 'Image' +#Display 'Trefon' +#Display 'LCD2USB' +#Display 'LPH7508-serdisplib' +#Display 'LPH7508' +#Display 'ctinclud' +#Display 'picoLCD' +#Display 'VNC' +Display 'GLCD2USB' + +#Layout 'Default' +Layout 'TestLayer' +#Layout 'TestImage' +#Layout 'L8x2' +#Layout 'L16x1' +#Layout 'L16x2' +#Layout 'L20x2' +#Layout 'L40x2' +#Layout 'Test' +#Layout 'Test2' +#Layout 'TestGPO' +#Layout 'Debug' +#Layout 'TestIcons' |