From a63ae89eb7442fae64c9155cd066048008de920e Mon Sep 17 00:00:00 2001 From: marschap Date: Mon, 2 Apr 2007 15:32:14 +0000 Subject: [PATCH] make LCDd's exit message configurable --- ChangeLog | 1 + LCDd.conf | 4 ++ contrib/patches/README | 2 - contrib/patches/lcdprocserverOPT.diff | 19 ------- docs/lcdproc-user/configuration.docbook | 33 ++++++++++++ server/serverscreens.c | 68 +++++++++++-------------- 6 files changed, 67 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8dbe57..7a7d3fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,7 @@ v.0.5dev (ongoing development) + picolcd - driver for Mini-box.com USB LCD picoLCD (Gatewood Green) + new ConnectionType pertelian in hd44780 driver (Matteo Pillon) + new ConnectionType lcd2usb in hd44780 driver + + make LCDd's GoodBye message configurable v.0.5.1 + config file support in lcdproc client (Andrew Foss) diff --git a/LCDd.conf b/LCDd.conf index 13070c6..f4e2a10 100644 --- a/LCDd.conf +++ b/LCDd.conf @@ -78,6 +78,10 @@ User=nobody # NOTE: Always place a slash as last character ! DriverPath=server/drivers/ +# GoodBye message: each entry represents a display line; default: builtin +#GoodBye="Thanks for using" +#GoodBye=" LCDproc!" + # The "...Key=" lines define what the server does with keypresses that # don't go to any client. # These are the defaults: diff --git a/contrib/patches/README b/contrib/patches/README index fb9cb0f..418ce75 100644 --- a/contrib/patches/README +++ b/contrib/patches/README @@ -27,8 +27,6 @@ one there, so I'll keep thinking on it for now. just to not display a useless menu. Let the server menu name be configurable in the config file with the [menu]menuentryname="Menu Name" option in LCDd.conf. -* setting the goodbye msg - which we set to "shutting down", instead of - "Thanks for using lcdproc+linux" 3. SEG - adds the ability to get a stack trace for the LCDd daemon. I didn't actually catch a useful trace w/ it, but might be a nice diff --git a/contrib/patches/lcdprocserverOPT.diff b/contrib/patches/lcdprocserverOPT.diff index 767bd6c..48d6ce7 100644 --- a/contrib/patches/lcdprocserverOPT.diff +++ b/contrib/patches/lcdprocserverOPT.diff @@ -241,22 +241,3 @@ diff -ruNp lcdproc-0.5.1-orig/server/serverscreens.c lcdproc-0.5.1-working/serve } else { w->text[0] = 0; } -@@ -157,6 +173,18 @@ goodbye_screen () - char *l16 = " LCDproc! "; - #endif - -+#ifndef OPT // disable config goobye -+ char * goodbye_string; -+ -+ if ( (goodbye_string = strdup(config_get_string("server", "goodbye", 0, "")))) { -+ t20=t16=goodbye_string; -+ if (strlen(goodbye_string) > 16 ) -+ l16 = goodbye_string + 16; -+ if (strlen(goodbye_string) > 20 ) -+ l20 = goodbye_string + 20; -+ } -+#endif //OPT -+ - if( !display_props ) - return 0; - diff --git a/docs/lcdproc-user/configuration.docbook b/docs/lcdproc-user/configuration.docbook index 77beda1..f9da997 100644 --- a/docs/lcdproc-user/configuration.docbook +++ b/docs/lcdproc-user/configuration.docbook @@ -221,6 +221,39 @@ settings for the LCDproc server LCDd. to syslog. Defaults to no. + + + + GoodBye= + GOODBYEMSG + + + + Define the message left on the screen when LCDd exits. + If not given, it defaults to the builtin + Thanks for using LCDproc!. + If it is given, each GoodBye= directive represents + a line on the display. + + + The GOODBYEMSGs will be printed on + the display one after each other starting on the beginning of each line. + So, the definition of + + GoodBye=" So Long," + GoodBye=" and" + GoodBye="Thanks for All the Fish!" + + prints the well known dolphin's message on the first 3 lines + of the display (which obviously needs to be 24 columns wide + to show the full last line). + + + To simply disable the default builtin message, and leave the screen blank + a single GoodBye="" suffices. + + + diff --git a/server/serverscreens.c b/server/serverscreens.c index 7fcf3da..58884fb 100644 --- a/server/serverscreens.c +++ b/server/serverscreens.c @@ -22,6 +22,7 @@ #endif #include "shared/report.h" +#include "shared/configfile.h" #include "drivers/lcd.h" #include "drivers.h" @@ -139,53 +140,42 @@ update_server_screen () } int -goodbye_screen () +goodbye_screen() { - char *b20 = " "; - char *t20 = " Thanks for using "; -#ifdef LINUX - char *l20 = " LCDproc and Linux! "; -#else - char *l20 = " LCDproc! "; -#endif - - char *b16 = " "; - char *t16 = "Thanks for using"; -#ifdef LINUX - char *l16 = " LCDproc+Linux! "; -#else - char *l16 = " LCDproc! "; -#endif - - if( !display_props ) + if(!display_props) return 0; - drivers_clear (); + drivers_clear(); - if (display_props->height >= 4) { - if (display_props->width >= 20) { - drivers_string (1, 1, b20); - drivers_string (1, 2, t20); - drivers_string (1, 3, l20); - drivers_string (1, 4, b20); - } else { - drivers_string (1, 1, b16); - drivers_string (1, 2, t16); - drivers_string (1, 3, l16); - drivers_string (1, 4, b16); + if (config_has_key("Server", "GoodBye")) { /* custom GoodBye */ + int i; + + /* loop over all display lines to read config & display message */ + for (i = 0; i < display_props->height; i++) { + const char *line = config_get_string("Server", "GoodBye", i, ""); + + drivers_string(1, 1+i, line); } - } else { - if (display_props->width >= 20) { - drivers_string (1, 1, t20); - drivers_string (1, 2, l20); - } else { - drivers_string (1, 1, t16); - drivers_string (1, 2, l16); + } + else { /* default GoodBye */ + if ((display_props->height >= 2) && (display_props->width >= 16)) { + int xoffs = (display_props->width - 16) / 2; + int yoffs = (display_props->height - 2) / 2; + + char *top = "Thanks for using"; +#ifdef LINUX + char *low = "LCDproc & Linux!"; +#else + char *low = " LCDproc! "; +#endif + + drivers_string(1+xoffs, 1+yoffs, top); + drivers_string(1+xoffs, 2+yoffs, low); } } - drivers_cursor (1, 1, CURSOR_OFF); - drivers_flush (); + drivers_cursor(1, 1, CURSOR_OFF); + drivers_flush(); return 0; }