Skip to content

August 5, 2010

11

Plymouth: Create your own splash screen with scrolling boot messages

by Joe Kuan

I have been trying to create a simple splash screen and configure it with scrolling boot messages. However, there are very little online documentation and reference, brief introductions can be found at Plymouth themes: Fix, install, create in Ubuntu 10.04 (Lucid Lynx) and Software/Plymouth/Scripts. In here, I am documenting how to create the splash screen with scrolling messages.

A simple splash screen

For Ubuntu Lucid (10.04), you need to install plymouth-label and plymouth-x11, also plymouth-theme-script gives an sample of the script.

Next stage is to prepare a theme. Here is the one I start off from the example in Plymouth themes: Fix, install, create in Ubuntu 10.04 (Lucid Lynx).

wallpaper_image = Image("itrinegy_live_splash.png");
screen_width = Window.GetWidth();
screen_height = Window.GetHeight();
resized_wallpaper_image = wallpaper_image.Scale(screen_width,screen_height);
wallpaper_sprite = Sprite(resized_wallpaper_image);
wallpaper_sprite.SetZ(-100);

Then make sure plymouth default theme is pointing to the one that you are going to experiment with.

update-alternatives --config default.plymouth

The best way to experiment a splash screen is under X-Windows environment. On a terminal, starts the plymouth splash screen daemon by running plymouthd. Then you use the client tool plymouth to communicate with plymouthd.

Here are couple of examples. To detect whether plymouthd is currently running.

root@LiveCD:~# plymouth --ping
root@LiveCD:~# echo $?
0

If plymouthd is not currently running, the exit code is 1.

To display a splash screen.

plymouth show-splash

Here is a screenshot.

There are two splash screen windows appeared instead of one. It may be a bug. Also the splash image is not fitted to the whole window, it may be due to my actual screen size is 1280×1024 whereas my splash image is 1024×768. Again the above script code specifies to rescale the image to fit entire screen. This may be another bug but I am not too concerned because the above script code does work during the actual boot process. Alternatively, runs plymouthd on a virtual console to see the real effect. As the time I was using plymouth, it was version 0.8.2-2.

Splash Screen displays a single message

However, this is a bit too simple for a splash screen. I would like to have some scrolling boot messages showing instead of a progress bar. First, I need to add some callback functions and bind with specific events, otherwise the splash screen won’t do anything with plymouth command.

So by slightly modifying above code, here is the version that will display a message just below the logo.

wallpaper_image = Image("itrinegy_live_splash.png");
screen_width = Window.GetWidth();
screen_height = Window.GetHeight();
resized_wallpaper_image = wallpaper_image.Scale(screen_width,screen_height);
wallpaper_sprite = Sprite(resized_wallpaper_image);
wallpaper_sprite.SetZ(-100);

message_sprite = Sprite();
message_sprite.SetPosition(screen_width * 0.2, screen_height * 0.6, 10000);

fun message_callback (text) {
  my_image = Image.Text(text, 0, 0, 0);
  message_sprite.SetImage(my_image);
}

Plymouth.SetUpdateStatusFunction(message_callback);

First we need to create a global sprite at a certain position proportional to the screen size. Secondly, creates a callback function to convert the input text into an image and place the text image into the sprite. As far as I know, the 0 arguments in Image.Text call changes the text color: (0, 0, 0) is black, (1, 1, 1) is white, other values give other different colors. Finally, binds the callback function with the update event.

To see the new effect, I need to restart the plymouthd daemon and use the update command

plymouth --quit ; plymouthd ; plymouth show-splash update --status="Hello"

Unfortunately, plymouthd doesn’t give any syntax error messages and I cannot find any plymouth interpreter tool to lint the script. All I can do is to start plymouthd and run show-splash after few changes. If there is syntax error, it will just show a blank screen.

The following screenshot shows the splash screen with a message.

Splash Screen scrolls with messages

The following simple code gives a nice scrolling effects.

NUM_SCROLL_LINES=5;
LINE_WIDTH=55;

