如何自定义Ubuntu启动标志?

我正在制作一个定制的发行版,关于启动时显示的带有5个点的Ubuntu徽标,我有一个问题。
在/lib/plymouth/themes/ubuntutext文件夹中的Ubuntu-Logo-Script中,有一个单词Ubuntu和下面的5个进度条'点'。是否可以删除进度条的点,并用一个逐渐变亮到完全的淡化的Ubuntu徽标来替代?

enter image description here

3个回答

安装主题

我按照你的要求创建了一个带有淡化的Ubuntu标志的主题(此外,我还添加了一个Ubuntu标志的动画。希望你会喜欢它 :-P)

截图

Spinning Ubuntu logo and the Ubuntu text logo with a moving fade effect.

想要亲眼看看吗?

点击http://www.youtube.com/watch?v=zPo50gM3txU查看。

你从哪里可以获得这个主题?

我已经上传到Mediafire云端,点击这里

如何安装它?

从上面的链接下载,保存在桌面上,然后逐个执行以下命令。 如果你使用的是16.04或更新版本,请将命令中的/lib/plymouth/themes替换为/usr/share/plymouth/themes

cd ~/Desktop/
tar -xf ubuntufaded.tar
sudo cp -r ubuntu-faded-screen '/lib/plymouth/themes'
sudo rm '/lib/plymouth/themes/default.plymouth'
sudo ln -s '/lib/plymouth/themes/ubuntu-faded-screen/ubuntu-faded-screen.plymouth' '/lib/plymouth/themes/default.plymouth'
sudo update-initramfs -u

如何检查它?
1. 重新启动Ubuntu,您将在启动和关闭时看到一个漂亮的动画。或者
2. 将下面的整个命令复制并粘贴到终端中,然后按回车键。(您可能需要安装一个软件包:sudo apt-get install plymouth-x11)
sudo plymouthd --debug --debug-file=/tmp/plymouth-debug-out ; sudo plymouth --show-splash ; for ((I=0;I<10;I++)); do sleep 1 ; sudo plymouth --update=event$I ; done ; sudo plymouth --quit
如何自己创建Plymouth主题
Plymouth脚本语言与C或JavaScript非常相似。如果您了解这些语言,那么自己创建Plymouth脚本将非常容易。
让我们从基础知识开始,比如运算符、循环、注释等。支持三种类型的注释。
# comment like in bash
// single line comment like in C
/* block comments */

语句以分号结束,例如:

foo = 10;

语句块可以用花括号创建,例如:
{
    foo = 10;
    z = foo + foo;
}

支持的运算符有+-*/%。 还支持简写赋值运算符+=, -=, *=,等等。 也支持一元运算符,例如。
foo *= ++z;

+ 用于连接字符串,例如:
foo = "Jun" + 7; # here foo is "Jun7"

比较运算符示例:
x = (3 >= 1); # assign 1 to x because it's true
y = ("foo" == "bar"); # assign 0 to y because it's false

条件操作和循环:
if (foo > 4)
{
    foo--;
    z = 1;
}
else
    z = 0;


while (foo--)
    z *= foo;

&&, ||, ! 也是受支持的。

if ( foo > 0 && foo <4 )

这对许多读者来说可能是新鲜事物:哈希,类似于数组。可以通过使用“点”或“[ ]”括号来访问它们的内容来创建哈希,例如。
foo.a = 5;
x = foo["a"] ; # x equals to 5

使用fun关键字来定义函数,例如。
fun animator (param1, param2, param3)
{
    if (param1 == param2)
        return param2;
    else
        return param3;
}

两个基本的Plymouth对象

图像

要创建一个新的图像,请将主题目录中的图像文件名提供给Image()。请记住,只支持.png文件。例如:

background = Image ("black.png"); 

要显示文本消息,您必须创建一个文本的Image。(这可能会让您感到惊讶。)例如:
text_message_image = Image.Text("I love Ubuntu");

可以使用GetWidth()GetHeight()来获取宽度和高度;例如:
image_area = background.GetWidth() * background.GetHeight();

一个可以旋转或改变图像大小的例子是:
down_image = logo_image.Rotate (3.1415); # Image can be Rotated. Parameter to Rotate is the angle in radians
fat_image = background.Scale ( background.GetWidth() * 4 , background.GetHeight () ) # make the image four times the width

