@@ -6,13 +6,11 @@ use alloc::format;
6
6
use uefi:: {
7
7
boot:: ScopedProtocol ,
8
8
print,
9
- proto:: {
10
- console:: text:: { Color , Output } ,
11
- network:: snp:: SimpleNetwork ,
12
- } ,
13
- Result , Status ,
9
+ proto:: console:: text:: { Color , Output } ,
10
+ Result ,
14
11
} ;
15
12
13
+ const LOGO : & ' static str = include_str ! ( "../../assets/uefi.logo" ) ;
16
14
const VERSION : & ' static str = " Efifetch 0.1.9" ;
17
15
const COLORS : [ Color ; 14 ] = [
18
16
Color :: LightRed ,
@@ -30,108 +28,88 @@ const COLORS: [Color; 14] = [
30
28
Color :: Magenta ,
31
29
Color :: Black ,
32
30
] ;
33
- const LOGO : & ' static str = r#"
34
- .^!??~
35
- .:~7?7~: .:!~:
36
- ^7?7~: :~?5PY7: .
37
- ^!JPGJ. ~?YPPJ!: :~?!^
38
- GGGGG5~. ??7^ .:~7J5GGGG
39
- GP?!~!77!~^. .:^7JJ7~^::!PG
40
- P~ !YP5YYY5PGJ^ 7G
41
- J :^ !PGGGGP~ :77.^!?YG
42
- J ~J7. ^PGGP^ YGPJ?!:7G
43
- P: ~GG? 7?5: 7G
44
- GJ 7J!^.. YG7 :5. 7G
45
- GGJ: :7?7??!:JG7 ~Y5 7G
46
- ^!YY7: ^!?PG? 5G5 ^^
47
- :~!!^: !GG? YPJ
48
- .:^!?YPGGG? ^:.
49
- ^!JPP!
50
- "# ;
51
31
52
- pub fn draw (
53
- mut stdout : & mut ScopedProtocol < Output > ,
54
- net : & ScopedProtocol < SimpleNetwork > ,
55
- date : Date ,
56
- ) -> Result < Status > {
32
+ pub fn draw ( mut stdout : & mut ScopedProtocol < Output > , date : Date ) -> Result < ( ) > {
57
33
stdout. clear ( ) ?;
58
34
59
35
let ( rows, columns) = get_resolution ( & mut stdout) ?;
60
- let mut logo = LOGO . lines ( ) . skip ( 1 ) ;
36
+ let mut logo = LOGO . lines ( ) ;
61
37
62
38
let resolution = format ! ( " Resolution: {}x{}" , columns, rows) ;
63
39
let date = format ! ( " BIOS Date: {}/{}/{}" , date. day, date. month, date. year) ;
64
40
let revision = format ! ( " UEFI Revision: {}" , uefi:: system:: uefi_revision( ) ) ;
65
41
let firmware_vendor = format ! ( " Firmware Vendor: {}" , uefi:: system:: firmware_vendor( ) ) ;
66
42
let firmware_revision = format ! ( " Firmware Revision: {}" , uefi:: system:: firmware_revision( ) ) ;
67
- let network_state = format ! ( " Network state: {:?}" , net. mode( ) . state) ;
68
43
69
- assert ! ( rows >= 24 ) ;
70
- assert ! ( columns >= 100 ) ;
71
-
72
- // Top frame //
44
+ // Top frame - 1 line
45
+ //==================================================================//
46
+ let margin = columns - 35 ;
73
47
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
74
- print ! ( "┌{:─<32}┬{:─>right$}┐" , "" , "" , right = columns - 35 ) ;
48
+ print ! ( "┌{:─<32}┬{:─>margin$}┐" , "" , "" ) ;
49
+ //==================================================================//
75
50
76
- // Info bar //
51
+ // Info bar - 2 line
52
+ //==================================================================//
53
+ let margin = ( columns - 80 ) / 5 ;
77
54
print ! ( "│ {} │" , logo. next( ) . unwrap( ) ) ;
78
55
stdout_text_color ( & mut stdout, Color :: Red ) ?;
79
- print ! ( " NET: " ) ;
56
+ print ! ( " NET:" ) ;
80
57
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
81
- print ! ( "F1" ) ;
58
+ print ! ( "F1 " ) ;
82
59
stdout_text_color ( & mut stdout, Color :: Red ) ?;
83
- print ! ( "{:<width $}CPU: " , "" , width = ( columns - 81 ) / 5 ) ;
60
+ print ! ( "{:<margin $}CPU:" , "" ) ;
84
61
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
85
- print ! ( "F2" ) ;
62
+ print ! ( "F2 " ) ;
86
63
stdout_text_color ( & mut stdout, Color :: Red ) ?;
87
- print ! ( "{:<width $}MEM: " , "" , width = ( columns - 81 ) / 5 ) ;
64
+ print ! ( "{:<margin $}MEM:" , "" ) ;
88
65
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
89
- print ! ( "F3" ) ;
66
+ print ! ( "F3 " ) ;
90
67
stdout_text_color ( & mut stdout, Color :: Red ) ?;
91
- print ! ( "{:<width $}PCI: " , "" , width = ( columns - 81 ) / 5 ) ;
68
+ print ! ( "{:<margin $}PCI:" , "" ) ;
92
69
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
93
- print ! ( "F4" ) ;
70
+ print ! ( "F4 " ) ;
94
71
stdout_text_color ( & mut stdout, Color :: Red ) ?;
95
- print ! ( "{:<width $}ACPI: " , "" , width = ( columns - 81 ) / 5 ) ;
72
+ print ! ( "{:<margin $}ACPI:" , "" ) ;
96
73
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
97
- print ! ( "F5" ) ;
74
+ print ! ( "F5 " ) ;
98
75
stdout_text_color ( & mut stdout, Color :: Red ) ?;
99
- print ! ( "{:<width$}HOST: " , "" , width = ( columns - 81 ) / 5 ) ;
100
- stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
101
- print ! ( "F6 │" ) ;
102
-
103
- print ! (
104
- "│ {} ├{:─<width$}┤" ,
105
- logo. next( ) . unwrap( ) ,
106
- "" ,
107
- width = columns - 35
108
- ) ;
109
-
110
- // UEFI and runtime inf lines //
76
+ print ! ( "{:<margin$}HOST:" , "" ) ;
77
+ stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
78
+ print ! ( "F6 │" ) ;
79
+ //==================================================================//
80
+
81
+ // Underbar - 3 line
82
+ //==================================================================//
83
+ let margin = columns - 35 ;
84
+ print ! ( "│ {} ├{:─<margin$}┤" , logo. next( ) . unwrap( ) , "" ) ;
85
+ //==================================================================//
86
+
87
+ // UEFI and runtime information - 4-9 lines
88
+ //==================================================================//
111
89
print ! ( "│ {} │" , logo. next( ) . unwrap( ) ) ;
112
90
stdout_text_color ( & mut stdout, Color :: LightGray ) ?;
113
91
print ! ( "{VERSION}" ) ;
114
92
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
115
93
print ! ( "{:<width$}│" , "" , width = columns - VERSION . len( ) - 35 ) ;
116
-
94
+ // 5
117
95
print ! ( "│ {} │" , logo. next( ) . unwrap( ) ) ;
118
96
stdout_text_color ( & mut stdout, Color :: LightGray ) ?;
119
97
print ! ( "{resolution}" ) ;
120
98
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
121
99
print ! ( "{:<width$}│" , "" , width = columns - resolution. len( ) - 35 ) ;
122
-
100
+ // 6
123
101
print ! ( "│ {} │" , logo. next( ) . unwrap( ) ) ;
124
102
stdout_text_color ( & mut stdout, Color :: LightGray ) ?;
125
103
print ! ( "{date}" ) ;
126
104
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
127
105
print ! ( "{:<width$}│" , "" , width = columns - date. len( ) - 35 ) ;
128
-
106
+ // 7
129
107
print ! ( "│ {} │" , logo. next( ) . unwrap( ) ) ;
130
108
stdout_text_color ( & mut stdout, Color :: LightGray ) ?;
131
109
print ! ( "{revision}" ) ;
132
110
stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
133
111
print ! ( "{:<width$}│" , "" , width = columns - revision. len( ) - 35 ) ;
134
-
112
+ // 8
135
113
print ! ( "│ {} │" , logo. next( ) . unwrap( ) ) ;
136
114
stdout_text_color ( & mut stdout, Color :: LightGray ) ?;
137
115
print ! ( "{firmware_revision}" ) ;
@@ -141,7 +119,7 @@ pub fn draw(
141
119
"" ,
142
120
width = columns - firmware_revision. len( ) - 35
143
121
) ;
144
-
122
+ // 9
145
123
print ! ( "│ {} │" , logo. next( ) . unwrap( ) ) ;
146
124
stdout_text_color ( & mut stdout, Color :: LightGray ) ?;
147
125
print ! ( "{firmware_vendor}" ) ;
@@ -151,18 +129,16 @@ pub fn draw(
151
129
"" ,
152
130
width = columns - firmware_vendor. len( ) - 35
153
131
) ;
154
-
155
- print ! ( "│ {} │" , logo. next( ) . unwrap( ) ) ;
156
- stdout_text_color ( & mut stdout, Color :: LightGray ) ?;
157
- print ! ( "{network_state}" ) ;
158
- stdout_text_color ( & mut stdout, Color :: LightRed ) ?;
132
+ //==================================================================//
133
+
134
+ // Blank lines
135
+ //==================================================================//
159
136
print ! (
160
- "{:<width$}│" ,
137
+ "│ {} │{:<width$}│" ,
138
+ logo. next( ) . unwrap( ) ,
161
139
"" ,
162
- width = columns - network_state . len ( ) - 35
140
+ width = columns - 35
163
141
) ;
164
-
165
- // Blank lines //
166
142
print ! (
167
143
"│ {} │{:<width$}│" ,
168
144
logo. next( ) . unwrap( ) ,
@@ -234,12 +210,16 @@ pub fn draw(
234
210
left_space = 17 ,
235
211
right_space = columns - 35
236
212
) ;
213
+ //==================================================================//
214
+
215
+ // Bottom bar - 21 line
216
+ //==================================================================//
237
217
print ! (
238
218
"└{:─<32}┴{:─<right_space$}┘" ,
239
219
"" ,
240
220
"" ,
241
221
right_space = columns - 35
242
222
) ;
243
-
244
- Ok ( Status :: SUCCESS )
223
+ //==================================================================//
224
+ Ok ( ( ) )
245
225
}
0 commit comments