/usr/share/plymouth/themes/spacefun/spacefun.script is in desktop-base 8.0.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | # Spacefun Plymouth theme script
# Copyright 2010 Aurélien COUDERC
#
# Inspired by the great blog series on Plymouth by Charlie Brej.
#
# The script uses the material made by Valessio Brito for his SpaceFun
# theme for Debian 6.0 Squeeze.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#------------------------------- Constants -----------------------------------------
NUM_STARS = 40;
MAX_STAR_SIZE = Math.Min(Window.GetWidth(), Window.GetHeight()) * 0.045;
MAX_MSG_DISPLAYED = 5;
#------------------------------- Background ----------------------------------------
bg_image = Image("background.png");
# Compute screen/image ratio and scale the background accordingly
window_max_width = Window.GetX() * 2 + Window.GetWidth();
window_max_height = Window.GetY() * 2 + Window.GetHeight();
screen_ratio = window_max_width / window_max_height;
bg_image_ratio = bg_image.GetWidth() / bg_image.GetHeight();
if (screen_ratio > bg_image_ratio)
bg_scale_factor = window_max_width / bg_image.GetWidth();
else
bg_scale_factor = window_max_height / bg_image.GetHeight();
scaled_bg_image = bg_image.Scale(bg_image.GetWidth() * bg_scale_factor,
bg_image.GetHeight() * bg_scale_factor);
# Display background
bg_sprite = Sprite(scaled_bg_image);
bg_sprite.SetPosition(Window.GetX() + Window.GetWidth() / 2 - scaled_bg_image.GetWidth() / 2,
Window.GetY() + Window.GetHeight() / 2 - scaled_bg_image.GetHeight() / 2,
-10000);
#------------------------------- Earth ---------------------------------------------
earth_height = Math.Min(Window.GetWidth(), Window.GetHeight()) * 0.12;
for (i = 0; i < 5; i++)
{
earth_image = Image("earth" + i + ".png");
earth_scale_factor = earth_height / earth_image.GetHeight();
earth_images[i] = earth_image.Scale(earth_image.GetWidth() * earth_scale_factor,
earth_image.GetHeight() * earth_scale_factor);
}
earth_glow_index = 0;
earth_sprite = Sprite(earth_images[earth_glow_index]);
earth_to_edge = Math.Min(Window.GetWidth(), Window.GetHeight()) * 0.07;
earth_x = Window.GetX() + earth_to_edge;
earth_y = Window.GetY() + Window.GetHeight() - earth_to_edge - earth_images[0].GetHeight();
earth_sprite.SetPosition(earth_x, earth_y, -10);
#------------------------------- Planet --------------------------------------------
planet_image = Image("planet.png");
planet_height = Math.Min(Window.GetWidth(), Window.GetHeight()) * 0.07;
planet_scale_factor = planet_height / planet_image.GetHeight();
planet_image = planet_image.Scale(planet_image.GetWidth() * planet_scale_factor,
planet_image.GetHeight() * planet_scale_factor);
planet_sprite = Sprite(planet_image);
planet_to_edge_y = Window.GetHeight() * 0.14;
planet_to_edge_x = Window.GetWidth() * 0.08;
planet_x = Window.GetX() + Window.GetWidth() - planet_to_edge_x - planet_image.GetWidth();
planet_y = Window.GetY() + planet_to_edge_y;
planet_sprite.SetPosition(planet_x, planet_y, -10);
#------------------------------- Logo ----------------------------------------------
logo_image = Image("logo.png");
logo_height = Math.Min(Window.GetWidth(), Window.GetHeight()) * 0.1;
logo_scale_factor = logo_height / logo_image.GetHeight();
logo_image = logo_image.Scale(logo_image.GetWidth() * logo_scale_factor,
logo_image.GetHeight() * logo_scale_factor);
logo_sprite = Sprite(logo_image);
logo_to_edge = Window.GetHeight() * 0.1;
logo_sprite.SetPosition(Window.GetX() + Window.GetWidth() - logo_to_edge - logo_image.GetWidth(),
Window.GetY() + Window.GetHeight() - logo_to_edge - logo_image.GetHeight(),
-10);
#------------------------------- Swirl galaxies ------------------------------------
swirlaxy_image = Image("swirlaxy.png");
if (!(Plymouth.GetMode() == "boot" || Plymouth.GetMode == "resume"))
{
swirls[0].x = 0.1; # Percentage of screen from left when positive, or right otherwise
swirls[0].y = 0.1; # Percentage of screen from top when positive, or bottom otherwise
swirls[0].height_p = 0.21; # Percent of screen height
swirls[0].angle = Math.Pi;
swirls[1].x = 0.54;
swirls[1].y = 0.14;
swirls[1].height_p = 0.11;
swirls[1].angle = Math.Pi;
swirls[2].x = -0.16;
swirls[2].y = -0.16;
swirls[2].height_p = 0.31;
swirls[2].angle = 0;
}
else
{
swirls[0].x = 0.1;
swirls[0].y = 0.12;
swirls[0].height_p = 0.38;
swirls[0].angle = 0;
swirls[1].x = 0.3;
swirls[1].y = -0.24;
swirls[1].height_p = 0.065;
swirls[1].angle = Math.Pi;
swirls[2].x = -0.05;
swirls[2].y = -0.3;
swirls[2].height_p = 0.21;
swirls[2].angle = Math.Pi;
}
for (i = 0; i < 3; i++)
{
swirl_height = Math.Min(Window.GetWidth(), Window.GetHeight()) * swirls[i].height_p;
swirl_width = swirl_height * swirlaxy_image.GetWidth() / swirlaxy_image.GetHeight();
swirl_image = swirlaxy_image.Scale(swirl_width, swirl_height);
swirl_image = swirl_image.Rotate(swirls[i].angle);
swirl_sprites[i] = Sprite();
if (swirls[i].x >= 0)
swirl_sprites[i].SetX(Window.GetX() + Window.GetWidth() * swirls[i].x);
else
swirl_sprites[i].SetX(Window.GetX() + Window.GetWidth() * (1 + swirls[i].x) - swirl_image.GetWidth());
if (swirls[i].y >= 0)
swirl_sprites[i].SetY(Window.GetY() + Window.GetHeight() * swirls[i].y);
else
swirl_sprites[i].SetY(Window.GetY() + Window.GetHeight() * (1 + swirls[i].y) - swirl_image.GetHeight());
swirl_sprites[i].SetImage(swirl_image);
}
#------------------------------- Stars ---------------------------------------------
# Load 3 star images
star_white_image = Image("star-white.png");
star_fuzzy_image = Image("star-fuzzy.png");
star_red_image = Image("star-red.png");
star_white_small_image = Image("star-white-small.png");
star_fuzzy_small_image = Image("star-fuzzy-small.png");
star_red_small_image = Image("star-red-small.png");
# Initialize the random seed depending on the resolution
pixels = Window.GetWidth() * Window.GetHeight();
while (pixels % 10 == 0)
{
pixels = pixels / 10;
Math.Random();
}
for (i = 0; i < pixels % 10; i++)
Math.Random();
# Create all star sprites
for (i = 0; i < NUM_STARS; i++)
{
# Randomly choose star image; white/fuzzy/red have 2/1/1 weights
star_type = Math.Random() * 4;
if (star_type < 2)
{
selected_image.big = star_white_image;
selected_image.small = star_white_small_image;
}
else if (star_type < 3)
{
selected_image.big = star_fuzzy_image;
selected_image.small = star_fuzzy_small_image;
}
else
{
selected_image.big = star_red_image;
selected_image.small = star_red_small_image;
}
# Choose random size
star_scaled_size = MAX_STAR_SIZE * Math.Random();
# Adapt the source image depending on the scale, smaller scales on big images
# don't render so nicely.
if (star_scaled_size > selected_image.small.GetHeight()
|| star_scaled_size > selected_image.small.GetWidth())
star_image = selected_image.big;
else
star_image = selected_image.small;
transformed_image = star_image.Scale(star_scaled_size, star_scaled_size);
# Random rotation of a 5 branch stars, we only need to rotate 2 * Pi / 5 at maximum.
transformed_image = transformed_image.Rotate(2 * Math.Pi / 5 * Math.Random());
stars[i] = Sprite(transformed_image);
# Randomize position, we accept that stars may be half out of the viewport
# in each direction
star_x = Window.GetX() + Math.Random() * (Window.GetWidth() + transformed_image.GetWidth())
- transformed_image.GetWidth() / 2;
star_y = Window.GetY() + Math.Random() * (Window.GetHeight() + transformed_image.GetHeight())
- transformed_image.GetHeight() / 2;
stars[i].SetPosition(star_x, star_y, -20); # Stars go behind other elements.
}
#------------------------------- Rocket --------------------------------------------
# Load all rocket images for animation
rocket_height = Math.Min(Window.GetWidth(), Window.GetHeight()) * 0.145;
for (i = 0; i < 4; i++)
{
rocket_image = Image("rocket" + i + ".png");
rocket_scale_factor = rocket_height / rocket_image.GetHeight();
rocket_images[i] = rocket_image.Scale(rocket_image.GetWidth() * rocket_scale_factor,
rocket_image.GetHeight() * rocket_scale_factor);
}
rocket_flame_index = 0;
rocket_sprite = Sprite();
# Rocket trajectory
# Take a point somwhere in the middle to compute the parabola
middle_x = Window.GetX() + Window.GetWidth() * 0.42;
middle_y = Window.GetY() + Window.GetHeight() * 0.42;
# Parabole coeffs so that y = a.x^2 + b.x + c for the earth, planet and middle points
# Use the earth and planet centers instead of top left corner
earth_cx = earth_x + earth_images[0].GetWidth()/2;
earth_cy = earth_y + earth_images[0].GetHeight()/2;
planet_cx = planet_x + planet_image.GetWidth()/2;
planet_cy = planet_y + planet_image.GetHeight()/2;
a = ((earth_cy-middle_y)/(earth_cx-middle_x)-(earth_cy-planet_cy)/(earth_cx-planet_cx))/(middle_x-planet_cx);
b = (middle_y-planet_cy)/(middle_x-planet_cx)-a*(middle_x+planet_cx);
c = earth_cy-a*earth_cx*earth_cx-b*earth_cx;
rocket_x_start = earth_cx + Window.GetWidth() * 0.1; # Don't start right on the earth
rocket_x_end = planet_cx - Window.GetWidth() * 0.1; # Don't reach the planet
# Set initial position
rocket_x = rocket_x_start;
rocket_y = a*rocket_x*rocket_x+b*rocket_x+c;
alpha = 2*a*rocket_x + b;
# Set flame status and rocket direction.
has_rocket = 0;
rocket_comes_back = 0;
if (Plymouth.GetMode() == "boot")
{
has_rocket = 1;
rocket_comes_back = 0;
}
if (Plymouth.GetMode() == "shutdown" || Plymouth.GetMode() == "suspend")
{
has_rocket = 1;
rocket_comes_back = 1;
}
if (Plymouth.GetMode() == "resume")
{
has_rocket = 1;
rocket_comes_back = 0;
}
#------------------------------- Animation -----------------------------------------
progress = 0;
fun refresh_callback ()
{
progress++;
# Rocket, update 50/3 times per second
if (progress % 3 == 0)
{
# 6 states for the rocket flame: 1, 2, 3, 4, 3, 2
rocket_flame_index = (rocket_flame_index + 1) % 6;
rocket_image = rocket_images[3 - Math.Abs(rocket_flame_index - 3)];
rotated_rocket = rocket_image.Rotate(alpha);
rocket_sprite.SetImage(rotated_rocket);
rocket_sprite.SetPosition(rocket_x - rotated_rocket.GetWidth()/2,
rocket_y - rotated_rocket.GetHeight()/2,
-10);
}
# Earth glow, update 10 times per second
if (earth_glow_index != 0 && progress % 5 == 0)
{
earth_glow_anim = Math.Int(3 * Math.Random()) - 1;
earth_glow_index = Math.Clamp(earth_glow_index + earth_glow_anim, 1, 4);
earth_sprite.SetImage(earth_images[earth_glow_index]);
}
# Stars dim, update 5 times per second
if (progress % 10 == 0)
{
for (i = 0; i < NUM_STARS; i++)
{
# Reset star to visible by 0.05 steps
star_opacity = stars[i].GetOpacity();
if (star_opacity < 1)
stars[i].SetOpacity(star_opacity + 0.05);
# 10% chance to dim the star
if (Math.Random() < 0.1)
stars[i].SetOpacity(0.8);
}
}
}
Plymouth.SetRefreshFunction (refresh_callback);
#------------------------------- Dialogue ------------------------------------------
status = "normal";
fun dialog_setup()
{
local.box;
local.lock;
local.entry;
box.image = Image("box.png");
lock.image = Image("lock.png");
entry.image = Image("entry.png");
box.sprite = Sprite(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 = Sprite(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 = Sprite(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);
global.dialog.box = box;
global.dialog.lock = lock;
global.dialog.entry = entry;
global.dialog.bullet_image = Image("bullet.png");
dialog_opacity (1);
}
fun dialog_opacity(opacity)
{
dialog.box.sprite.SetOpacity (opacity);
dialog.lock.sprite.SetOpacity (opacity);
dialog.entry.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);
for (index = 0; dialog.bullet[index] || index < bullets; index++)
{
if (!dialog.bullet[index])
{
dialog.bullet[index].sprite = Sprite(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);
}
}
Plymouth.SetDisplayNormalFunction(display_normal_callback);
Plymouth.SetDisplayPasswordFunction(display_password_callback);
#------------------------------- Progress Bar ------------------------------------------
# No "progress bar" per se, we use the rocket position
fun progress_callback (duration, progress)
{
if (rocket_comes_back)
{
# Rocket position
rocket_x = rocket_x_end - progress * (rocket_x_end - rocket_x_start);
rocket_y = a*rocket_x*rocket_x + b*rocket_x + c;
# Rocket orientation
alpha = Math.ATan2(2*a*rocket_x + b, 1) + Math.Pi;
}
else
{
# Rocket position
rocket_x = rocket_x_start + progress * (rocket_x_end - rocket_x_start);
rocket_y = a*rocket_x*rocket_x + b*rocket_x + c;
# Rocket orientation
alpha = Math.ATan2(2*a*rocket_x + b, 1);
}
}
Plymouth.SetBootProgressFunction(progress_callback);
#------------------------------- Root filesystem mount ---------------------------------
fun root_mounted_callback ()
{
# On boot show earth glow starting when root filesystem is mounted
earth_glow_index = 1;
}
Plymouth.SetRootMountedFunction(root_mounted_callback);
#------------------------------- Quit --------------------------------------------------
fun quit_callback ()
{
}
Plymouth.SetQuitFunction(quit_callback);
#------------------------------- Message -----------------------------------------------
msg_sprites; # Declare global variable
num_displayed_msg = 0; # Current number of message being displayed
next_msg_idx = 0; # Index of the message to be displayed next in the msg_sprites table
next_msg_y; # Y of next message to display
fun message_callback (text)
{
if (num_displayed_msg < MAX_MSG_DISPLAYED)
{
# We've not reached max number of messages
# Compute next y
next_msg_y = 10;
for (i = 0; i < num_displayed_msg; i++)
next_msg_y += msg_sprites[i].GetImage().GetHeight() + 1; # 1px between lines
num_displayed_msg++;
}
else
{
# We've reached max number of messages
# Move all existing messages one line up
move_y_by = -1 - msg_sprites[(next_msg_idx + 1) % MAX_MSG_DISPLAYED].GetImage().GetHeight();
for (i = 0; i < MAX_MSG_DISPLAYED; i++)
{
msg = msg_sprites[(next_msg_idx + 1 + i) % MAX_MSG_DISPLAYED];
msg.SetY(msg.GetY() + move_y_by);
}
}
next_msg_image = Image.Text(text, 1, 1, 1, 1);
msg_sprites[next_msg_idx] = Sprite();
msg_sprites[next_msg_idx].SetPosition(Window.GetX() + 10, Window.GetY() + next_msg_y, 10000);
msg_sprites[next_msg_idx].SetImage(next_msg_image);
next_msg_idx = (next_msg_idx + 1) % MAX_MSG_DISPLAYED;
}
Plymouth.SetMessageFunction(message_callback);
|