如何编写自己的Linux自定义启动画面?

时间:2022-09-10 07:31:14

This is NOT a question on plain old boring customization; I actually want to create an program, you know, with source code, etc...

这不是关于普通的无聊定制的问题;我实际上想用源代码等创建一个程序...

I'm thinking about programming my own media centre interface, and I figured it'd look better if I coded my own splash screen for when the OS is loading.

我正在考虑编写自己的媒体中心界面,我认为如果我在加载操作系统时编写自己的启动画面,它看起来会更好。

Note: The media centre interface will be run in X, but this question is regarding what will happen before the X server loads.

注意:媒体中心界面将在X中运行,但这个问题是关于在X服务器加载之前会发生什么。

Simply, I'd like to make a splash screen application to hide the linux kernel boot messages. Is there a way I can program some animation in to this like some sort of animated progress bar for example? I assume that I won't be able to code any 2D/3D graphics (as that'd require X to be running, right?), so how would I go about generating that?

简单地说,我想制作一个启动画面应用程序来隐藏linux内核启动消息。有没有一种方法可以像某种动画进度条那样编写一些动画?我假设我将无法对任何2D / 3D图形进行编码(因为这需要X运行,对吧?),那么我将如何生成呢?

I'd prefer to do this in C++, but C is also an option.

我更喜欢在C ++中这样做,但C也是一种选择。

Note: I'm not looking to use any existing "themes" or anything like that, just interested in the programming side of things.

注意:我不打算使用任何现有的“主题”或类似的东西,只是对编程方面感兴趣。

Update:

Some suggestions have been to use standard images (.bmp, .jpeg, etc), I am not interested in loading images in to an existing application. But obviously I may want to load images in to the boot screen application that I will make.

一些建议是使用标准图像(.bmp,.jpeg等),我对将图像加载到现有应用程序不感兴趣。但显然我可能想要将图像加载到我将要制作的引导屏幕应用程序中。

I'm not tied to a Linux distro, so this can be for anything, although Debian or a Debian-based distro would be nice.

我没有绑定Linux发行版,所以这可以是任何东西,虽然Debian或基于Debian的发行版会很好。

I like the suggestion about loading the X server early and running a loading screen from there, however is there not a more direct approach? Surely you can make a program which hides the boot messages and shows a custom program? Obviously this would be very low level programming, but that's what I'm looking for...

我喜欢早期加载X服务器并从那里运行加载屏幕的建议,但是没有更直接的方法吗?当然你可以创建一个程序来隐藏启动消息并显示自定义程序?显然这将是非常低级别的编程,但这就是我正在寻找的......

Also, I'm not interested in altering the boot loader (LILO, GRUB, etc).

另外,我对改变引导加载程序(LILO,GRUB等)并不感兴趣。

Update 2:

So far good suggestions have been looking at the source code for applications like splashy and fbsplash. Can anyone better this suggestion?

到目前为止,好的建议一直在寻找像splashy和fbsplash这样的应用程序的源代码。谁能更好地提出这个建议?

6 个解决方案

#1


3  

For the graphical output you can use the Linux framebuffer, for application development you can use gtk which support rendering directly to the framebuffer GtkFB.

对于图形输出,您可以使用Linux framebuffer,对于应用程序开发,您可以使用gtk,它支持直接渲染到帧缓冲区GtkFB。

For the video and such you can use mplayer which also support rendering to the framebuffer.

对于视频等,您可以使用mplayer,它也支持渲染到帧缓冲区。

For the initialization you have to look around the system used, debian uses a sysv init style initialization http://www.debian-administration.org/articles/212, ubuntu uses upstart.

对于初始化你必须查看所使用的系统,debian使用sysv init样式初始化http://www.debian-administration.org/articles/212,ubuntu使用upstart。

#2


3  

I'd look into splashy source code. But you will need to code in C.

我会研究一下引人注目的源代码。但是你需要在C中编码。

If you have the skills, you can implement a software based 3D engine (like in the good old days). A simple rotating cube shouldn't be very hard to code and there are tons of tutorials. The downside is that you will increase the boot time, something not very pleasant in a media center.

如果您具备这些技能,则可以实施基于软件的3D引擎(就像过去一样)。一个简单的旋转立方体应该不是很难编码,并且有大量的教程。缺点是你会增加启动时间,这在媒体中心不太令人愉快。

#3


2  

Here's the thing: there is a library/kernel patch, fbsplash, that has already been written to do exactly what it sounds like you want to do. It will display an image in place of the normal boot messages, and it can also incorporate a progress bar. When you're trying to do something for which a well-established open-source implementation already exists, there's really no better way to learn how to do it yourself than to look at the source code.

事情就是这样:有一个库/内核补丁fbsplash,它已经被编写完成了你想要做的事情。它将显示一个图像来代替正常的启动消息,它还可以包含一个进度条。当你试图做一些已经存在完善的开源实现的东西时,实际上没有更好的方法来学习如何自己做,而不是查看源代码。

Even if you're looking for something more complicated (say if you want to create some fancier animation than a progress bar), you might be able to start with fbsplash and modify it to suit your needs.

即使你正在寻找更复杂的东西(比如你想创建一些比进度条更高级的动画),你也许可以从fbsplash开始并根据你的需要进行修改。

#4


1  

There are several ways you could do this. You could have the X server load very early, and just write a program to display the splash screen. You could also use the framebuffer device. If you are using Intel hardware, or are willing to use the OSS AMD drivers, or Nouveau for Nvidia, you could use kernel mode setting. For this, I would look at Fedora's Plymouth. You could just write a Plymouth plugin to display your splash screen.

有几种方法可以做到这一点。您可以很早地加载X服务器,只需编写一个程序来显示启动画面。您也可以使用framebuffer设备。如果您使用的是英特尔硬件,或者愿意使用OSS AMD驱动程序或Nouveau用于Nvidia,则可以使用内核模式设置。为此,我会看看Fedora的普利茅斯。你可以写一个Plymouth插件来显示你的启动画面。

#5


0  

The splash screen is simply an image (.bmp, .jpg, etc.) and can be loaded by the boot loader. Since you haven't specified the distribution you're using, look into LILO, grub, or whichever one is appropriate. Check the /boot directory for clues that will direct your search.

启动画面只是一个图像(.bmp,.jpg等),可以由启动加载程序加载。由于您尚未指定正在使用的发行版,请查看LILO,grub或其中任何一个适当的发行版。检查/ boot目录中是否有指导您搜索的线索。

#6


0  

If all you want to do is have a nice clean boot sequence with your own splash and absolutely no boot messaging you can do the following:

如果您想要做的就是拥有一个漂亮的干净启动顺序,并拥有自己的启动,并且绝对没有启动消息,您可以执行以下操作:

First, silence grub, boot messaging, and console cursor:

首先,沉默grub,启动消息和控制台游标:

GRUB_CMDLINE_LINUX_DEFAULT = quiet fastboot splash vt.cur_default=1 loglevel=0
GRUB_TIMEOUT               = 0

This will very quickly and silently (fade to black) bring you to your login screen, where you can place a splash. Your distro may show it's own splash briefly, which you can change if you like.

这将非常快速和默默地(淡入黑色)带您进入您的登录屏幕,在那里您可以放置​​一下。你的发行版可以简单地展示它自己的飞溅,如果你愿意,你可以改变它。

This yeilds a professional clean boot sequence, without all the usual linux warts and wrinkles. (Like OSX and Windows).

这是一个专业的干净启动顺序,没有所有常见的Linux疣和皱纹。 (像OSX和Windows)。

I personally use Ubunutu with LXDE, and have a clean splashy boot in under 3 seconds, even on older hardware.

我个人使用Ubunutu和LXDE,并且在3秒内即使在较旧的硬件上也能进行​​干净的启动。

#1


3  

For the graphical output you can use the Linux framebuffer, for application development you can use gtk which support rendering directly to the framebuffer GtkFB.

对于图形输出,您可以使用Linux framebuffer,对于应用程序开发,您可以使用gtk,它支持直接渲染到帧缓冲区GtkFB。

For the video and such you can use mplayer which also support rendering to the framebuffer.

对于视频等,您可以使用mplayer,它也支持渲染到帧缓冲区。

For the initialization you have to look around the system used, debian uses a sysv init style initialization http://www.debian-administration.org/articles/212, ubuntu uses upstart.

对于初始化你必须查看所使用的系统,debian使用sysv init样式初始化http://www.debian-administration.org/articles/212,ubuntu使用upstart。

#2


3  

I'd look into splashy source code. But you will need to code in C.

我会研究一下引人注目的源代码。但是你需要在C中编码。

If you have the skills, you can implement a software based 3D engine (like in the good old days). A simple rotating cube shouldn't be very hard to code and there are tons of tutorials. The downside is that you will increase the boot time, something not very pleasant in a media center.

如果您具备这些技能,则可以实施基于软件的3D引擎(就像过去一样)。一个简单的旋转立方体应该不是很难编码,并且有大量的教程。缺点是你会增加启动时间,这在媒体中心不太令人愉快。

#3


2  

Here's the thing: there is a library/kernel patch, fbsplash, that has already been written to do exactly what it sounds like you want to do. It will display an image in place of the normal boot messages, and it can also incorporate a progress bar. When you're trying to do something for which a well-established open-source implementation already exists, there's really no better way to learn how to do it yourself than to look at the source code.

事情就是这样:有一个库/内核补丁fbsplash,它已经被编写完成了你想要做的事情。它将显示一个图像来代替正常的启动消息,它还可以包含一个进度条。当你试图做一些已经存在完善的开源实现的东西时,实际上没有更好的方法来学习如何自己做,而不是查看源代码。

Even if you're looking for something more complicated (say if you want to create some fancier animation than a progress bar), you might be able to start with fbsplash and modify it to suit your needs.

即使你正在寻找更复杂的东西(比如你想创建一些比进度条更高级的动画),你也许可以从fbsplash开始并根据你的需要进行修改。

#4


1  

There are several ways you could do this. You could have the X server load very early, and just write a program to display the splash screen. You could also use the framebuffer device. If you are using Intel hardware, or are willing to use the OSS AMD drivers, or Nouveau for Nvidia, you could use kernel mode setting. For this, I would look at Fedora's Plymouth. You could just write a Plymouth plugin to display your splash screen.

有几种方法可以做到这一点。您可以很早地加载X服务器,只需编写一个程序来显示启动画面。您也可以使用framebuffer设备。如果您使用的是英特尔硬件,或者愿意使用OSS AMD驱动程序或Nouveau用于Nvidia,则可以使用内核模式设置。为此,我会看看Fedora的普利茅斯。你可以写一个Plymouth插件来显示你的启动画面。

#5


0  

The splash screen is simply an image (.bmp, .jpg, etc.) and can be loaded by the boot loader. Since you haven't specified the distribution you're using, look into LILO, grub, or whichever one is appropriate. Check the /boot directory for clues that will direct your search.

启动画面只是一个图像(.bmp,.jpg等),可以由启动加载程序加载。由于您尚未指定正在使用的发行版,请查看LILO,grub或其中任何一个适当的发行版。检查/ boot目录中是否有指导您搜索的线索。

#6


0  

If all you want to do is have a nice clean boot sequence with your own splash and absolutely no boot messaging you can do the following:

如果您想要做的就是拥有一个漂亮的干净启动顺序,并拥有自己的启动,并且绝对没有启动消息,您可以执行以下操作:

First, silence grub, boot messaging, and console cursor:

首先,沉默grub,启动消息和控制台游标:

GRUB_CMDLINE_LINUX_DEFAULT = quiet fastboot splash vt.cur_default=1 loglevel=0
GRUB_TIMEOUT               = 0

This will very quickly and silently (fade to black) bring you to your login screen, where you can place a splash. Your distro may show it's own splash briefly, which you can change if you like.

这将非常快速和默默地(淡入黑色)带您进入您的登录屏幕,在那里您可以放置​​一下。你的发行版可以简单地展示它自己的飞溅,如果你愿意,你可以改变它。

This yeilds a professional clean boot sequence, without all the usual linux warts and wrinkles. (Like OSX and Windows).

这是一个专业的干净启动顺序,没有所有常见的Linux疣和皱纹。 (像OSX和Windows)。

I personally use Ubunutu with LXDE, and have a clean splashy boot in under 3 seconds, even on older hardware.

我个人使用Ubunutu和LXDE,并且在3秒内即使在较旧的硬件上也能进行​​干净的启动。