-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysi-cz
460 lines (397 loc) · 18.3 KB
/
sysi-cz
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
#!/bin/bash
set -u
# Function to add colors to text
color_text() {
local color=$1
local text=$2
# ANSI color codes
declare -A colors=(
["black"]="\033[30m" ["red"]="\033[31m" ["green"]="\033[32m"
["yellow"]="\033[33m" ["blue"]="\033[34m" ["magenta"]="\033[35m"
["cyan"]="\033[36m" ["white"]="\033[37m" ["bright_black"]="\033[90m"
["bright_red"]="\033[91m" ["bright_green"]="\033[92m" ["bright_yellow"]="\033[93m"
["bright_blue"]="\033[94m" ["bright_magenta"]="\033[95m" ["bright_cyan"]="\033[96m"
["bright_white"]="\033[97m" ["bg_black"]="\033[40m" ["bg_red"]="\033[41m"
["bg_green"]="\033[42m" ["bg_yellow"]="\033[43m" ["bg_blue"]="\033[44m"
["bg_magenta"]="\033[45m" ["bg_cyan"]="\033[46m" ["bg_white"]="\033[47m"
["bg_bright_black"]="\033[100m" ["bg_bright_red"]="\033[101m"
["bg_bright_green"]="\033[102m" ["bg_bright_yellow"]="\033[103m"
["bg_bright_blue"]="\033[104m" ["bg_bright_magenta"]="\033[105m"
["bg_bright_cyan"]="\033[106m" ["bg_bright_white"]="\033[107m"
)
# Output the colored text, or an error message if the color is not found
if [[ ${colors[$color]} ]]; then
echo -e "${colors[$color]}${text}\033[0m"
else
echo "Color '$color' not recognized."
fi
}
# Function to center text based on terminal width, handling multi-line input
center_text() {
local text="$1"
local cols=$(tput cols)
while IFS= read -r line; do
local text_length=${#line}
if [ $text_length -lt $cols ]; then
local padding=$(( (cols - text_length) / 2 ))
printf "%${padding}s%s\n" " " "$line"
else
echo "$line"
fi
done <<< "$text"
}
# Function to calculate percentage
get_percentage() {
used=$1
total=$2
awk -v used="$used" -v total="$total" 'BEGIN { printf("%.2f%%", (used / total) * 100) }'
}
# Get memory and swap usage details
memory_usage=$(free -h --si | awk '/^Mem/ {print $3 " / " $2}')
swap_usage=$(free -h --si | awk '/^Swap/ {print $3 " / " $2}')
# Calculate percentage for memory
memory_used=$(free --si | awk '/^Mem/ {print $3}')
memory_total=$(free --si | awk '/^Mem/ {print $2}')
memory_percentage=$(get_percentage "$memory_used" "$memory_total")
# Calculate percentage for swap
swap_used=$(free --si | awk '/^Swap/ {print $3}')
swap_total=$(free --si | awk '/^Swap/ {print $2}')
swap_percentage=$(get_percentage "$swap_used" "$swap_total")
# Function to display ASCII art of a computer screen with SYSI
display_logo() {
center_text "$(color_text "bg_red" " _________")"
center_text "$(color_text "bg_green" " / |")"
center_text "$(color_text "bg_yellow" " / _______ |")"
center_text "$(color_text "bg_blue" " | | | |")"
center_text "$(color_text "bg_magenta" " | | SYSI | |")"
center_text "$(color_text "bg_cyan" " | |_______| |")"
center_text "$(color_text "bg_white" " | |")"
center_text "$(color_text "bg_bright_red" " | _______ |")"
center_text "$(color_text "bg_bright_yellow" " | / \\ |")"
center_text "$(color_text "bg_bright_blue" " |/ \\|")"
center_text "$(color_text "bg_green" " \\___________/")"
echo ""
}
# Function to display system informations
display_info() {
os=$(awk -F= '/^PRETTY_NAME=/{print $2}' /etc/os-release | tr -d '"')
center_text "$(color_text "bg_green" " Operační systém")"
center_text "$(color_text "bright_white" "$os")"
echo""
center_text "$(color_text "bg_green" " Host")"
center_text "$(color_text "bright_white" "$(cat /proc/sys/kernel/hostname)")"
echo""
center_text "$(color_text "bg_green" " Model")"
center_text "$(color_text "bright_white" "$(cat /sys/devices/virtual/dmi/id/board_{name,vendor} | awk '!(NR%2){print$1,p}{p=$0}')")"
echo""
center_text "$(color_text "bg_yellow" " Přihlášení uživatelé")"
center_text "$(w)"
echo""
center_text "$(color_text "bg_yellow" " Název jádra")"
center_text "$(color_text "bright_white" "$(uname -s)")"
echo""
center_text "$(color_text "bg_yellow" " Verze jádra")"
center_text "$(color_text "bright_white" "$(uname -r)")"
echo""
center_text "$(color_text "bg_yellow" " Vydání jádra \e[0m")"
center_text "$(uname -v)"
echo""
center_text "$(color_text "bg_yellow" " Architektura jádra")"
center_text "$(color_text "bright_white" "$(uname -m)")"
echo""
center_text "$(color_text "bg_white" " Doba provozuschopnosti")"
center_text "$(color_text "bg_blue" "\e[0m $(uptime -p)")"
echo""
center_text "$(color_text "bg_white" " Hodiny/čas")"
center_text "$(color_text "white" "\e[0m $(date '+%Y-%m-%d %H:%M:%S')")"
echo""
center_text "$(color_text "bg_bright_black" " Balíčky: $(get_package_count)")"
echo""
center_text "$(color_text "bg_bright_black" " Rozlišení")"
center_text "$(color_text "bright_white" "\e[0m $(xrandr | grep -i "*" )")"
echo""
center_text "$(color_text "bg_bright_black" " Hardwarová platforma stroje")"
center_text "$(color_text "bg_white" "\e[0m $(uname -i)")"
echo""
center_text "$(color_text "bg_bright_black" " Typ procesoru")"
center_text "$(color_text "bg_bright_black" "\e[0m $(uname -p)")"
echo""
center_text "$(color_text "bg_blue" " procesor")"
center_text "$(color_text "bg_blue" "\e[0m $(grep "model name" /proc/cpuinfo | cut -d ' ' -f 3- | uniq)")"
echo""
center_text "$(color_text "bg_blue" " CPU jádra")"
center_text "$(color_text "bg_blue" "\e[0m $(awk '/^cpu cores/ {print $4; exit}' /proc/cpuinfo)")"
echo""
center_text "$(color_text "bg_blue" " CPU vlákna")"
center_text "$(color_text "bg_blue" "\e[0m $(awk '/^processor/ {count++} END {print count}' /proc/cpuinfo)")"
echo""
center_text "$(color_text "bg_blue" " Otáčky ventilátoru")"
center_text "$(color_text "bg_blue" "\e[0m$(sensors | grep -i 'fan' | awk '{print " ", $1, $2, $3, $4}')")"
echo""
if command -v sensors &> /dev/null; then
center_text "$(color_text "bg_bright_blue" " Teplota CPU")"
# Collect all lines containing "Core" from sensors output
echo ""
core_lines=$(sensors | grep "Core")
# Iterate over each line and center it
while IFS= read -r line; do
center_text "$(color_text "bg_red" "$line")"
done <<< "$core_lines"
else
center_text "$(color_text "bg_red" " Teplota CPU: Není dostupný (lm_sensors not installed)")"
fi
echo ""
center_text "$(color_text "bg_bright_black" " GPU")"
center_text "$(color_text "bg_bright_black" "\e[0m $(lspci | grep VGA | cut -d ':' -f 3 | cut -d '[' -f 1,2 | sed 's/^ *//')")"
echo""
if ! command -v sensors &> /dev/null; then
center_text "$(color_text "red" "lmsensory nejsou nainstalovány")"
else
gpu_temp=$(sensors | grep -i 'gpu')
if [ -z "$gpu_temp" ]; then
center_text "$(color_text "bg_bright_red" " Nejsou k dispozici žádné údaje o teplotě GPU")"
else
center_text "$(color_text "bg_bright_black" " Teploty GPU:" "$gpu_temp")"
fi
fi
echo ""
center_text "$(color_text "bg_bright_magenta" " Paměť: ($memory_percentage) ($memory_usage)")"
echo""
center_text "$(color_text "bg_bright_magenta" " Swap: ($swap_percentage) ($swap_usage)")"
echo""
local disk_usage=$(df -h / | awk 'NR==2 {print "(" $5 " used) " $3 "/" $2 }')
center_text "$(color_text "bg_bright_black" " Využití disku: ${disk_usage}")"
echo""
local battery_info=$(upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to full|percentage")
center_text "$(color_text "bg_bright_black" " baterie:")"
while IFS= read -r line; do
center_text "$line"
done <<< "$battery_info"
echo""
center_text "$(color_text "bg_cyan" " Nejlepší procesy podle využití CPU")"
ps -eo pid,%cpu,%mem,cmd --sort=-%cpu | head -n 11 | while IFS= read -r line; do
center_text "$line"
done
echo ""
center_text "$(color_text "bg_cyan" " Nejlepší procesy podle využití paměti")"
ps -eo pid,%cpu,%mem,cmd --sort=-%mem | head -n 11 | while IFS= read -r line; do
center_text "$line"
done
echo ""
center_text "$(color_text "bg_yellow" " Statistika I/O disku")"
local io_stats=$(iostat)
while IFS= read -r line; do
center_text "$line"
done <<< "$io_stats"
echo ""
center_text "$(color_text "bg_bright_black" " Namontované disky")"
echo ""
local header="$(color_text "bg_blue" " Filesystem Size Used Use%")"
center_text "$header"
local drives=$(df -h | awk 'NR>1 {printf " %-30s %-10s %-10s %-10s\n", $1, $2, $3, $5}')
while IFS= read -r line; do
center_text "$line"
done <<< "$drives"
echo""
# [Additional functionalities enable manually not translated to Czech language]
# [network]
#Display Network Interfaces
# center_text "$(color_text "bg_yellow" " Síťová rozhraní:")"
# ip addr show | sed 's/^/ /'
#echo""
# [gpu]
# Display GPU temperatures for Nvidia, AMD, and Intel GPUs if available
# center_text "$(color_text "bg_yellow" " Teploty GPU:")"
# Check and display Nvidia GPU temperature
# if command -v nvidia-smi &> /dev/null; then
# center_text "$(color_text "bg_yellow" " Nvidia:")"
# nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader | awk '{print " ", $1, "°C"}'
# fi
# Check and display AMD GPU temperature
# if command -v radeontop &> /dev/null; then
# center_text "$(color_text "bg_yellow" " AMD:")"
# radeontop -l1 | grep "Temperature" | sed 's/^/ /'
# fi
# Check and display Intel GPU temperature
# if command -v intel_gpu_top &> /dev/null; then
# center_text "$(color_text "bg_yellow" " Intel:")"
# intel_gpu_top -s 1 | awk '/Rendering/ {print " ", $7, "°C"}'
# fi
# [uptime]
# Display Uptime
# center_text "$(color_text "bg_yellow" " Doba provozuschopnosti:") $(uptime)"
#echo ""
# [shell]
# Display Shell
# center_text "$(color_text "bg_green" " Shell:") $SHELL"
# [firewall]
# Display Firewall Information requires password
#center_text "$(color_text "bg_yellow" " Informace o bráně firewall:")"
#center_text "$(color_text "bg_yellow" " UFW Stav:")"
#ufw status verbose | sed 's/^/ /' # Upravte formát podle potřeby pro výstup vašeho systému
#center_text "$(color_text "bg_yellow" " Pravidla IPTtables:")"
#iptables -L -v -n | sed 's/^/ /' # upravte formát podle potřeby pro výstup vašeho systému
#center_text "$(color_text "bg_yellow" " Firewallové zóny a služby:")"
#firewall-cmd --list-all-zones | sed 's/^/ /' # Upravte formát podle potřeby pro výstup vašeho systému
#center_text "$(color_text "bg_yellow" " Pravidla Nftables:")"
#nft list ruleset | sed 's/^/ /' # Upravte formát podle potřeby pro výstup vašeho systému
# [resolution]
# Display Resolution
# center_text "$(color_text "bg_yellow" " Rozlišení")"
# center_text "$(color_text "bg_yellow" "\e[0m $(hwinfo --monitor)")"
# echo""
}
# Function to display a random quote
display_quote() {
quotes=(
"Talk is cheap. Show me the code. - Linus Torvalds"
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program. - Linus Torvalds"
"Free software is software that respects your freedom and the social solidarity of your community. So it's free as in freedom. - Richard Stallman"
"Control over the use of one's ideas really constitutes control over other people's lives; and it is usually used to make their lives more difficult. - Richard Stallman"
"Given enough eyeballs, all bugs are shallow. - Eric S. Raymond"
"The next best thing to having good ideas is recognizing good ideas from your users. Sometimes the latter is better. - Eric S. Raymond"
"The Web as I envisaged it, we have not seen it yet. The future is still so much bigger than the past. - Tim Berners-Lee"
"The only way to make software secure, reliable, and fast is to put it out in the public domain and let people attack it, play with it, and break it. - Brian Behlendorf"
"I believe that openness is the key to creativity and innovation. - Mitchell Baker"
"May the Force be with you. -Star Wars (many characters)"
"Knowledge is power. -Sir Francis Bacon"
"Information flow is what the Internet is about. Information sharing is power. If you dont share your ideas smart people cant do anything about them and your all remain anonymous and powerless. -Vint cerf"
"When we have welcoming communities of contributors, open source software gets better and more useful to everyone. -Limor Fried"
"Open source is about collaborating; not competing. -Kelesey Hightower"
)
random_index=$((RANDOM % ${#quotes[@]}))
center_text "$(color_text "bg_cyan" "Random Quote: ${quotes[$random_index]}")"
echo""
}
# Function to display a random programming joke
display_joke() {
jokes=(
"Why do programmers prefer dark mode? Because light attracts bugs!"
"There are 10 types of people in the world: those who understand binary and those who don't."
"A SQL statement walks into a bar and sees two tables. It approaches, and asks, 'May I join you?'"
"Why do Java developers wear glasses? Because they don't see sharp."
"How many programmers does it take to change a light bulb? None. It's a hardware problem."
"your mama so fat 32 she cant store file over 4 GB"
"your mama so ugly she turn sdd into flopy"
"Knock, knock. Who’s There? Very long pause… Java."
"Things aren’t always #000000 and #FFFFFF"
"Why do Java programmers have to wear glasses? Because they don’t C#"
"There’s no place like 127.0.0.1"
"My love for you has no bugs"
"Real programmers count from 0"
"while (alive) { eat(); sleep (); code ();}"
"Binary: It’s as easy as 01, 10, 11"
)
random_index=$((RANDOM % ${#jokes[@]}))
center_text "$(color_text "bg_magenta" "Joke of the Day: ${jokes[$random_index]}")"
echo""
}
# Function to display a random fun fact
display_fun_fact() {
facts=(
"The first computer bug was an actual bug: a moth stuck in a Harvard Mark II in 1947."
"The first 1GB hard drive, announced in 1980, weighed over 500 pounds and cost 40000."
"The first computer virus was created in 1983 by Fred Cohen as part of his PhD thesis."
"The first programming language was Ada Lovelace's algorithm for Charles Babbage's Analytical Engine."
"The first webcam was used to monitor a coffee pot at the University of Cambridge."
"The first computer mouse was made of wood."
"The Firefox logo isnt a fox. is Red panda."
"Nintendo made playing cards."
"As of 2017, 2.1 millions people still use dial up."
"Google's First Tweet was in binary"
"Motorola produced the first handheld mobile phone."
"YouTube uploads 72 hours of video every single minute. "
"The First Computer Weighed More Than 24,493.988 KG/27 Tons."
"The C Language was not called C at the beginning"
)
random_index=$((RANDOM % ${#facts[@]}))
center_text "$(color_text "bg_yellow" "Fun Fact: ${facts[$random_index]}")"
echo""
}
get_package_count() {
local package_count="N/A"
if command -v dpkg >/dev/null 2>&1; then
pkgs=$(dpkg -l | grep '^ii' | wc -l)
source="(dpkg)"
elif command -v pacman >/dev/null 2>&1; then
pkgs=$(pacman -Q | wc -l)
source="(pacman)"
elif command -v equo >/dev/null 2>&1; then
pkgs=$(equo query list installed -q | wc -l)
source="(equo)"
elif command -v eopkg >/dev/null 2>&1; then
pkgs=$(eopkg list-installed | wc -l)
source="(eopkg)"
elif command -v tce-status >/dev/null 2>&1; then
pkgs=$(tce-status -i | wc -l)
source="(tce-status)"
elif command -v apk >/dev/null 2>&1; then
pkgs=$(apk info | wc -l)
source="(apk)"
elif command -v xbps-query >/dev/null 2>&1; then
pkgs=$(xbps-query -l | wc -l)
source="(xbps-query)"
elif command -v emerge >/dev/null 2>&1; then
pkgs=$(qlist -I | wc -l)
source="(emerge)"
elif command -v rpm >/dev/null 2>&1; then
pkgs=$(rpm -qa | wc -l)
source="(rpm)"
fi
echo "$pkgs" "$source"
}
# Function to get information about various gnome themes
get_theme_info() {
local gtk_theme icon_theme cursor_theme shell_theme
# Get GTK theme
gtk_theme=$(gsettings get org.gnome.desktop.interface gtk-theme 2>/dev/null)
gtk_theme="${gtk_theme//\'/}" # Remove single quotes from the output
# Get icon theme
icon_theme=$(gsettings get org.gnome.desktop.interface icon-theme 2>/dev/null)
icon_theme="${icon_theme//\'/}" # Remove single quotes from the output
# Get cursor theme
cursor_theme=$(gsettings get org.gnome.desktop.interface cursor-theme 2>/dev/null)
cursor_theme="${cursor_theme//\'/}" # Remove single quotes from the output
# Display themes using center_text function
center_text "$(color_text "bg_red" "GTK Theme: $gtk_theme")"
echo""
center_text "$(color_text "bg_green" "Icon Theme: $icon_theme")"
echo""
center_text "$(color_text "bg_blue" "Cursor Theme: $cursor_theme")"
}
# Easter egg for ASUSTeK model
get_model() {
model=$(cat /sys/devices/virtual/dmi/id/board_{name,vendor} | awk '!(NR%2){print$1,p}{p=$0}')
if [[ "$model" == *"ASUSTeK"* ]]; then
echo ""
center_text "$(color_text "bg_bright_black" "Asus more like ASSUS")"
fi
echo""
}
#stuff about the program
sysi-info() {
center_text "$(color_text "bg_bright_black" "Jazyk")"
echo ""
center_text "$(color_text "bg_bright_blue" "čeština")"
echo ""
center_text "$(color_text "bg_bright_black" "sysi verze")"
echo ""
center_text "$(color_text "bg_bright_blue" "1.0.3")"
echo ""
center_text "$(color_text "bg_bright_black" "vývojář")"
echo ""
center_text "$(color_text "bg_bright_blue" "hlavní vývojář stuffbymax")"
}
# Main function to display output
main() {
clear
display_logo
display_info
get_theme_info
get_model
display_quote
display_joke
display_fun_fact
}
# Execute main function
main