精灵

使用 精灵 在屏幕上放置一个 图像

创建一个 精灵

first_sprite = Sprite ();
first_sprite.SetImage (background);

通过向其构造函数提供图像,
first_sprite = Sprite (background);

如何将不同的精灵设置到屏幕上的不同位置(x,y,z):
first_sprite.SetX (300); # put at x=300
first_sprite.SetY (200); # put at y=200
background.SetZ(-20);
foreground.SetZ(50);

或者你可以使用SetPosition()一次性设置所有位置:
first_sprite.Setposition(300, 200, 50) # put at x=300, y=200, z=50

改变透明度:
faded_sprite.SetOpacity (0.3);
invisible_sprite.SetOpacity (0);

一些常用的杂项方法包括:
Window.GetWidth();
Window.GetHeight();
Window.SetBackgroundTopColor (0.5, 0, 0); # RGB values between 0 to 1.
Window.SetBackgroundBottomColor (0.4, 0.3, 0.6);
Plymouth.GetMode(); #  returns a string of one of: "boot", "shutdown", "suspend", "resume" or unknown.
etc.

预定义函数

Plymouth.SetRefreshFunction (function); # Calling Plymouth.SetRefreshFunction with a function will set that function to be called up to 50 times every second
Plymouth.SetBootProgressFunction(); # function is called with two numbers, time spent booting so far and the progress (between 0 and 1)
Plymouth.SetRootMountedFunction(); # function is called when a new root is mounted
Plymouth.SetKeyboardInputFunction(); # function is called with a string containing a new character entered on the keyboard
Plymouth.SetUpdateStatusFunction(); # function is called with the new boot status string
Plymouth.SetDisplayPasswordFunction(); # function is called when the display should display a password dialogue. First param is prompt string, the second is the number of bullets.
Plymouth.SetDisplayQuestionFunction(); # function is called when the display should display a question dialogue. First param is prompt string, the second is the entry contents.
Plymouth.SetDisplayNormalFunction(); # function is called when the display should return to normal
Plymouth.SetMessageFunction(); # function is called when new message should be displayed. First arg is message to display.

数学函数

Math.Abs()
Math.Min()
Math.Pi()
Math.Cos()
Math.Random()
Math.Int()
etc.

修改现有脚本比从头开始更好。

打开我上传的主题中的.script文件,并尝试理解它的功能。你可以在这里找到一个很棒的指南。

我相信你会学会的,这并不难。如果你需要任何帮助,请告诉我。

希望这对你自己创建一个脚本有所帮助。

回答Roshan George的评论: 是否可能将默认Plymouth主题“ubuntu-logo”中的紫色背景替换为图像?

background = Image ("your-image.png"); 
sprite = Sprite (background.Scale (Window.GetWidth(), Window.GetHeight()));
sprite.SetX (0); # put at x=0
sprite.SetY (0); # put at y=0

你可能需要添加 sprite.SetZ (-10); 你应该移除
Window.SetBackgroundTopColor (p, q, r);
Window.SetBackgroundBottomColor (a, b, c);

其中 p, q, r, a, b, c 是一些值。

更多链接


