Je voudrais savoir comment créer un splash pour Ubuntu Maverick avec des messages de démarrage affichés lorsque je démarre, ainsi qu'une barre de progression et un logo tournant.
Ou, si possible, comment éditer un splash qui a déjà un logo tournant et une barre de progression, et y ajouter des messages de démarrage.
Voici le thème que je voudrais éditer:
et je voudrais quelque chose comme ça:
ou ceci, qui est le splash exact que je veux créer:
J'ai pu trouver ce site Web, il contient beaucoup d'informations utiles, mais j'ai du mal à en comprendre certaines. je n'ai jamais fait de script avant!
Créez votre propre écran de démarrage avec des messages de démarrage défilants
et ceci est un autre site Web qui peut aider avec les scripts
voici le script de la barre de progression dans le splash:
#----------------------------------------- Progress Bar --------------------------------
progress_box.image = Image("progress_box.png");
progress_box.sprite = Sprite(progress_box.image);
progress_box.x = Window.GetX() + Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2;
progress_box.y = Window.GetY() + Window.GetHeight() * 0.65 - progress_box.image.GetHeight() / 2;
progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0);
progress_bar.original_image = Image("progress_bar.png");
progress_bar.sprite = Sprite();
progress_bar.x = Window.GetX() + Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2;
progress_bar.y = Window.GetY() + Window.GetHeight() * 0.65 - progress_box.image.GetHeight() / 2 + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2;
progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1);
fun progress_callback (duration, progress)
{
if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress))
{
# add the * 3 to multiply the speed of the progress bar by 3
progress_bar.image = progress_bar.original_image.Scale(progress_bar.original_image.GetWidth(progress_bar.original_image) * progress * 3, progress_bar.original_image.GetHeight());
progress_bar.sprite.SetImage (progress_bar.image);
}
}
Plymouth.SetBootProgressFunction(progress_callback);
OK, j'ai donc fait beaucoup plus de recherches et j'ai pu en apprendre un peu plus sur Plymouth.
ce sont les sites que j'ai trouvé utiles. Guide thématique de Plymouth Il y a quatre parties à cet article que vous devez lire à travers pour comprendre l'essentiel de ce que nous faisons. (Je comparais leur script avec le script de mon splash pour comprendre ce qui est quoi, je recommande de le faire si quelqu'un veut suivre mes traces.) Script Plymouth Ok ce lien a 2 pages a dû les parcourir pour comprendre quoi faire . Il s'avère qu'ils recherchaient la même chose que moi, c'est-à-dire diriger les messages de démarrage vers le splash de Plymouth où j'ai déjà un logo tournant, un arrière-plan, une barre de progression.
J'ai donc dû éditer mon /lib/lsb/init-functions
fichier et le faire pour qu'il envoie les messages d'erreur / succès de démarrage, etc. à Plymouth en ajoutant ce paragraphe
# SEND MESSAGES TO PLYMOUTH
if [ -x /bin/plymouth ] && pidof plymouthd >/dev/null
then
plymouth_send() {
[ "$1" = '-n' ] && { # add a flag '>' for lines that will be extended
shift
/bin/plymouth message --text=">$*" || true
return
}
[ "$1" = '-w' ] && { # add "warning" formatting
shift
/bin/plymouth update --status="warning" || true
/bin/plymouth message --text="$*" || true
/bin/plymouth update --status="normal" || true
return
}
[ "$1" = '-f' ] && { # add "failed" formatting
shift
/bin/plymouth update --status="failed" || true
/bin/plymouth message --text="$*" || true
/bin/plymouth update --status="normal" || true
return
}
/bin/plymouth message --text="$*" || true
}
else
plymouth_send() { :; }
fi
# int log_begin_message (char *message)
log_begin_msg () {
if [ -z "${1:-}" ]; then
return 1
fi
echo -n "$@"
}
En plus d'ajouter
# Only do the fancy stuff if we have an appropriate terminal
# and if /usr is already mounted
if log_use_fancy_output; then
RED=`$TPUT setaf 1`
YELLOW=`$TPUT setaf 3`
NORMAL=`$TPUT op`
else
RED=''
YELLOW=''
NORMAL=''
fi
if [ $1 -eq 0 ]; then
echo "."
plymouth_send "."
elif [ $1 -eq 255 ]; then
/bin/echo -e " ${YELLOW}(warning).${NORMAL}"
plymouth_send -w " (warning)."
else
/bin/echo -e " ${RED}failed!${NORMAL}"
plymouth_send -f " failed!"
fi
log_end_msg_post "$@"
return $retval
}
log_action_msg () {
echo "$@."
plymouth_send "$@."
}
log_action_begin_msg () {
echo -n "$@..."
plymouth_send -n "$@..."
}
log_action_cont_msg () {
echo -n "$@..."
plymouth_send -n "$@..."
}
log_action_end_msg () {
log_action_end_msg_pre "$@"
if [ -z "${2:-}" ]; then
end="."
else
end=" ($2)."
fi
if [ $1 -eq 0 ]; then
echo "done${end}"
plymouth_send "done${end}"
else
if log_use_fancy_output; then
RED=`$TPUT setaf 1`
NORMAL=`$TPUT op`
/bin/echo -e "${RED}failed${end}${NORMAL}"
else
echo "failed${end}"
plymouth_send -f "failed${end}"
fi
fi
log_action_end_msg_post "$@"
}
Jusqu'à présent, je n'ai pas pu transmettre les messages à Plymouth, mais j'ai mieux compris comment fonctionne le script Plymouth!
Je ne sais pas quoi faire d'autre pour que ça marche! en espérant que quelqu'un ici puisse m'aider
Ohh et voici ma version du script pour le Splash sur lequel je travaille.
# INT2MIL-Ubuntu-10.10-Eng splashy like theme
Window.GetMaxWidth = fun (){
i = 0;
width = 0;
while (Window.GetWidth(i)){
width = Math.Max(width, Window.GetWidth(i));
i++;
}
return width;
};
Window.GetMaxHeight = fun (){
i = 0;
height = 0;
while (Window.GetHeight(i)){
height = Math.Max(height, Window.GetHeight(i));
i++;
}
return height;
};
anim.imagecount = 100;
anim.target_width = 0.2* 0.46 * Window.GetWidth();
anim.target_height = 0.2* 0.46 * Window.GetWidth();
fun RotatedImage (index){
index = Math.Int(index);
if (!RotatedImageCache[index])
RotatedImageCache[index] = anim.original_image.Rotate((Math.Pi*2*index)/anim.imagecount).Scale(anim.target_width, anim.target_height);
return RotatedImageCache[index];
}
if (Plymouth.GetMode() == "suspend" || Plymouth.GetMode() == "resume") {
background.original_image = ImageNew("suspend.png");
Window.SetBackgroundTopColor(1, 0, 0);
Window.SetBackgroundBottomColor(0, 1, 0);
}
else {
logo.original_image = ImageNew("logo.png");
background.original_image = ImageNew("background.png");
Window.SetBackgroundTopColor(0.234, 0.43, 0.705);
Window.SetBackgroundBottomColor(0.16, 0.25, 0.44);
anim.image= ImageNew("animation.png");
anim.original_image= anim.image.Scale(anim.target_width, anim.target_width);
anim.sprite = SpriteNew();
anim.sprite.SetImage(RotatedImage (0));
anim.sprite.SetX((Window.GetX() + Window.GetWidth() - RotatedImage(0).GetWidth()) / 2);
anim.sprite.SetY(Window.GetY() + Window.GetHeight() * 0.37);
anim.angle = 0;
anim.index = 0;
}
#change reduction size to make logo bigger
ratio = logo.original_image.GetWidth() / logo.original_image.GetHeight();
reduction = 0.4;
logo.image = logo.original_image.Scale(reduction * Window.GetMaxWidth() , reduction / ratio * Window.GetMaxWidth());
logo.sprite = SpriteNew();
logo.sprite.SetImage(logo.image);
logo.opacity_angle = 0;
#change logo location
logo.sprite.SetX((Window.GetX() + Window.GetMaxWidth() - logo.image.GetWidth()) / 2);
logo.sprite.SetY(Window.GetY() + Window.GetHeight() * 0.37);
#background image attributs x,z,y
background.image = background.original_image.Scale(Window.GetMaxWidth() , Window.GetMaxHeight());
background.sprite = SpriteNew();
background.sprite.SetImage(background.image);
background.sprite.SetPosition(Window.GetX(), Window.GetY(), -10);
sprite_prompt = SpriteNew();
fun refresh_callback ()
{
if (status == "normal")
{
#anim.index=speed of rotation
anim.index += 1;
anim.index %= anim.imagecount;
anim.sprite.SetImage(RotatedImage (anim.index));
#anim.sprite.SetOpacity (1);
motif.sprite.SetOpacity(motif.opacity);
}
else
{
anim.sprite.SetOpacity(0);
motif.sprite.SetOpacity(0);
}
}
if (Plymouth.GetMode() != "suspend" && Plymouth.GetMode() != "resume") {
Plymouth.SetRefreshFunction (refresh_callback);
}
#----------------------------------------- Dialog --------------------------------
status = "normal";
fun dialog_setup()
{
local.box;
local.lock;
local.entry;
local.prompt_sprite;
box.image = ImageNew("box.png");
lock.image = ImageNew("lock.png");
entry.image = ImageNew("entry.png");
box.sprite = SpriteNew();
box.sprite.SetImage(box.image);
box.x = Window.GetX() + Window.GetWidth() / 2 - box.image.GetWidth()/2;
box.y = Window.GetY() + Window.GetHeight() / 2 - box.image.GetHeight()/2;
box.z = 10000;
box.sprite.SetPosition(box.x, box.y, box.z);
lock.sprite = SpriteNew();
lock.sprite.SetImage(lock.image);
lock.x = box.x + box.image.GetWidth()/2 - (lock.image.GetWidth() + entry.image.GetWidth()) / 2;
lock.y = box.y + box.image.GetHeight()/2 - lock.image.GetHeight()/2;
lock.z = box.z + 1;
lock.sprite.SetPosition(lock.x, lock.y, lock.z);
entry.sprite = SpriteNew();
entry.sprite.SetImage(entry.image);
entry.x = lock.x + lock.image.GetWidth();
entry.y = box.y + box.image.GetHeight()/2 - entry.image.GetHeight()/2;
entry.z = box.z + 1;
entry.sprite.SetPosition(entry.x, entry.y, entry.z);
prompt_sprite = SpriteNew();
prompt_sprite.SetPosition(box.x, box.y - 20, box.z);
global.dialog.box = box;
global.dialog.lock = lock;
global.dialog.entry = entry;
global.dialog.bullet_image = ImageNew("bullet.png");
global.dialog.prompt_sprite = prompt_sprite;
dialog_opacity (1);
}
fun dialog_opacity(opacity)
{
dialog.box.sprite.SetOpacity(opacity);
dialog.lock.sprite.SetOpacity(opacity);
dialog.entry.sprite.SetOpacity(opacity);
dialog.prompt_sprite.SetOpacity(opacity);
for (index = 0; dialog.bullet[index]; index++)
{
dialog.bullet[index].sprite.SetOpacity(opacity);
}
}
fun display_normal_callback ()
{
global.status = "normal";
if (global.dialog)
dialog_opacity (0);
}
fun display_password_callback (prompt, bullets)
{
global.status = "password";
if (!global.dialog)
dialog_setup();
else
dialog_opacity(1);
motif.sprite.SetOpacity(0);
anim.sprite.SetOpacity(0);
dialog.prompt_sprite.SetImage(Image.Text(prompt, 1.0, 1.0, 1.0));
for (index = 0; dialog.bullet[index] || index < bullets; index++)
{
if (!dialog.bullet[index])
{
dialog.bullet[index].sprite = SpriteNew();
dialog.bullet[index].sprite.SetImage(dialog.bullet_image);
dialog.bullet[index].x = dialog.entry.x + index * dialog.bullet_image.GetWidth();
dialog.bullet[index].y = dialog.entry.y + dialog.entry.image.GetHeight() / 2 - dialog.bullet_image.GetHeight() / 2;
dialog.bullet[index].z = dialog.entry.z + 1;
dialog.bullet[index].sprite.SetPosition(dialog.bullet[index].x, dialog.bullet[index].y, dialog.bullet[index].z);
}
if (index < bullets)
dialog.bullet[index].sprite.SetOpacity(1);
else
dialog.bullet[index].sprite.SetOpacity(0);
}
}
fun display_message_callback (prompt)
{
prompt = Image.Text(prompt,1.0, 1.0, 1.0);
sprite_prompt.SetImage(prompt);
sprite_prompt.SetPosition(Window.GetX() + (Window.GetWidth() - prompt.GetWidth()) / 2, Window.GetY() + Window.GetHeight() * 0.93, 2);
}
/* instantiate dialog at startup, to ensure all icons are loaded in memory before initrd is unmounted, in case /usr isn't mounted yet */
dialog_setup(); dialog_opacity(0);
Plymouth.SetDisplayNormalFunction(display_normal_callback);
Plymouth.SetDisplayPasswordFunction(display_password_callback);
Plymouth.SetMessageFunction(display_message_callback);
#----------------------------------------- Progress Bar --------------------------------
progress_box.image = Image("progress_box.png");
progress_box.sprite = Sprite(progress_box.image);
progress_box.x = Window.GetX() + Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2;
progress_box.y = Window.GetY() + Window.GetHeight() * 0.65 - progress_box.image.GetHeight() / 2;
progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0);
progress_bar.original_image = Image("progress_bar.png");
progress_bar.sprite = Sprite();
progress_bar.x = Window.GetX() + Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2;
progress_bar.y = Window.GetY() + Window.GetHeight() * 0.65 - progress_box.image.GetHeight() / 2 + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2;
progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1);
fun progress_callback (duration, progress)
{
if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress))
{
progress_bar.image = progress_bar.original_image.Scale(progress_bar.original_image.GetWidth(progress_bar.original_image) * progress * 3, progress_bar.original_image.GetHeight());
progress_bar.sprite.SetImage (progress_bar.image);
}
}
Plymouth.SetBootProgressFunction(progress_callback);
#----------------------------------------- Status Update --------------------------------
NUM_SCROLL_LINES = 5;
LINE_WIDTH = 55;
# width of one character
CHAR_WIDTH = 7;
# height of one character
CHAR_HEIGHT = 10;
msg_color = [0.5,0.5,0.5]; # msg_color is array
fun update_status_callback(sta) {
if (sta == "failed") msg_color = [1,0,0];
if (sta == "warning") msg_color = [0.8,0.8,0];
if (sta == "normal") msg_color = [0.5,0.5,0.5];
}
fun StringLength(string) {
index = 0;
str = String(string);
while(str.CharAt(index)) index++;
return index;
}
// 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].SetX (Window.GetX() + (screen_width / 2 ) - (LINE_WIDTH * CHAR_WIDTH / 2));
message_sprite[i].SetY (Window.GetY() + (screen_height / 2) + (logo_height /2) +(logo_height * 1.2)+ (i * CHAR_HEIGHT * 2) );
message_sprite[i].SetZ (10000);
}
pretext = String("");
fun scroll_message_callback(text) {
nobreak = 0;
if (text.CharAt(0) == ">") { # "no linebreak" flag, like "-n"
text = text.SubString(1, StringLength(text)); # remove ">" at front
nobreak = 1;
}
if (pretext == "") {
if (nobreak == 1) pretext = text;
// Truncate the message if too long
if (StringLength(text) > LINE_WIDTH) {
text = text.SubString(0, LINE_WIDTH - 3);
text += "...";
}
// Shift messages one up
for (i = 0; i < NUM_SCROLL_LINES - 1; i++) {
lines[i] = lines[i+1];
}
else { # the previous message was flagged to have no linebreak
// Truncate the message if too long
if (StringLength(text) > LINE_WIDTH - 5) { # leave min. 5 for pretext
text = text.SubString(0, LINE_WIDTH - 8);
text += "...";
}
# Truncate the previous message if too long
if (StringLength(pretext) > (LINE_WIDTH - StringLength(text))) {
pretext = pretext.SubString(0, LINE_WIDTH - StringLength(text) - 3);
pretext += "...";
}
text = pretext + text;
if (nobreak == 1) pretext = text;
else pretext = "";
}
// Create the image for the latest message
# original script had "lines[i]"
lines[i] = Image.Text( text, 0.5, 0.5, 0.5);
// Re-allocate the text images to sprites
for (i = 0; i < NUM_SCROLL_LINES; i++) {
message_sprite[i].SetImage(lines[i]);
}
}
Plymouth.SetUpdateStatusFunction(scroll_message_callback);
# messages get added to updates
Plymouth.SetMessageFunction(scroll_message_callback);
#----------------------------------------- Quit --------------------------------
fun quit_callback ()
{
anim.sprite.SetOpacity (0);
if (Plymouth.GetMode() == "shutdown") {
motif.sprite.SetOpacity(0);
}
}
Plymouth.SetQuitFunction(quit_callback);
OK, j'ai donc fourni presque toutes les informations nécessaires, si quelqu'un est familier avec cela, faites-moi savoir ce qui me manque pour faire passer les messages de démarrage à Plymouth. Merci