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 | From 7d15c9356e6ed3b320c86a54444522d5b4202c73 Mon Sep 17 00:00:00 2001
From: Didier Roche <didrocks@ubuntu.com>
Date: Thu, 26 Feb 2015 11:05:10 +0100
Subject: [PATCH] Get systemd-fsckd support to the script theme
systemd-fsckd now supports reporting progress, cancellation and user message
when one or more fsck are in progress.
Indicate that a fsck check is in progress and how to cancel it to the user.
There is no implementation in that theme on showing exact progress report, but
this can be added via the update_status_callback() function.
Ensure we delete the user message showing how to cancel a fsck in progress
when fsck is done, or when the user cancelled it.
systemd-fsckd manpage contains more details on the protocol.
---
themes/script/script.script | 66 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/themes/script/script.script b/themes/script/script.script
index 7ea9d5e..228f540 100644
--- a/themes/script/script.script
+++ b/themes/script/script.script
@@ -30,6 +30,37 @@ fun refresh_callback ()
Plymouth.SetRefreshFunction (refresh_callback);
+#-------------------------------- Some strings utilities ---------------------------
+
+fun StringString(string, substring) {
+ local.start = 0;
+ while (String(string).CharAt (start)) {
+ local.walk = 0;
+ while (String(substring).CharAt (walk) == String(string).CharAt (start + walk) ) {
+ walk++;
+ if (!String(substring).CharAt (walk)) return start;
+ }
+ start++;
+ }
+
+ return NULL;
+}
+
+fun StringLength (string) {
+ local.index = 0;
+ while (String(string).CharAt(index)) index++;
+ return index;
+}
+
+fun StringCopy (source, beginning, end) {
+ local.destination = "";
+ for (index = beginning; ( ( (end == NULL) || (index <= end) ) && (String(source).CharAt(index)) ); index++) {
+ destination += String(source).CharAt(index);
+ }
+
+ return destination;
+}
+
#----------------------------------------- Dialogue --------------------------------
status = "normal";
@@ -155,9 +186,20 @@ Plymouth.SetQuitFunction(quit_callback);
message_sprites = [];
message_sprite_count = 0;
message_sprite_y = 10;
+cancel_fsckd_msg_index = -1;
fun display_message_callback (text)
{
+ # if fsck message coming from systemd-fsckd, use the localized string directly
+ local.fsck_key = "fsckd-cancel-msg:";
+ local.key = StringString(text, fsck_key);
+ if (key != NULL) {
+ text = StringCopy(text, key + StringLength(fsck_key), NULL);
+ if (!text)
+ return;
+ cancel_fsckd_msg_index = message_sprite_count;
+ }
+
my_image = Image.Text(text, 1, 1, 1);
message_sprites[message_sprite_count] = Sprite(my_image);
message_sprites[message_sprite_count].SetPosition(10, message_sprite_y, 10000);
@@ -175,5 +217,29 @@ fun hide_message_callback (text)
}
}
+fun update_status_callback(status) {
+ if (!status) return;
+ local.index = 0;
+ local.update_strings[index] = "";
+ if (StringString(text, fsck_string) != NULL) {
+ for (local.i=0; (String(status).CharAt(i) != ""); i++) {
+ local.temp_char = String(status).CharAt(i);
+ if (temp_char != ":")
+ update_strings[index] += temp_char;
+ else
+ update_strings[++index] = "";
+ }
+ }
+
+ # we are only interested in fsck progress to know when when should hide fsckd-cancel-msg
+ if (update_strings[0] == "fsckd") {
+ # systemd-fsckd pass fsckd:<number_devices>:<progress>:<l10n_string>
+ if ((update_strings[2] == "100,0") && (cancel_fsckd_msg_index != -1))
+ message_sprites[cancel_fsckd_msg_index] = NULL;
+ cancel_fsckd_msg_index = -1;
+ }
+}
+
Plymouth.SetDisplayMessageFunction (display_message_callback);
Plymouth.SetHideMessageFunction (hide_message_callback);
+Plymouth.SetUpdateStatusFunction (update_status_callback);
--
2.1.4
|