Plymouth theming guide (part 4)

This the final part of the theming guide. As I mentioned in the last post, you already know everything you need to write your themes. In this post I will show a couple themes I wrote to explore the system and some fancy high level aspects of the scripting language. You don’t need to know these, they are just a cute method to solve a problem that others may find useful.

Themes

To install these themes, extract them to /usr/share/plymouth/themes and run the appropriate plymouth-set-default-theme line.

Vizta

A very simple theme matching what the Vista theme does. It has just 30 lines of custom code.

http://brej.org/blog/wp-content/uploads/2009/12/vizta

source

Dandelion

This theme has the target of stressing the system. A couple months ago it was running at about 3 fps, now my machine hits 30 fps and spends some time idle.

http://brej.org/blog/wp-content/uploads/2009/12/dandelion

source

Inheritance

When I first proposed doing a scripting system Ray said “If you do this, I guess I’d recommend you keep it very simple”. I agreed, so what I aimed to do was to implement all the features with the minimum space. The solution I came up was to kill several birds with one stone. The stone being an inheritance system.

The important operation for inheritance is the single bar (“|“), inherit operator. Think of it as a very lazy OR function. As an example take the statement:

A = B | C;

This creates a new object (A) which is an inheritance of B and C. A now gains all the properties of B and, as a fall-back, C. There are three ways of using inheritance objects.

Direct

Consider the following statement:

A = "Seven" | 7;
B = String(A).CharAt(2);
C = 80 + A;

So A is an inheritance of the string “Seven” and the number 7. This means when in situations where a string is preferred, it will act as a string, and when the a number is preferred, it will act as a number. The value in B will be the third character in the string (“v”), and the value in C will be the number 87.

This kind of inheritance is used to allow native C objects (images, sprites etc.) to be able to be used as hashes to find appropriate functions to call. An object is created which inherits from the native object and the object template hash (which holds all the functions). The constructor function is also connected to the template using an inheritance. Thus you can treat it as a function, or as a hash of functions and it will adopt the appropriate behaviour.

text_image = Image.Text("string"); # Treat Image as a hash
png_image = Image("filename.png"); # Treat Image as a function

Hashed

Hashes are the main containers in the system. When an object inherits from two hashes, accessing the inner elements will trigger a crawl through all hashes for that element.

A.a = "a";
A.b = "b";   # A: a="a", b="b"
B.b = "B";
B.c = "C";   # B: b="B", c="c"
C = A | B;   # C: a="a", b="b", c="c"

When accessing the elements within C, the system looks within A, then B (also within any object they inherit from). Thus, elements within B can be overridden by A. This is very much like the __proto__ in Mozilla JavaScript.

Functional

Just like hashes, when functions are inherited, the system goes through them in the inheritance sequence, executing each one and moving onto the next if it has failed.

Fib = fun (v) {if (v <= 2) return 1; else fail;}
    | fun (v) {if (FibCache[v]) return FibCache[v]; else fail;}
    | fun (v) {return FibCache[v] = Fib(v-1) + Fib(v-2);};

If you have ever programmed the ML languages, you will already be somewhat familiar with this. In those, you can put constants in the function variable decelerations and functions which do not match these to the passed parameters, fail. Here, at any point in the function, you can choose to fail. The system then tries to execute the next function in the inheritance.

  1. Thanks for writing such a great set of artist focused tutorials. Hopefully we’ll see some bootsplashes on Linux soon to make people drool. :)

    One thing I didn’t see mentioned but that I was curious about… Can Plymouth play sounds? Ideally I’d love to load up an ogg and play it as my machine boots.

    • Wes
    • March 11th, 2010

    Great article!

    I followed all the steps and built my own theme. It is displayed whilst shutting down, but not whilst starting up?!

    Any ideas?

    • You need to update your initrd. In Fedora that is done by adding “–rebuild-initrd” to the plymouth-set-default-theme command.
      If you isnatlled from git, you will have to manually run:
      dracut -f /boot/initramfs-$(uname -r).img $(uname -r)

  2. Great work !!
    I’m trying the Vizta theme with ubuntu 10.04.
    It shows up but it’s waaaay too slow, the GDM show before the end of the animation :/

    Is it possible to decrease the time of the animation in the script file ?

    Thank you !

    Best regards,

    François

    • In the “refresh” function, look for what is ahppening to “inc”. That is a value between 0 and 1 showing you where in the boot it is. 0-0.8 it moves blobs. 0.8-0.9 it fades them out. 0.9-1 solid logo. Try changing those values.

  3. Thank you !

    I’ve also managed to find some information on the web.

    At the middle of the bottom, I added this :

    period = (perdiod * 100.0) / 20.0;

    And it slowed down the animation :)

    I also made a custom variation of your theme, here is a quick video : http://www.youtube.com/watch?v=8EYtxUAWDjw

    Thanks again for those great pieces of work !

      • marcioabr
      • July 15th, 2010

      Hi, frankynov,

      I have the same problem with vizta script, where exacly add (period = (perdiod * 100.0) / 20.0;) ? Could you give me a link to your modified script?
      Thanks!

      Hello Charlie Brej! Great work man!
      Thanks!

      Marcioabr

    • Bigby
    • July 22nd, 2010

    Hey, Francois:

    Trying to get this working in Ubuntu myself; ran

    – sudo update-alternatives –install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/vizta/vizta.plymouth 100

    so it appears in the list of available themes. However, it leaves the screen blank, even after I rebuild initramfs. Any tips from either of you guys?

    And great work, Charlie! It’s astounding how little info there is on Plymouth in the Ubuntu community; very disappointing.

    P.S: Francois, the link to your modified script is broken.
    Thanks!

    • Bigby
    • July 24th, 2010

    Thanks a lot! Hoping to delve into this plymouth business once I get the free time. Again, much appreciated.

    • verona007
    • August 26th, 2010

    Hy! I am reworked your dandelion theme. Fixed the progress bar, and updated, plus I added a pretty good wallpaper to this. Downloadable:

    http://www.mediafire.com/file/1atl68l1ztjt7lc/dandelion.tar.gz

    I am amused from this work, you are awesome!!! Thanks!

    • Testing
    • August 1st, 2011

    Does not work with VirtualMachine. It shows a fallback theme. How do you overwrite that. Which documentation i can see for this?

    Thank you

      • Coldfire
      • August 16th, 2011

      You need to activate uvesafb instead of vga=something in your kernel command line :
      grub.cfg :
      linux /boot/vmlinuz root=/dev/sda1 ro quiet splash video=uvesafb:mode_option=1024×768,mtrr=2,scroll=ywrap

      /etc/initramfs-tools/modules (Debian & based):
      uvesafb mode_option=1024×768 mtrr=2 scroll=ywrap

      You need to install v86d too. worked for me, at least on Debian.

    • Alex
    • May 16th, 2012

    Is there a list somewhere of any built-in constant/variables in the scripting language. I’m trying specifically to detect whether the system is shutting down or starting up.

  1. December 16th, 2009
  2. March 4th, 2015
  3. February 8th, 2024
    Trackback from : รถพยาบาล
  4. February 27th, 2024
    Trackback from : connetix
  5. March 2nd, 2024
    Trackback from : Thai food nyc
  6. March 3rd, 2024
    Trackback from : เกม 3D
  7. March 11th, 2024
    Trackback from : magic mushroom gummies
  8. March 12th, 2024
    Trackback from : fun guy mushroom gummies
  9. March 13th, 2024