From 98d4d81b10af8922515d6b5dd136eaad4881b23b Mon Sep 17 00:00:00 2001 From: Seth Mos Date: Sat, 26 Jan 2008 22:39:13 +0000 Subject: Update LCDproc package. - After installing and selecting some screens this should display something. - PHP lcdproc client not yet finished. Using included lcdproc client for now. --- packages/lcdproc/lcdproc.inc | 66 +++++++++++++++++++++++++++++++----- packages/lcdproc/lcdproc.xml | 20 ++++++----- packages/lcdproc/lcdproc_client.php | 54 +++++++++++++++++------------ packages/lcdproc/lcdproc_screens.xml | 56 ++++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 37 deletions(-) create mode 100644 packages/lcdproc/lcdproc_screens.xml (limited to 'packages/lcdproc') diff --git a/packages/lcdproc/lcdproc.inc b/packages/lcdproc/lcdproc.inc index d6c3d530..adf3f931 100644 --- a/packages/lcdproc/lcdproc.inc +++ b/packages/lcdproc/lcdproc.inc @@ -32,7 +32,7 @@ /* LCDproc */ define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh'); - define('LCDPROC_CLIENT', '/tmp/lcdprocc.sh'); + define('LCDPROC_CLIENT', '/tmp/lcdclient.sh'); define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf'); define('LCDPROC_HOST','localhost'); define('LCDPROC_PORT','13666'); @@ -61,6 +61,17 @@ fclose($handle); } + function lcdproc_write_script($file, $text) { + $handle = fopen($file, 'wx'); + if(!$handle) { + lcdproc_warn("Could not open {$file} for writing."); + exit; + } + fwrite($handle, $text); + fclose($handle); + chmod($file, 0755); + } + function before_form_lcdproc($pkg) { global $config; @@ -69,6 +80,14 @@ config_unlock(); } + function before_form_lcdproc_screens($pkg) { + global $config; + + config_lock(); + + config_unlock(); + } + function validate_form_lcdproc($post, $input_errors) { if($post['comport']) { switch($post['comport']) { @@ -90,14 +109,22 @@ } } } + function validate_form_lcdproc_screens($post, $input_errors) { + // No validation required ?! + } + function sync_package_lcdproc_screens() { + sync_package_lcdproc(); + } function sync_package_lcdproc() { + global $g; global $config; global $input_errors; config_lock(); $lcdproc_config = $config['installedpackages']['lcdproc']['config'][0]; + $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0]; /* since config is written before this file invoked we don't need to read post data */ if($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) { @@ -124,11 +151,11 @@ $config_text .= "ReportToSyslog=yes\n"; $config_text .= "WaitTime=5\n"; $config_text .= "User=nobody\n"; - $config_text .= "ServerScreen=0\n"; + $config_text .= "ServerScreen=no\n"; $config_text .= "Foreground=no\n"; $config_text .= "DriverPath=/usr/local/lib/lcdproc/\n"; $config_text .= "GoodBye=\"Thanks for using\"\n"; - $config_text .= "GoodBye=\" {$g['product']} \"\n"; + $config_text .= "GoodBye=\" {$g['product_name']} \"\n"; /* FIXME: Specific to the pyramid project */ $config_text .= "ToggleRotateKey=Enter\n"; $config_text .= "PrevScreenKey=Left\n"; @@ -217,13 +244,35 @@ } /* generate rc file start and stop */ + $options = ""; + foreach($lcdproc_screens_config as $name => $screen) { + if($screen == "on") { + switch($name) { + case "scr_cpu": + $options .= "P "; + break; + case "scr_time": + $options .= "O "; + break; + case "scr_load": + $options .= "L "; + break; + case "scr_uptime": + $options .= "U "; + break; + } + } + } $client_script = << 'lcdproc.sh', diff --git a/packages/lcdproc/lcdproc.xml b/packages/lcdproc/lcdproc.xml index 34dc7fa4..e87ad03d 100644 --- a/packages/lcdproc/lcdproc.xml +++ b/packages/lcdproc/lcdproc.xml @@ -2,9 +2,20 @@ Services: LCDproc lcdproc - 0.5.2_1-p2 + 0.5.2_1-p3 Save /usr/local/pkg/lcdproc.inc + + + Server + /pkg_edit.php?xml=lcdproc.xml&id=0 + + + + Screens + /pkg_edit.php?xml=lcdproc_screens.xml&id=0 + + LCDproc Set LCDproc settings such as display driver and com port @@ -26,13 +37,6 @@ lcdproc.sh lcdproc - - - LCDproc Settings - /pkg_edit.php?xml=lcdproc.xml&id=0 - - - Enable LCDproc diff --git a/packages/lcdproc/lcdproc_client.php b/packages/lcdproc/lcdproc_client.php index ea9d8c97..a07b62ce 100644 --- a/packages/lcdproc/lcdproc_client.php +++ b/packages/lcdproc/lcdproc_client.php @@ -27,8 +27,8 @@ POSSIBILITY OF SUCH DAMAGE. */ - require_once("config.inc"); - require_once("functions.inc"); + // require_once("config.inc"); + // require_once("functions.inc"); require_once("/usr/local/pkg/lcdproc.inc"); /* Define functions */ @@ -39,34 +39,46 @@ } foreach($lcd_cmds as $lcd_cmd) { $cmd_output = ""; - fwrite($lcd, $lcd_cmd); - $cmd_output .= fgets($lcd, 128); - lcdproc_notice("LCDd output for cmd $lcd_cmd is: $cmd_output"); - sleep(1); + if(! fwrite($lcd, "$lcd_cmd\n")) { + lcdproc_warn("Connection to LCDd process lost $errstr ($errno)"); + die(); + } + $cmd_output = fgets($lcd, 4096); + if(preg_match("/^huh?/", $cmd_output)) { + lcdproc_notice("LCDd output: \"$cmd_output\". Executed \"$lcd_cmd\""); + } + // sleep(1); } } function loop_status($lcd) { + global $g; + global $config; /* keep a counter to see how many times we can loop */ - $i = 0; - while(1) { - $time = time(); + $i = 1; + while($i) { + $time = date ("l dS of F Y h:i:s A"); $lcd_cmds = array(); - $lcd_cmds[] = "client_set -name \"Parenttest\"\n"; - $lcd_cmds[] = "screen_add status\n"; - $lcd_cmds[] = "screen_set status -heartbeat off\n"; - $lcd_cmds[] = "widget_add status title title\n"; - $lcd_cmds[] = "widget_add status date scroller\n"; - $lcd_cmds[] = "widget_set status title $i\n"; - $lcd_cmds[] = "widget_set status date left right h 1 $time\n"; + $lcd_cmds[] = "widget_set welcome_scr title_wdgt \"$i test \""; + // $lcd_cmds[] = "widget_set welcome_scr text_wdgt 1 1 \"$time test\""; + $lcd_cmds[] = "widget_set welcome_scr text_wdgt 1 2 20 2 h 4 \"$i $time test\""; + // $lcd_cmds[] = "output on 1 \""; send_lcd_commands($lcd, $lcd_cmds); + sleep(10); $i++; } } - function send_hello($lcd) { + function build_interface($lcd) { $lcd_cmds = array(); - $lcd_cmds[] = "hello\n"; + $lcd_cmds[] = "hello"; + $lcd_cmds[] = "client_set name pfSense"; + $lcd_cmds[] = "screen_add welcome_scr"; + $lcd_cmds[] = "screen_set welcome_scr heartbeat off"; + // $lcd_cmds[] = "screen_set welcome_scr duration 32"; + $lcd_cmds[] = "screen_set welcome_scr name welcome"; + $lcd_cmds[] = "widget_add welcome_scr title_wdgt title"; + $lcd_cmds[] = "widget_add welcome_scr text_wdgt scroller"; send_lcd_commands($lcd, $lcd_cmds); } @@ -75,10 +87,10 @@ if (!$lcd) { lcdproc_warn("Failed to connect to LCDd process $errstr ($errno)"); } else { - send_hello($lcd); + build_interface($lcd); loop_status($lcd); /* loop exited? Close fd and wait for the script to kick in again */ - sleep(1); + // sleep(1); + fclose($lcd); } - fclose($lcd); ?> diff --git a/packages/lcdproc/lcdproc_screens.xml b/packages/lcdproc/lcdproc_screens.xml new file mode 100644 index 00000000..9c44852d --- /dev/null +++ b/packages/lcdproc/lcdproc_screens.xml @@ -0,0 +1,56 @@ + + + Services: LCDproc: Screens + lcdproc_screens + 0.5.2_1-p3 + Save + /usr/local/pkg/lcdproc.inc + + + Server + /pkg_edit.php?xml=lcdproc.xml&id=0 + + + Screens + /pkg_edit.php?xml=lcdproc_screens.xml&id=0 + + + + + LCDproc + Set LCDproc settings such as display driver and com port +
Services
+ /pkg_edit.php?xml=lcdproc.xml&id=0 +
+ + + Enable CPU + scr_cpu + checkbox + + + Enable Load + scr_load + checkbox + + + Enable Time + scr_time + checkbox + + + Enable Uptime + scr_uptime + checkbox + + + + before_form_lcdproc_screens(&$pkg); + + + validate_form_lcdproc_screens($_POST, &$input_errors); + + + sync_package_lcdproc_screens(); + +
-- cgit v1.2.3