1我能否得到与您创建的相同,但是使用Ubuntu徽标和文本(在现在的相同位置)交替发光和变暗(当徽标发光时,文本变暗,当文本发光时,徽标变暗),没有旋转边框,并且有一个像Ubuntu9.10播放口令中的裂缝进度条...即这个-https://wiki.ubuntu.com/Artwork/Incoming/Karmic/Boot/Demo?action=AttachFile&do=get&target=xsplash-3.png....我只想要像链接中的那样的裂缝进度条...文本和徽标位于与您相同的位置...您能帮我实现吗?同时我正在尝试从您解释的内容中学习...谢谢!非常好的答案。 - Nirmik
23有时候我希望能够多次点赞:D - Rinzwind
1@Rinzwind:我代表我们所有人给他“10个赞”了 :) - ish
谢谢,伙计,这个教程太棒了。我期待着编辑它。这样可以吗? - Roshan George
@RoshanGeorge 当然可以,你可以编辑这个。我们拥有自由的力量!:-) - Rahul Virpara
我想知道是否可以更改Live CD的Plymouth主题? - Roshan George
你需要创建自己的LiveCD - Lucio
@virpara 你已经创建了一个完整的Plymouth脚本语言指南!你可以使用这些信息创建维基百科条目 :) - Lucio
可以将默认的Plymouth主题"ubuntu-logo"中的紫色背景替换为一张图片吗? - Roshan George
@RoshanGeorge 我已经更新了答案。 - Rahul Virpara
@virpara,但是在使用ubuntu-builder制作的发行版中,这并不显示出来。应该给予什么权限? - Roshan George
@RoshanGeorge 你运行了 sudo ln -s '/lib/plymouth/themes/your-theme/your-script.plymouth' '/lib/plymouth/themes/default.plymouth'; sudo update-initramfs -u 吗?这个命令会改变你的默认 plymouth 主题并更新 initrd 文件。 - Rahul Virpara
我做了那个,但还是没有显示出来..我只看到一个黑屏。我应该对主题文件夹执行"chmod a+x"命令吗? - Roshan George
@RoshanGeorge 你能够使用 plymouth-x11 进行检查吗? - Rahul Virpara
怎么做那 - Roshan George
请按照答案中的“如何检查?”进行操作。 - Rahul Virpara
嗨,我找到了 initrd 文件,并且它包含了我制作的 plymouth 主题,但是当我启动 live cd 或者安装系统时,它没有运行。 - Roshan George
@RoshanGeorge 你把那个 initrd 文件放进了你的 squashfsiso 文件里吗? - Rahul Virpara
我正在使用ubuntu-builder,所以squashfs的解压缩和压缩都是自动完成的。那么,有没有添加它的选项? - Roshan George
你必须使用chroot来完成这个任务。你不应该将你的/boot/initrd放到提取出来的文件系统(从.squashfs中)。请等一天或两天。我会在这里发布完整的指南。 - Rahul Virpara
@viapara 真是令人难以置信的教程,非常感谢你提供如此详细的内容!我稍微修改了你的原始文件,并且有一个问题想请教。我在Ubuntu 15.10上运行时,启动后的背景是黑色的,尽管我已经将顶部和底部的背景设置为白色。唯一是白色的只有我用自己的图片替换掉的那些图像。你知道这是为什么吗? - shreddish
3请注意,在16.04版本中,主题目录的位置已更改为:/usr/share/plymouth/themes - Olivier
哇塞,这真是令人印象深刻。实至名归的加一! - Kaz Wolfe
1自从Ubuntu 16.04版本以来,plymouth主题目录已经按另一个评论所述进行了更改。如有机会,请更新您的答案以反映这一变化。谢谢! - Xiaodong Qi
感谢您发布如此有帮助的答案。曾经我试图修改一个Plymouth脚本,但是看着那么长的脚本让我发疯了。但在阅读了您的回答之后,现在我可以完全理解它的含义了。 - Puspam

使用Plymouth Manager来进行更改。您可以从这里的Launchpad获取它,或者运行下面的命令。
wget https://launchpad.net/plymouth-manager/trunk/stable/+download/plymouth-manager_1.5.0-1_all.deb
sudo dpkg -i plymouth-manager_1.5.0-1_all.deb 

之后,您需要使用以下命令启动plymouth-manager
sudo plymouth-manager

如果你想自己完成所有工作(编写自己的plymouth配置文件),并且在准备好时应用它,那么"magic"命令是:
sudo update-alternatives --config default.plymouth && sudo update-initramfs -u

我用GRUB Customizer软件更改了GRUB屏幕。但如果你想改变Plymouth屏幕,那就不一样了。
这个软件的所有内容都在/lib/plymouth/themes目录下,而其中所有的动画都在/lib/plymouth/themes/ubuntu-logo/ubuntu-logo.script文件中。
如果你想按照自己的喜好修改Plymouth,你所需要的一切都在ubuntu-logo文件夹里。
你可以自己完成这个任务,不需要任何外部软件的帮助,但是你必须懂得编程。
此外,你也可以在Ubuntu软件仓库中找到工具来完成这个任务,但你需要学习如何创建Plymouth主题。
祝你好运!