2 * Related to the screen */
4 screen_width = Window.GetWidth();
5 screen_height = Window.GetHeight();
6 screen_x = Window.GetX();
7 screen_y = Window.GetY();
12 * Images, check bits per pixel
13 * and load images accordingly */
15 background_image = Image("wallpaper.png");
16 passw_dialog_input_image = Image("passw-dialog.png");
17 bullet_image = Image("test.png");
19 bpp = Window.GetBitsPerPixel();
23 logotype_image = Image("logo_16bit.png");
24 progress_meter_image = Image("progress-meter_16bit.png");
25 progress_fade_image = Image("progress-fade_16bit.png");
26 fsck_progress_meter_image = Image("progress-meter_16bit.png");
27 fsck_progress_fade_image = Image("fsck-fade_16bit.png");
32 logotype_image = Image("logo.png");
33 progress_meter_image = Image("progress-meter.png");
34 progress_fade_image = Image("progress-fade.png");
35 fsck_progress_meter_image = Image("progress-meter.png");
36 fsck_progress_fade_image = Image("fsck-fade.png");
45 ratio = screen_height / screen_width;
46 background_ratio = background_image.GetHeight() / background_image.GetWidth();
49 if (ratio > background_ratio) {
51 factor = screen_height / background_image.GetHeight();
56 factor = screen_width / background_image.GetWidth();
60 scaled = background_image.Scale(background_image.GetWidth() * factor, background_image.GetHeight() * factor);
61 background_sprite = Sprite(scaled);
62 background_sprite.SetX(screen_x + screen_width / 2 - scaled.GetWidth() / 2);
63 background_sprite.SetY(screen_y + screen_height / 2 - scaled.GetHeight() / 2);
65 logotype_sprite = Sprite(logotype_image);
67 fsck_progress_meter_sprite = Sprite(fsck_progress_meter_image);
68 fsck_progress_fade_sprite = Sprite(fsck_progress_fade_image.Scale(1, fsck_progress_fade_image.GetHeight()));
70 passw_dialog_input_sprite = Sprite(passw_dialog_input_image);
71 passw_lbl_sprite = Sprite();
73 msg_label_sprite = Sprite();
82 fade_pos_x = (screen_width / 2) - (progress_meter_image.GetWidth() / 2);
83 fade_dir = 0; /* 0 = right, 1 = left */
88 fsck_fade_in_counter = 0;
95 msgs_line = [NULL,NULL,NULL,NULL,NULL];
103 debug_sprite = Sprite();
105 fun debugOutput(str) {
108 * This will print to the top left corner */
109 debug_sprite.SetImage(Image.Text(str));
116 * Setup the graphics properties */
117 logotype_sprite.SetPosition(screen_x + (screen_width / 2) - (logotype_image.GetWidth() / 2), screen_y + (screen_height / 2) - (logotype_image.GetHeight() / 2));
118 fsck_progress_meter_sprite.SetPosition(screen_x + (screen_width / 2) - (progress_meter_image.GetWidth() / 2), screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 25);
119 fsck_progress_fade_sprite.SetPosition(screen_x + (screen_width / 2) - (progress_meter_image.GetWidth() / 2), screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 25);
120 fsck_progress_meter_sprite.SetOpacity(0);
121 fsck_progress_fade_sprite.SetOpacity(0);
122 passw_dialog_input_sprite.SetPosition(screen_x + (screen_width / 2) - (passw_dialog_input_image.GetWidth() / 2), screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 70);
123 passw_dialog_input_sprite.SetOpacity(0);
124 passw_lbl_sprite.SetOpacity(0);
129 * this function only goes up to 100
130 * because thats all thats needed for
131 * the progress meter bar */
136 for (i = 0; i <= 100; i++) {
153 * This handler will/can be invoked
154 * 50 times per second.
156 * According to the previous author of the
157 * splash script, without this callback
158 * the screen is not updated correctly */
162 fun refreshHandler() {
164 if (spin < 3.14 * 2) {
175 /* if fsck is running or the password is prompted, hide the spinner */
176 if (fsck_running == 1 || passw_dialog_input_sprite.GetOpacity() == 1) {
178 spinner_sprite.SetOpacity(0);
182 spinner = Image("spinner.png");
183 spinner = spinner.Rotate(spin);
184 spinner_sprite = Sprite(spinner);
185 spinner_sprite.SetPosition(screen_x + (screen_width / 2) - (spinner.GetWidth() / 2), screen_y + (screen_height / 2) - (spinner.GetHeight() / 2) + 80);
193 if (counter >= 200) {
212 if ((fsck_running == 1) && (fsck_done_fading == 0)) {
215 fsck_progress_meter_sprite.SetOpacity(fsck_fade_in_counter);
216 fsck_progress_fade_sprite.SetOpacity(fsck_fade_in_counter);
218 if (fsck_fade_in_counter < 1) {
220 fsck_fade_in_counter+= 0.025;
225 fsck_done_fading = 1;
233 Plymouth.SetRefreshFunction (refreshHandler);
238 * This function will display the password related information
239 * when being prompt with entering a password */
240 fun showPasswordHandler(prompt, stars) {
242 if (passw_dialog_input_sprite.GetOpacity() == 0 && passw_lbl_sprite.GetOpacity() == 0) {
244 passw_dialog_input_sprite.SetOpacity(1);
245 passw_lbl_sprite.SetOpacity(1);
249 tmp_prompt_image = Image.Text(prompt, 1, 1, 1);
251 passw_lbl_sprite.SetImage(tmp_prompt_image);
252 passw_lbl_sprite.SetPosition(screen_x + (screen_width / 2) - (tmp_prompt_image.GetWidth() / 2), screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 50);
254 for(i = 0; i < stars_n; i++) {
256 stars_array[i] = NULL;
262 for(i = 0; (i < stars) && (i < 15); i++) {
264 stars_array[i] = Sprite(bullet_image);
265 stars_array[i].SetPosition(screen_x + (((screen_width / 2) - (passw_dialog_input_image.GetWidth() / 2)) + (18 * i)) + 2, screen_y + (screen_height / 2) + (logotype_image.GetHeight() / 2) + 75);
272 Plymouth.SetDisplayPasswordFunction(showPasswordHandler);
276 fun displayNormalHandler() {
279 * Hide the password dialog and the bullets */
281 if (passw_dialog_input_sprite.GetOpacity() == 1) {
283 passw_dialog_input_sprite.SetOpacity(0);
287 if (passw_lbl_sprite.GetOpacity() == 1) {
289 passw_lbl_sprite.SetOpacity(0);
293 for(i = 0; i < stars_n; i++) {
295 stars_array[i] = NULL;
301 Plymouth.SetDisplayNormalFunction(displayNormalHandler);
307 while (String(string).CharAt(i)) {
318 * This function will display the most current message */
319 fun messageHandler(msg) {
321 if ((msg == "") || !msg) {
327 if (msg.SubString(0, 5) == "keys:") {
329 msg = msg.SubString(5, strlen(msg));
333 # Get the message without the "fsckd-cancel-msg" prefix as we don't support i18n
334 if (msg.SubString(0, 17) == "fsckd-cancel-msg:")
335 msg = msg.SubString(17, strlen(msg));
337 //full_msg += msg + " ";
338 for(i = 4; i > 0; i--) {
340 msgs_line[i] = msgs_line[i - 1];
344 msgs_line[0] = Sprite(Image.Text(msg, 1, 1, 1));
348 for(i = 0; i < 5; i++) {
350 if (msgs_line[i] != NULL) {
352 msgs_line[i].SetPosition(screen_x + (screen_width / 2) - (msgs_line[i].GetImage().GetWidth() / 2), screen_y + (screen_height - msgs_line[i].GetImage().GetHeight()) - 20*dist);
361 Plymouth.SetMessageFunction(messageHandler);
366 * Handles the updates passed to the plymouth daemon
367 * for example the FSCK data */
368 fun statusHandler(status) {
371 status_array[0] = "";
374 for (i = 0; String(status).CharAt(i) != ""; i++) {
376 tmp_char = String(status).CharAt(i);
378 if (tmp_char != ":") {
380 status_array[elem_count] += tmp_char;
386 status_array[elem_count] = "";
392 if (status_array[0] == "fsck") {
396 if (fsck_running == 0) {
399 * use the dedicated message handler for this
400 * since there is no messages about fsck checks
402 messageHandler("Routine disk drive check.");
408 for(i = 0; i < fsck_dev_counter; i++) {
411 * check if the device already exist and update
412 * the progress only in that case */
413 if (fsck_dev_array[i][0] == status_array[1]) {
415 fsck_dev_array[i][1] = status_array[2]; /* progress */
423 * if the device is not added, then add it */
424 if (already_added == 0) {
426 fsck_dev_array[fsck_dev_counter][0] = status_array[1]; /* device */
427 fsck_dev_array[fsck_dev_counter][1] = status_array[2]; /* progress */
433 * update the progress */
437 for(i = 0; i < fsck_dev_counter; i++) {
439 total += atoi(fsck_dev_array[i][1]);
443 if (fsck_dev_counter > 0) {
446 * display the total percentage */
447 fsck_progress_fade_sprite.SetImage(fsck_progress_fade_image.Scale((fsck_progress_meter_image.GetWidth() / 100) * (total / fsck_dev_counter), fsck_progress_fade_image.GetHeight()));
454 * if the total progress is at maximum,
455 * make the progress meter go away,
456 * we might want to fade this out... */
457 if (total == (100 * fsck_dev_counter)) {
459 fsck_progress_meter_sprite.SetOpacity(0);
460 fsck_progress_fade_sprite.SetOpacity(0);
466 # systemd-fsckd pass fsckd:<number_devices>:<progress>:<l10n_string>
467 if (status_array[0] == "fsckd") {
470 # remove ",x" as we only care about integers
471 progress_str = status_array[2];
472 progress = atoi(progress_str.SubString(0, strlen(progress_str) - 2));
474 fsck_progress_fade_sprite.SetImage(fsck_progress_fade_image.Scale((fsck_progress_meter_image.GetWidth() / 100) * progress, fsck_progress_fade_image.GetHeight()));
477 * if the total progress is at maximum,
478 * make the progress meter go away,
479 * we might want to fade this out... */
480 if (progress == 100) {
481 fsck_progress_meter_sprite.SetOpacity(0);
482 fsck_progress_fade_sprite.SetOpacity(0);
488 Plymouth.SetUpdateStatusFunction(statusHandler);