Ubuntu Maverickのスプラッシュを作成する方法を知りたいのですが、起動時にブートメッセージが表示され、進行状況バーと回転するロゴが表示されます。
または、可能であれば、回転するロゴと進行状況バーが既にあるスプラッシュを編集し、ブートメッセージを追加する方法。
これは私が編集したいテーマです:
そして、私はこのようなものが欲しいです:
または、これは私が作成したい正確なスプラッシュです:
このウェブサイトには多くの有用な情報がありますが、その一部を理解するのに苦労しています。以前にスクリプトを作成していません!
これはスクリプト作成に役立つ別のWebサイトです
これは、スプラッシュの進行状況バーのスクリプトです。
#----------------------------------------- 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);
わかりましたので、私はもっと多くの検索を行い、プリマスについてもう少し学ぶことができました。
これらは私が便利だと思ったサイトです。 プリマスのテーマガイド 私たちがしていることの要点をつかむために、それらの記事を読む必要がある4つのパートがあります。 (私は彼らのスクリプトをスプラッシュのスクリプトと比較して何が何であるかを理解していましたが、誰かが私の足跡をたどる場合はそれを行うことをお勧めします。) プリマススクリプト Okこのリンク何をすべきかを理解するために2ページを通過しなければなりませんでした。彼らは私と同じことをしたことがわかりました。これは、すでに回転するロゴ、背景、プログレスバーがあるプリマススプラッシュにブートメッセージを向けることです。
だから私は/lib/lsb/init-functions
ファイルを編集し、この段落を追加してPlymouthにブートエラー/成功などのメッセージを送信するようにしなければならなかった
# 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 "$@"
}
加えて
# 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 "$@"
}
これまでのところ、プリマスへのメッセージを送信することはできませんでしたが、プリマスのスクリプトがどのように機能するのかをよりよく理解できました!
私はそれを機能させるために他に何をすべきかわからない!ここに誰かが私を助けることができることを願っています
ああ、これが Splash のスクリプトの私のバージョンです。
# 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);
わかりましたので、必要な情報をほぼすべて提供しました。これに慣れている人がいれば、プリマスにブートメッセージを送信するために足りないものを教えてください。ありがとう
わかりましたので、私はこの問題に4日間まっすぐ取り組んでいます、そして、私はほとんど完全にそれを打ちました。これまでのところ、メッセージが表示された状態でPlymouthを起動することができましたが、残念ながらメッセージは切り捨てられます。現在、スクリプトを微調整しようとしていますが、/ lib/lsb/init-functionsスクリプトまたは/lib/plymouth/themes/"theme-name"/mdv.scriptのどこに問題があるのかわかりません。
これまでの私の仕事です。
まず、init関数が次のようにメッセージをプリマスに送信するようにする必要があります(各行を確認して違いを確認し、プリマスの送信に対応する行をコピーします)。
# /lib/lsb/init-functions for Debian -*- Shell-script -*-
#
#Copyright (c) 2002-08 Chris Lawrence
#All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions
#are met:
#1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#3. Neither the name of the author nor the names of other contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
start_daemon () {
local force Nice pidfile exec i args
force=0
Nice=0
pidfile=/dev/null
OPTIND=1
while getopts fn:p: opt ; do
case "$opt" in
f) force=1;;
n) Nice="$OPTARG";;
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
if [ "$1" = '--' ]; then
shift
fi
exec="$1"; shift
args="--start --nicelevel $Nice --quiet --oknodo"
if [ $force = 1 ]; then
/sbin/start-stop-daemon $args --chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@"
Elif [ $pidfile ]; then
/sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@"
else
/sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@"
fi
}
pidofproc () {
local pidfile line i pids= status specified pid
pidfile=
specified=
OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG"; specified=1;;
esac
done
shift $(($OPTIND - 1))
base=${1##*/}
if [ ! "$specified" ]; then
pidfile="/var/run/$base.pid"
fi
if [ -n "${pidfile:-}" -a -r "$pidfile" ]; then
read pid < "$pidfile"
if [ -n "${pid:-}" ]; then
if $(kill -0 "${pid:-}" 2> /dev/null); then
echo "$pid"
return 0
Elif ps "${pid:-}" >/dev/null 2>&1; then
echo "$pid"
return 0 # program is running, but not owned by this user
else
return 1 # program is dead and /var/run pid file exists
fi
fi
fi
if [ -x /bin/pidof -a ! "$specified" ]; then
status="0"
/bin/pidof -o %PPID -x $1 || status="$?"
if [ "$status" = 1 ]; then
return 3 # program is not running
fi
return 0
fi
return 4 # Unable to determine status
}
# start-stop-daemon uses the same algorithm as "pidofproc" above.
killproc () {
local pidfile sig status base i name_param is_term_sig
pidfile=
name_param=
is_term_sig=no
OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
base=${1##*/}
if [ ! $pidfile ]; then
name_param="--name $base --pidfile /var/run/$base.pid"
else
name_param="--pidfile $pidfile"
fi
sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/')
sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
if [ -z "$sig" -o "$sig" = 15 -o "$sig" = TERM ]; then
is_term_sig=yes
fi
status=0
if [ ! "$is_term_sig" = yes ]; then
if [ -n "$sig" ]; then
/sbin/start-stop-daemon --stop --signal "$sig" --quiet $name_param || status="$?"
else
/sbin/start-stop-daemon --stop --quiet $name_param || status="$?"
fi
else
/sbin/start-stop-daemon --stop --quiet --oknodo $name_param || status="$?"
fi
if [ "$status" = 1 ]; then
if [ -n "$sig" ]; then
return 0
fi
return 3 # program is not running
fi
if [ "$status" = 0 -a "$is_term_sig" = yes -a "$pidfile" ]; then
pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile"
fi
return 0
}
# Return LSB status
status_of_proc () {
local pidfile daemon name status
pidfile=
OPTIND=1
while getopts p: opt ; do
case "$opt" in
p) pidfile="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
if [ -n "$pidfile" ]; then
pidfile="-p $pidfile"
fi
daemon="$1"
name="$2"
status="0"
pidofproc $pidfile $daemon >/dev/null || status="$?"
if [ "$status" = 0 ]; then
log_success_msg "$name is running"
return 0
Elif [ "$status" = 4 ]; then
log_failure_msg "could not access PID file for $name"
return $status
else
log_failure_msg "$name is not running"
return $status
fi
}
log_use_fancy_output () {
TPUT=/usr/bin/tput
EXPR=/usr/bin/expr
if [ -t 1 ] && [ "x${TERM:-}" != "x" ] && [ "x${TERM:-}" != "xdumb" ] && [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1 && $TPUT setaf 1 >/dev/null 2>&1; then
[ -z $FANCYTTY ] && FANCYTTY=1 || true
else
FANCYTTY=0
fi
case "$FANCYTTY" in
1|Y|yes|true) true;;
*) false;;
esac
}
log_success_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@
fi
log_end_msg 0
}
log_failure_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@ "..."
fi
log_end_msg 1 || true
}
log_warning_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@ "..."
fi
log_end_msg 255 || true
}
#
# NON-LSB HELPER FUNCTIONS
#
# int get_lsb_header_val (char *scriptpathname, char *key)
get_lsb_header_val () {
if [ ! -f "$1" ] || [ -z "${2:-}" ]; then
return 1
fi
LSB_S="### BEGIN INIT INFO"
LSB_E="### END INIT INFO"
sed -n "/$LSB_S/,/$LSB_E/ s/# $2: \(.*\)/\1/p" $1
}
# 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 "$@"
plymouth_send -n "$@"
}
# Sample usage:
# log_daemon_msg "Starting GNOME Login Manager" "gdm"
#
# On Debian, would output "Starting GNOME Login Manager: gdm"
# On Ubuntu, would output " * Starting GNOME Login Manager..."
#
# If the second argument is omitted, logging suitable for use with
# log_progress_msg() is used:
#
# log_daemon_msg "Starting remote filesystem services"
#
# On Debian, would output "Starting remote filesystem services:"
# On Ubuntu, would output " * Starting remote filesystem services..."
log_daemon_msg () {
if [ -z "${1:-}" ]; then
return 1
fi
log_daemon_msg_pre "$@"
if [ -z "${2:-}" ]; then
echo -n "$1:"
plymouth_send -n "$1:"
return
fi
echo -n "$1: $2"
plymouth_send -n "$1: $2"
log_daemon_msg_post "$@"
}
# #319739
#
# Per policy docs:
#
# log_daemon_msg "Starting remote file system services"
# log_progress_msg "nfsd"; start-stop-daemon --start --quiet nfsd
# log_progress_msg "mountd"; start-stop-daemon --start --quiet mountd
# log_progress_msg "ugidd"; start-stop-daemon --start --quiet ugidd
# log_end_msg 0
#
# You could also do something fancy with log_end_msg here based on the
# return values of start-stop-daemon; this is left as an exercise for
# the reader...
#
# On Ubuntu, one would expect log_progress_msg to be a no-op.
log_progress_msg () {
if [ -z "${1:-}" ]; then
return 1
fi
echo -n " $@"
plymouth_send -n " $@"
}
# int log_end_message (int exitstatus)
log_end_msg () {
# If no arguments were passed, return
if [ -z "${1:-}" ]; then
return 1
fi
retval=$1
log_end_msg_pre "$@"
# 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}"
plymouth_send -f "failed${end}"
else
echo "failed${end}"
plymouth_send -f "failed${end}"
fi
fi
log_action_end_msg_post "$@"
}
# Hooks for /etc/lsb-base-logging.sh
log_daemon_msg_pre () { :; }
log_daemon_msg_post () { :; }
log_end_msg_pre () { :; }
log_end_msg_post () { :; }
log_action_end_msg_pre () { :; }
log_action_end_msg_post () { :; }
FANCYTTY=
[ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true
これをinit関数に追加したら、Plymouthテーマmdv.scriptを編集する必要があります
これは、スクリプトの最新の更新バージョンです。
# 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;
};
#change animcount to increase/decrease speed of spinning arrows
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(), -100);
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(1);
motif.Sprite.SetOpacity(1);
}
}
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(1);
anim.Sprite.SetOpacity(1);
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))
{
# * 3 = multiply progress 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);
#----------------------------------------- Status Update --------------------------------
NUM_SCROLL_LINES=10;
LINE_WIDTH=55;
# width of one character doesnt work------------
CHAR_WIDTH = 7;
# height of one character
CHAR_HEIGHT = 10;
#------------------------
msg_color = [1,1,1]; # msg_color is array
#status callback function
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];
}
screen_width = Window.GetWidth();
screen_height = Window.GetHeight();
#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("", msg_color[0], msg_color[1], msg_color[2]);
message_Sprite[i] = Sprite();
message_Sprite[i].SetPosition(screen_width * 0.025, (screen_height * 0.6) + (i * 20), 10000);
}
fun StringLength(string) {
index = 0;
str = String(string);
while(str.CharAt(index)) index++;
return index;
}
pretext = String("");
#scroll message function
fun scroll_message_callback(text) {
##nobreak function
nobreak = 0;
if (text.CharAt(0) == ">") { # "no linebreak" flag, like "-n"
text = text.SubString(1, StringLength(text)); # remove ">" at front
nobreak = 1;
}
if ((pretext == "") || (StringLength(text) > 15)) {
if (text == ".") return; # ignore messages of only a single dot
if (nobreak == 1) pretext = text;
#Truncate the message if too long
if (StringLength(text) > LINE_WIDTH) {
text = text.SubString(0, LINE_WIDTH - 0);
text += "...";
}
#Shift message 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
lines[i] = Image.Text(text, msg_color[0], msg_color[1], msg_color[2]);
#Re-positioning the text images
for (i = 0; i < NUM_SCROLL_LINES; i++) {
message_Sprite[i].SetImage(lines[i]);
}
}
Plymouth.SetUpdateStatusFunction(update_status_callback);
Plymouth.SetUpdateStatusFunction(scroll_message_callback);
#----------------------------------------- Quit --------------------------------
fun quit_callback ()
{
anim.Sprite.SetOpacity (1);
if (Plymouth.GetMode() == "shutdown") {
motif.Sprite.SetOpacity(1);
}
}
Plymouth.SetQuitFunction(quit_callback);
基本的に、スクリプトは任意のテーマに適用できます。必要なのは、フォルダー内の画像のファイル名を指定することだけです。そして、画面上の画像を調整するために他のいくつかの行を変更します。または、あなたがしなければならないのは、すべてをコピーするだけなので、進行状況の部分が欲しいと言うことができるように、必要な部分をコピーすることです
まで
Mdv.scriptの編集が完了したら、Sudo update-initramfs -u
を確認してください。次回の起動時に、新しいスプラッシュが表示されます。
私の質問で提供されているリンクを必ずチェックしてください。それらは非常に有益であり、プリマススクリプトをすぐに理解できるようになります。
ここで私が言ったことをすべて完了したら、スプラッシュブートでスクロールメッセージが表示されるはずです。切り捨て部分については、現在作業中ですが、変更を加えるたびにマシンをリブートしなければならないのはちょっと面倒です。 ログイン中にブートプロセスをテストすることは可能ですか like
Sudo plymouthd ; Sudo plymouth --show-splash ; Sudo plymouth update --status="Hello" ; sleep 2 ; Sudo plymouth update --status="This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. " ; sleep 10 ; Sudo killall plymouthd
Plymouthをテストするもう1つの方法は、上記のコマンドをテキストファイルにコピーし、Sudo plymouth update --status="your message"
を追加して、さらにメッセージをスクロールさせることです。次に、ファイルを実行可能にし、ターミナルで実行します。
これが、プリマスのスプラッシュを編集したい人に役立つことを願っています。幸運を!!!
古いスレッドであることは知っていますが、テキストの切り捨てについての答えは知っていると思います。 themename.script(themename.plymouthファイルではありません)では、2つの変数を使用します。
1. NUM_SCROLL_LINES
2. LINE_WIDTH
これらの変数を使用して、表示される行数と表示される行の長さを設定できます。また、このスクリプトには、表示が長すぎる場合に行を切り捨てる関数があります。
これが誰かに役立つことを願っています。
Opensuse 42.1 Leapでの私の問題は。 plymouthは、/ var/log/boot.logに書き込まれるように、ブートメッセージを表示しません。サービスのsystemd呼び出しを示しています。
この方法で/ lib/lsb/init-functionsも編集しました
if [ -x /usr/bin/plymouth ]; then
/usr/bin/plymouth update --status="$@"
fi
またはその
[ -x /usr/bin/plymouth ] && /usr/bin/plymouth update --status="$@"
私には何も機能しませんでした。誰もがアイデアを持っていますか?
ここに私が使用するthemename.scriptがあります
NUM_SCROLL_LINES=52;
LINE_WIDTH=120;
wallpaper_image = Image("background.png");
screen_width = Window.GetWidth();
screen_height = Window.GetHeight();
resized_wallpaper_image = wallpaper_image.Scale(screen_width,screen_height);
wallpaper_Sprite = Sprite(resized_wallpaper_image);
wallpaper_Sprite.SetZ(-100);
// 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();
# here you can set the hights and width of textdisplay. 0.005 uses almost the whole screen.
# message_Sprite[i].SetPosition(screen_width * 0.2, (screen_height * 0.6) + (i * 20), 10000);
message_Sprite[i].SetPosition(screen_width * 0.005, (screen_height * 0.005) + (i * 20), 10000);
}
// From ubuntu-logo
fun StringLength(string) {
index = 0;
str = String(string);
while(str.CharAt(index)) index++;
return index;
}
fun scroll_message_callback(text) {
// Truncate the message if too long
if (StringLength(text) > LINE_WIDTH) {
text = text.SubString(0, LINE_WIDTH - 3);
text += "...";
}
// Shift message one up
for (i = 0; i < NUM_SCROLL_LINES - 1; i++) {
lines[i] = lines[i+1];
}
// Create the image for the latest message
# z.B. turquoise coloured text / (text, 0.28, 0.82, 0.80); // 1.0 = 100% 0.28 = 28% usw.
lines[i] = Image.Text(text, 0.28, 0.82, 0.80);
// Re-positioning the text images
for (i = 0; i < NUM_SCROLL_LINES; i++) {
message_Sprite[i].SetImage(lines[i]);
}
}
Plymouth.SetUpdateStatusFunction(scroll_message_callback);