wallpaper_image = Image("itrinegy_live_splash.png");
screen_width = Window.GetWidth();
screen_height = Window.GetHeight();
resized_wallpaper_image = wallpaper_image.Scale(screen_width,screen_height);
wallpaper_sprite = Sprite(resized_wallpaper_image);
wallpaper_sprite.SetZ(-100);

// Initialising text images and their positions
// 20 is the height (including line spacing) of each line
for (i=0; i < NUM_SCROLL_LINES; i++) {
  lines[i]= Image.Text("", 0, 0, 0);
  message_sprite[i] = Sprite();
  message_sprite[i].SetPosition(screen_width * 0.2, (screen_height * 0.6) + (i * 20), 10000);
}

// From ubuntu-logo
fun StringLength(string) {

  index = 0;
  str = String(string);
  while(str.CharAt(index)) index++;
  return index;
}

fun scroll_message_callback(text) {

   // Truncate the message if too long
   if (StringLength(text) > LINE_WIDTH) {
     text = text.SubString(0, LINE_WIDTH - 3);
     text += "...";
   }

   // Shift message one up
   for (i = 0; i < NUM_SCROLL_LINES - 1; i++) {
     lines[i] = lines[i+1];
   }

   // Create the image for the latest message
   lines[i] = Image.Text(text, 0, 0, 0);

   // Re-positioning the text images
   for (i = 0; i < NUM_SCROLL_LINES; i++) {
     message_sprite[i].SetImage(lines[i]);
   }
}

Plymouth.SetUpdateStatusFunction(scroll_message_callback);

Couple global variables controls the size of the messages being displayed. NUM_SCROLL_LINES defines maximum number of lines being displayed and LINE_WIDTH defines maximum number of characters being displayed on each line.

Here is the screenshot of the splash screen scrolling with test messages.

Bind plymouth with boot log messages

The final bit is to get the boot process to output messages onto the plymouth splash screen. Edit the file /usr/share/initramfs-tools/scripts/functions and add the highlighted lines to the _log_msg call

_log_msg()
{
    if [ -x /bin/plymouth ]; then
      /bin/plymouth update --status="$@"
    fi
    if [ "$quiet" = "y" ]; then return; fi
    echo "$@"
}

Then runs the following command to update the boot process. You should see the boot messages scrolling on the splash screen at the next boot.

update-initramfs -u
Advertisements
11 Comments Post a comment
  1. Aug 9 2010

    Sweet. Thanks.

    Reply
  2. Pali
    Aug 15 2010

    https://launchpad.net/plymouth-usplash

    Alternative to boot log messages. It doesnt modify plymouth theme, it use directly param –message. Support boot and shutdown messages which is in /lib/lsb/init-functions. All is only in one deb package.

    Reply
  3. Sep 3 2010

    This is a Geeky article :) Awesome trick :)

    Reply
  4. Nov 23 2011

    hi, i have a little trouble
    i can’t start plymouthd (always got exit code 1)
    but if i type sudo plymouthd, nothing happens…. (even no error)
    would you help me please?

    Reply
  5. May 16 2012

    I dont know if its too late but I still hope I would get some good answer to my question.
    plymouth is working nicely. as far as test messages are concerned they are displayed nicely one by one. But when I go for scrolling text I cant get it. I do it in this way
    plymouthd ; plymouth show-splash update –status=”Hello World”. but i cant see any text in my plymouth screen.

    I have used some other plymouth theme named INT2MIL-Ubuntu-10.04-Eng. I doubt if it is because of the theme BUT again text messages (one by one) are displayed correctly.

    Can you please guide…….Is there anyone else who have come across same problem.

    Reply
  6. Kelteseth
    May 19 2012

    Thanks it helped me a lot ;)

    Reply
  7. dave
    Apr 28 2014

    hi, can this be done with systemd arch linux because i can’t get the booting text to show i modified /usr/lib/initcpio/init_functions which i think it’s the right file for it to work, can somebody point me in the right direction, thanks.

    Reply

Trackbacks & Pingbacks

  1. Plymouth Altmar | Altmar
  2. Plymouth Boot Splash Command Display | Don Milligan
  3. How To Get Plymouth To Display Boot Messages When Booting? - TecHub
  4. How do I change Ubuntu linux to show my company name at boot up? - Quora

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

%d bloggers like this: