如何自定义 Ubuntu 启动徽标?

如何自定义 Ubuntu 启动徽标?

我正在制作一个自定义发行版,并且对启动时显示的带有 5 个点的 Ubuntu 徽标有疑问。

Ubuntu-Logo-Script文件夹中有/lib/plymouth/themes/ubuntutextUbuntu 字样,下方有 5 个进度“点”。是否可以删除进度条点,而将其替换为褪色的 Ubuntu 徽标,并逐渐变色至全色?

在此处输入图片描述

答案1

安装主题

我已经按照您的要求创建了带有褪色的 Ubuntu 徽标的主题(此外,我还添加了 Ubuntu 徽标的动画。希望您会喜欢它 :-P)

截屏

旋转的 Ubuntu 徽标和 Ubuntu 文本徽标具有移动淡入淡出效果。

想亲眼见证吗?

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 脚本语言与 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 )

这对许多读者来说可能很新奇:哈希类似于数组。可以通过使用dot[ ]括号访问其内容来创建哈希,例如

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

雪碧

用于在屏幕上Sprite放置一个Image

创建一个Sprite

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 的评论Is it possible to replace the purple colour with an image as background in the default Plymouth theme names "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一些值。

更多链接

答案2

使用 Plymouth Manager 来更改此设置。你可以从从这里开始或者运行以下命令。

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 配置文件),并在准备好时应用它,则可以使用以下“神奇”命令:

sudo update-alternatives --config default.plymouth && sudo update-initramfs -u

答案3

我已经使用 GRUB Customizer 软件更改了 GRUB 屏幕。但是如果你想更改 Plymouth 屏幕,那就不一样了。

该软件的所有内容都在/lib/plymouth/themes目录中所有动画这个在/lib/plymouth/themes/ubuntu-logo/ubuntu-logo.script文件中。

如果您想根据自己的喜好修改 Plymouth,您所需要的只是文件夹ubuntu-logo

你可以自己做,不需要任何外部软件的帮助,但是你必须懂编程

您也可以在 Ubuntu 存储库中找到执行此操作的工具,但您需要学习创建 Plymouth 主题。

祝你好运!

相关内容