After this patch is applied, F2 can be enabled automatically at boot by adding this tag to the theme.xml
<autoverboseonstart>yes</autoverboseonstart> After installing this package, the default theme includes the new tag (set to no). It is necessary to make sure the theme has <textbox><enable>yes .... <textbox> <!-- whether you want the textbox always shown or no. If no, it will be shown only on error--> <enable>yes</enable> The patch is attached. It touches many files since I updated affected man pages plus the theme generation code. I also made some minor improvements to interactive theme generation (a message explains why theme name and image name input is not accepted). I removed the unused code for the verbose error messages (it was very, very slow as indicated in the code), and I marked in the man pages that verbose on error is not implemented
--- a/src/splashycnf.h +++ b/src/splashycnf.h @@ -42,6 +42,7 @@ #define SPL_THEME_CONFIG_FILE_NAME "theme.xml" /** xpaths for common xml strings in config files */ #define SPL_AUTO_VERBOSE_ON_ERROR "/splashy/autoverboseonerror" +#define SPL_AUTO_VERBOSE_ON_START "/splashy/autoverboseonstart" #define SPL_CURRENT_THEME "/splashy/current_theme" #define SPL_DEFAULT_THEME "/splashy/default_theme" #define SPL_THEMES_DIR "/splashy/themes" --- a/src/splashy_functions.c +++ b/src/splashy_functions.c @@ -89,10 +89,9 @@ * * * * * to true at cmd_exit() */ static gboolean read_console = FALSE; /* flag to turn on/off reading the * /dev/vcs* files */ -static gboolean switched_to_verbose = FALSE; /* flag to know when verbose - * image is displayed */ static gboolean F2_toggle_pressed = FALSE; /* keeps track of the depress * F2 key */ + static gint timeout = 120; /* time out when reading from splashy socket * (in seconds). If splashy doesn't recvmsg * for this long, splashy will exit. */ @@ -663,6 +662,7 @@ } + inline void _switch_to_verbose_image () { @@ -678,250 +678,7 @@ splashy_change_splash (background); } -/** - * When autoverboseonerror is set we show the scrolling - * text from the consoles /dev/vcs* - * @param data - not used - * @return - * - * TODO - * - make use of real console - * - this is a slow function - */ -inline void * -verbose_text_loop (void *data) -{ - FILE *dev_vcs; - char buf[81]; - GString *buf_str; /* what to display */ - GString *device; /* /dev/vcs to read */ - gshort i, j; - const gchar *error_pattern; - - gboolean found_error; - gboolean autoverbose; - struct timespec _sleep; - - dev_vcs = NULL; - switched_to_verbose = FALSE; /* verbose image flag */ - splashy_set_textbox_area_visible (FALSE); - - autoverbose = FALSE; /* assume we don't need verbose mode for now */ - read_console = TRUE; /* assume we will be able to read from a - * console */ - found_error = FALSE; /* we have not found any errors yet */ - error_pattern = "(FATAL|fail|error|abort|===|recovering journal)"; - - _sleep.tv_sec = 1; - _sleep.tv_nsec = 0; - - device = g_string_new (""); - - /* - * get autoverboseonerror from config file and set autoverbose - * accordingly - */ - if (g_ascii_strncasecmp - (splashy_get_config_string (SPL_AUTO_VERBOSE_ON_ERROR), "yes", - 3) == 0) - autoverbose = TRUE; - - /* - * set the cancellation parameters -- - Enable thread cancellation - - * Defer the action of the cancellation - */ - pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); - pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL); - - while (1) - { - if (exiting || read_console == FALSE) - { - DEBUG_PRINT ("Not reading console at all..."); - /* - * this thread shouldn't be holding a lock on this - * but... - */ - sched_yield (); - nanosleep (&_sleep, NULL); - continue; - } - /* - * read the realcons console and look for error patterns - * on error, set our background image accordingly and display - * text printing 1 line (80 char) at a time - */ - /* - * Ubuntu uses /dev/vcs2, every other distro /dev/vcs1 - */ - for (i = 1; i <= 7; i++) - { - g_string_printf (device, "/dev/vcs%d", i); - if (!g_file_test (device->str, G_FILE_TEST_EXISTS)) - { - sched_yield (); - continue; - } - dev_vcs = g_fopen (device->str, "r"); - if (!dev_vcs) - { - DEBUG_PRINT ("Can't open %s for reading", - device->str); - sched_yield (); - /* - * short wait - */ - _sleep.tv_sec = 0; - /* - * 1/2 second - */ - _sleep.tv_nsec = 459999999; - nanosleep (&_sleep, NULL); - continue; - } - while (fgets_unlocked (buf, 81, dev_vcs)) - { - if (strlen (buf) < 8) - continue; - /* - * we need to find where the spaces end - */ - for (j = 0; j < strlen (buf); j++) - { - if (buf[j] != ' ') - { - break; - } - } - - /* - * copy only the characters now (no leading spaces) - */ - buf_str = g_string_new (""); - for (; j < strlen (buf); j++) - { - g_string_append_c (buf_str, buf[j]); - } - - /* - * we don't need to print blank lines or new-lines - */ - /* - * if (strlen(buf) < 8) - */ - if (search_pattern_str - ("[^a-zA-Z0-9]", buf_str->str, - 0) == FALSE) - { - - g_string_free (buf_str, TRUE); - continue; - } - - /* - * look for error messages only if we weren't asked - * to display text right the way - */ - if (splashy_get_textbox_area_visible () != - TRUE) - { - /* - * we only look for errors if autoverbose - * is set to TRUE - * once an error is found, we keep printing - * the text to the textbox area without - * matching any more errors - */ - - if (found_error == FALSE) - { - if (autoverbose == TRUE) - { - found_error = - search_pattern_str - (error_pattern, - buf, 1); - } - - /* - * when the user presses F2 - * we want to show the buffer - * in the textbox anyway. - * regardless of whether an - * error was found or not - */ - if (F2_toggle_pressed != TRUE) - { - g_string_free - (buf_str, - TRUE); - continue; - } - } - else - { - /* - * error was found, we need to display the error image - * and allow the textbox area to be shown - */ - found_error = TRUE; - splashy_set_textbox_area_visible - (TRUE); - - if (autoverbose == TRUE - && switched_to_verbose == - FALSE) - { - _switch_to_verbose_image - (); - switched_to_verbose = - TRUE; - /* - * fake F2 pressed so that users can press - * this key to turn off the textbox area - */ - F2_toggle_pressed = - TRUE; - } - } - } - - /* - * pressing F2 will cause text to be printed to the textbox - * as well as having autoverbose set to ON in the config.xml - */ - if (autoverbose == TRUE - || F2_toggle_pressed == TRUE) - { - if (!exiting) - splashy_printline_s ((char *) - buf_str-> - str); - - sched_yield (); - - for (j = 0; j < 81; j++) - { - buf[j] = '\0'; /* make it - * all NULs */ - } - - /* - * wait for 1/6 seconds - */ - _sleep.tv_sec = 0; - _sleep.tv_nsec = 114999999; - nanosleep (&_sleep, NULL); - } - g_string_free (buf_str, TRUE); - } - fclose (dev_vcs); - } - } - g_string_free (device, TRUE); /* never reached */ - pthread_exit (NULL); /* never reached */ -} inline void * socket_loop (void *data) { @@ -1112,6 +869,14 @@ pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL); + if ( g_ascii_strncasecmp + (splashy_get_config_string (SPL_AUTO_VERBOSE_ON_START), "yes", + 3) == 0) + { + F2_toggle_pressed = TRUE; /* the next F2 will turn off text */ + splashy_set_textbox_area_visible (TRUE); + + } while (1) { if (exiting) @@ -1122,6 +887,8 @@ /* * sub-parent (we are a fork after all). init is our parent */ + + /* Wait for keyboard input or getstring/getpass */ splashy_wait_for_event (); /* seize the keyboard, blocking if getstring/getpass running */ @@ -1200,21 +967,15 @@ _splashy_child (const gchar * seq) { gint i; /* general purpose counter */ - gint thr_id_c, thr_id_d; /* thread ID for the newly * created - * thread: c - keyboard events d - - * SplashyClient handler */ + gint thr_id_c, thr_id_d; /* thread ID for the newly * created + * thread: c - keyboard events d - + * SplashyClient handler + * thread: f verbose text loop + */ pthread_t p_thread_c, p_thread_d; /* we need thread C and D to * manage our keyboard events - * * * and SplashyClient */ + * and SplashyClient */ - /* - * gint thr_id_f; * Handles /dev/vcs1 text to be displayed to * - * splashy overlay textbox ... when pressing * F2 we launch a thread - * to handle the * console text - */ - /* - * pthread_t p_thread_f; - */ gboolean _preview = FALSE; @@ -1279,15 +1040,13 @@ } else { - /* send a SIGUSR2 signal to parent process. This signal lets the parent process exit so that init can continue */ - /* stalling init until this point is necessary to avoid the race condition causing bug 505270 */ - /* the signal handler is defined in splashy_main.c */ + /* send a SIGUSR2 signal to parent process. This signal lets the parent process + * exit so that init can continue. Until this signal is sent, the parent waits, stalling the boot. + * Stalling init until this point is necessary to avoid the race condition which caused bug #505270 + * the signal handler is defined in splashy_main.c + */ - /***** for testing ***** - * ERROR_PRINT("deliberate failure for testing purposes"); - * g_usleep(2000000); - *****/ pid_t parentID = getppid(); kill(parentID,SIGUSR2); @@ -1311,11 +1070,6 @@ thr_id_d = pthread_create (&p_thread_d, NULL, keyevent_loop, NULL); /* - * thr_id_f = pthread_create (&p_thread_f, NULL, verbose_text_loop, - * NULL); - */ - - /* * Wait till thread is finished reading the socket... ie 'forever' */ pthread_join (p_thread_c, NULL); --- a/src/xml_functions.h +++ b/src/xml_functions.h @@ -119,7 +119,8 @@ guint textfont_blue; guint textfont_alpha; - gchar *verbose; + gchar *verbose_error; + gchar *verbose_start; gchar *fadein; gchar *fadeout; } XmlFields; --- a/themes/default/theme.xml +++ b/themes/default/theme.xml @@ -132,6 +132,7 @@ </text> </textbox> <autoverboseonerror>no</autoverboseonerror> + <autoverboseonstart>no</autoverboseonstart> <fadein>no</fadein> <fadeout>no</fadeout> </splashy> --- a/src/splashy_video.c +++ b/src/splashy_video.c @@ -1123,8 +1123,14 @@ * - linux_input := we loose input from keyboard on dfb 0.9.25 * - radeon := we use fbdev on Linux */ - DirectFBSetOption ("quiet", NULL); + +#ifdef DEBUG + DirectFBSetOption ("debug", NULL); +#else + DirectFBSetOption ("quiet", NULL);\ DirectFBSetOption ("no-debug", NULL); +#endif + DirectFBSetOption ("graphics-vt", NULL); DirectFBSetOption ("no-cursor", NULL); /* --- a/doc/splashy-theme.xml.pod +++ b/doc/splashy-theme.xml.pod @@ -234,7 +234,7 @@ <textbox> <!-- whether you want the textbox enabled. If no, the F2 key does nothing - see autoverboseonerror --> + --> <enable>yes</enable> <!-- here are tags to set the text area... x coordinate, y coordinate, width and height are for the text area. @@ -276,7 +276,10 @@ <alpha>255</alpha> </text> </textbox> + <!-- autoverboseonerror is not implemented and does nothing --> <autoverboseonerror>yes</autoverboseonerror> + <!-- autoverboseonstart means show the text display automatically --> + <autoverboseonstart>no</autoverboseonstart> <progressbaronboot>yes</progressbaronboot> <progressbaronshutdown>yes</progressbaronshutdown> </splashy> --- a/src/splashy_main.c +++ b/src/splashy_main.c @@ -52,17 +52,17 @@ switch( sig ) { case SIGCHLD: g_printerr ("Splashy boot: splashy setup via child process failed (SIGCHLD received). Exiting..."); - break; + break; case SIGUSR2: g_printerr ("Splashy boot: splashy setup succeeded (SIGUSR2 received)."); - break; + break; default: g_printerr ("Splashy boot: Unexpected signal received."); - break; + break; } DEBUG_PRINT ("Splashy boot caught signal number %d. Exiting...", sig); - + exit(0); return; /* we never reach this */ } --- a/doc/splashy_config.pod +++ b/doc/splashy_config.pod @@ -260,9 +260,13 @@ Set the ALPHA channel of the text area font (0->255) -=item B<--autoverbose> yes|no +=item B<--autoverbose-on-error> yes|no -Set if Splashy turn into verbose mode when an error appears at boot +Set to make Splashy turn into verbose mode when an error appears at boot. Not implemented + +=item B<--autoverbose-on-start> yes|no + +Set to make Splashy turn into verbose mode automatically from the start of booting =item B<--progressbar-visibility-boot> yes|no --- a/src/splashy_config-main.c +++ b/src/splashy_config-main.c @@ -127,7 +127,8 @@ {"text-font-green", required_argument, 0, 'O'}, {"text-font-blue", required_argument, 0, 'P'}, {"text-font-alpha", required_argument, 0, 'Q'}, - {"autoverbose", required_argument, 0, 'R'}, + {"autoverbose-on-error", required_argument, 0, 'R'}, + {"autoverbose-on-start", required_argument, 0, '('}, {"fadein", required_argument, 0, 'U'}, {"fadeout", required_argument, 0, 'V'}, {"progressbar-background-red", required_argument, 0, 'W'}, @@ -383,7 +384,11 @@ g_strtod (optarg, 0); break; case 'R': - inline_theme->verbose = + inline_theme->verbose_error = + g_strdup (optarg); + break; + case '(': + inline_theme->verbose_start = g_strdup (optarg); break; case 'U': @@ -483,8 +488,10 @@ g_free (inline_theme->textbox_border_show); if (inline_theme->textfont_file) g_free (inline_theme->textfont_file); - if (inline_theme->verbose) - g_free (inline_theme->verbose); + if (inline_theme->verbose_error) + g_free (inline_theme->verbose_error); + if (inline_theme->verbose_start) + g_free (inline_theme->verbose_start); if (inline_theme->fadein) g_free (inline_theme->fadein); if (inline_theme->fadeout) --- a/src/splashy_config-functions.c +++ b/src/splashy_config-functions.c @@ -794,6 +794,7 @@ { XmlFields *NewTheme = g_new0 (XmlFields, 1); gboolean use_pixel_units = FALSE; + gboolean repeat_question = FALSE; /* provide feedback about failed input */ check_fields (NewTheme); @@ -806,9 +807,16 @@ NewTheme->name = NULL; } ask_string (_("* Name"), &NewTheme->name); + if (theme_name_exists (NewTheme->name) ) + { + repeat_question = TRUE; + g_print("%s\n", "name exists, try another"); + } + else repeat_question = FALSE; } - while (theme_name_exists (NewTheme->name) == TRUE); + while (repeat_question); + repeat_question = FALSE; // Boot image do { @@ -818,8 +826,15 @@ NewTheme->bg_boot = NULL; } ask_string (_("* Boot image"), &NewTheme->bg_boot); + if (check_image (NewTheme->bg_boot) != 0) + { + repeat_question = TRUE; + g_print("%s\n", "Problem with that image. Is it in the current directory? Try another"); + } + else repeat_question = FALSE; } - while (check_image (NewTheme->bg_boot) != 0); + while (repeat_question); + repeat_question = FALSE; /* not logically needed, just being safe */ // Shutdown image do @@ -830,8 +845,15 @@ NewTheme->bg_shutdown = NULL; } ask_string (_("* Shutdown image"), &NewTheme->bg_shutdown); + if (check_image (NewTheme->bg_shutdown) != 0) + { + repeat_question = TRUE; + g_print("%s\n", "Problem with that image. Is it in the current directory? Try another"); + } + else repeat_question = FALSE; } - while (check_image (NewTheme->bg_shutdown) != 0); + while (repeat_question); + repeat_question = FALSE; /* not logically needed, just being safe */ // Error image do @@ -842,8 +864,15 @@ NewTheme->bg_error = NULL; } ask_string (_("* Error image"), &NewTheme->bg_error); + if (check_image (NewTheme->bg_error) != 0) + { + repeat_question = TRUE; + g_print("%s\n", "Problem with that image. Is it in the current directory? Try another"); + } + else repeat_question = FALSE; } - while (check_image (NewTheme->bg_error) != 0); + while (repeat_question); + repeat_question = FALSE; /* not logically needed, just being safe */ // Resume image do @@ -854,8 +883,15 @@ NewTheme->bg_resume = NULL; } ask_string (_("* Resume image"), &NewTheme->bg_resume); + if (check_image (NewTheme->bg_resume) != 0) + { + repeat_question = TRUE; + g_print("%s\n", "Problem with that image. Is it in the current directory? Try another"); + } + else repeat_question = FALSE; } - while (check_image (NewTheme->bg_resume) != 0); + while (repeat_question); + repeat_question = FALSE; /* not logically needed, just being safe */ // Suspend image do @@ -866,8 +902,15 @@ NewTheme->bg_suspend = NULL; } ask_string (_("* Suspend image"), &NewTheme->bg_suspend); + if (check_image (NewTheme->bg_suspend) != 0) + { + repeat_question = TRUE; + g_print("%s\n", "Problem with that image. Is it in the current directory? Try another"); + } + else repeat_question = FALSE; } - while (check_image (NewTheme->bg_suspend) != 0); + while (repeat_question); + repeat_question = FALSE; /* not logically needed, just being safe */ // Ask if the height & width of the background must be set gchar *resolution = "no"; @@ -1056,16 +1099,20 @@ } // if progressbar // Auto verbose - ask_string (_("Pass in verbose mode on error? (yes|no)"), - &NewTheme->verbose); + ask_string (_("Pass in verbose mode on error (not implemented)? (yes|no)"), + &NewTheme->verbose_error); + + ask_string (_("Pass in verbose mode at start? (yes|no)"), + &NewTheme->verbose_start); // Text box or not - ask_string (_("Do you want to see a text box? (yes|no)"), + ask_string (_("Do you want to see a text box (necessary for verbose mode)? (yes|no)"), &NewTheme->textbox_show); // Text box - if ((g_strcasecmp (NewTheme->verbose, "yes") == 0) - || (g_strcasecmp (NewTheme->textbox_show, "yes") == 0)) + if ((g_strcasecmp (NewTheme->verbose_error, "yes") == 0) + || (g_strcasecmp (NewTheme->verbose_start, "yes") == 0) + || (g_strcasecmp (NewTheme->textbox_show, "yes") == 0)) { g_print (_("Text box\n")); @@ -1584,13 +1631,20 @@ CheckMe->textfont_alpha = 255; // Autoverbose on error ? - if (CheckMe->verbose == NULL - || (g_strcasecmp (CheckMe->verbose, "yes") != 0 - && g_strcasecmp (CheckMe->verbose, "no"))) + if (CheckMe->verbose_error == NULL + || (g_strcasecmp (CheckMe->verbose_error, "yes") != 0 + && g_strcasecmp (CheckMe->verbose_error, "no"))) { - CheckMe->verbose = g_strdup ("no"); + CheckMe->verbose_error = g_strdup ("no"); } + // Autoverbose on start ? + if (CheckMe->verbose_start == NULL + || (g_strcasecmp (CheckMe->verbose_start, "yes") != 0 + && g_strcasecmp (CheckMe->verbose_start, "no"))) + { + CheckMe->verbose_start = g_strdup ("no"); + } // Progressbar on boot ? if (CheckMe->pb_on_boot == NULL || (g_strcasecmp (CheckMe->pb_on_boot, "yes") != 0 --- a/src/xml_functions.c +++ b/src/xml_functions.c @@ -118,7 +118,8 @@ spl_theme->textfont_green, spl_theme->textfont_blue, spl_theme->textfont_alpha, - spl_theme->verbose, + spl_theme->verbose_error, + spl_theme->verbose_start, spl_theme->fadein, spl_theme->fadeout ); --- a/src/xml_format.h.in +++ b/src/xml_format.h.in @@ -17,6 +17,8 @@ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA */ + +/* this file is used to create xml_format.h so modify this, not xml_format.h */ #ifndef _XML_FORMAT_H #define _XML_FORMAT_H @@ -167,6 +169,7 @@ </text>\n\ </textbox>\n\ <autoverboseonerror>%s</autoverboseonerror>\n\ + <autoverboseonstart>%s</autoverboseonstart>\n\ <fadein>%s</fadein>\n\ <fadeout>%s</fadeout>\n\ </splashy>\n"