summarylogtreecommitdiffstats
path: root/prtx-mutator-en
blob: 4783e60e140dd953ec941f3368d28c68a78f9046 (plain)
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
#!/usr/bin/env bash

THEMES_PER_PAGE=9
GRUB_CONFIG="/etc/default/grub"
GRUB_THEMES_DIR="/usr/share/grub/themes"

RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
CYAN='\033[1;36m'
MAGENTA='\033[1;35m'
BOLD='\033[1m'
DIM='\033[2m'
NC='\033[0m'

show_logo() {
    echo -e "${CYAN}${BOLD}"
    cat <<'EOF'
               ██████╗ ██████╗ ████████╗██╗  ██╗
               ██╔══██╗██╔══██╗╚══██╔══╝╚██╗██╔╝
               ██████╔╝██████╔╝   ██║    ╚███╔╝ 
               ██╔═══╝ ██╔══██╗   ██║    ██╔██╗ 
               ██║     ██║  ██║   ██║   ██╔╝ ██╗
               ╚═╝     ╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═╝
          ,--,                                         
        ,---.'|                                        
        |   | :                                        
        :   : |                ,---,                   
        |   ' :              ,---.'|                   
        ;   ; '              |   | :     .--.--.       
        '   | |__   ,--.--.  :   : :    /  /    '      
        |   | :.'| /       \ :     |,-.|  :  /`./      
        '   :    ;.--.  .-. ||   : '  ||  :  ;_        
        |   |  ./  \__\/: . .|   |  / : \  \    `.     
        ;   : ;    ," .--.; |'   : |: |  `----.   \    
        |   ,/    /  /  ,.  ||   | '/ : /  /`--'  /__  
        '---'    ;  :   .'   \   :    |'--'.     /  .\ 
                |  ,     .-./    \  /   `--'---'\  ; | 
                 `--`---'   `-'----'             `--"  
EOF
    echo -e "${NC}"
    echo -e "${DIM}${CYAN}            ═══════════════════════════════════════${NC}"
    echo -e "${MAGENTA}${BOLD}                          GRUB Mutator${NC}"
    echo -e "${DIM}${CYAN}            ═══════════════════════════════════════${NC}"
    echo ""
}

get_installed_themes() {
    if [ ! -d "$GRUB_THEMES_DIR" ]; then
        echo -e "${RED}Directory $GRUB_THEMES_DIR not found${NC}"
        return 1
    fi
    
    themes=("default")
    while IFS= read -r theme; do
        themes+=("$theme")
    done < <(find "$GRUB_THEMES_DIR" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort)
}

get_current_theme() {
    current_theme="default"
    if [ -f "$GRUB_CONFIG" ]; then
        local theme_path=$(grep "^GRUB_THEME=" "$GRUB_CONFIG" 2>/dev/null | cut -d'"' -f2)
        if [ -n "$theme_path" ]; then
            current_theme=$(echo "$theme_path" | sed 's|/theme\.txt$||' | xargs basename)
        fi
    fi
}

show_page() {
    local page=$1
    local start_idx=$((page * THEMES_PER_PAGE))
    local end_idx=$((start_idx + THEMES_PER_PAGE))
    local total_pages=$(( (${#themes[@]} + THEMES_PER_PAGE - 1) / THEMES_PER_PAGE ))
    
    clear
    show_logo
    
    echo -e "${CYAN}╔══════════════════════════════════════════════════════════════╗${NC}"
    echo -e "${CYAN}║${NC}  ${BOLD}Active Theme:${NC} ${GREEN}${BOLD}$current_theme${NC}$(printf '%*s' $((46 - ${#current_theme})) '')${CYAN}║${NC}"
    echo -e "${CYAN}║${NC}  ${DIM}Page ${MAGENTA}${BOLD}$((page + 1))${NC}${DIM}/${MAGENTA}${BOLD}$total_pages${NC}$(printf '%*s' 52 '')${CYAN}║${NC}"
    echo -e "${CYAN}╠══════════════════════════════════════════════════════════════╣${NC}"
    echo ""
    
    local display_num=1
    for i in $(seq $start_idx $((end_idx - 1))); do
        if [ $i -lt ${#themes[@]} ]; then
            local theme="${themes[$i]}"
            local display_name="$theme"
            [ "$theme" = "default" ] && display_name="◈ No Theme"
            
            if [ "$theme" = "$current_theme" ]; then
                echo -e "   ${GREEN}${BOLD}[$display_num]${NC} ${GREEN}●${NC} ${BOLD}$display_name${NC} ${YELLOW}✓${NC}"
            else
                echo -e "   ${CYAN}[$display_num]${NC} ${DIM}○${NC} $display_name"
            fi
            ((display_num++))
        fi
    done
    
    echo ""
    echo -e "${CYAN}╠══════════════════════════════════════════════════════════════╣${NC}"
    
    if [ $total_pages -gt 1 ]; then
        echo -e "${CYAN}║${NC}  ${YELLOW}[\`]${NC} ${DIM}←${NC} Previous  ${YELLOW}[-]${NC} ${DIM}→${NC} Next$(printf '%*s' 34 '')${CYAN}║${NC}"
    fi
    
    echo -e "${CYAN}║${NC}  ${BLUE}[I]${NC} Install Themes  ${MAGENTA}[R]${NC} Reboot System$(printf '%*s' 23 '')${CYAN}║${NC}"
    echo -e "${CYAN}║${NC}  ${RED}[U]${NC} Uninstall All  ${RED}[Q]${NC} Quit$(printf '%*s' 33 '')${CYAN}║${NC}"
    echo -e "${CYAN}╚══════════════════════════════════════════════════════════════╝${NC}"
    echo ""
}

apply_theme() {
    local theme_name=$1
    
    if [ "$theme_name" = "default" ]; then
        echo ""
        echo -e "${MAGENTA}${BOLD}⚙${NC}  Reset to Default Theme"
        echo -e "${DIM}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
        
        sudo sed -i '/^GRUB_THEME=/d' "$GRUB_CONFIG"
        
        echo -e "${YELLOW}⟳${NC} Updating GRUB configuration..."
        sudo grub-mkconfig -o /boot/grub/grub.cfg > /dev/null 2>&1
        
        echo ""
        echo -e "${GREEN}${BOLD}✓${NC} Default theme applied!"
        echo -e "${YELLOW}⚠${NC}  ${DIM}Reboot your system to see the changes.${NC}"
        echo ""
        sleep 1.5
        return 0
    fi
    
    local theme_path="$GRUB_THEMES_DIR/$theme_name/theme.txt"
    
    if [ ! -f "$theme_path" ]; then
        echo -e "${RED}${BOLD}✗${NC} Theme file not found: ${DIM}$theme_path${NC}"
        sleep 1.5
        return 1
    fi
    
    echo ""
    echo -e "${MAGENTA}${BOLD}⚙${NC}  Applying Theme: ${CYAN}${BOLD}$theme_name${NC}"
    echo -e "${DIM}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
    
    sudo cp "$GRUB_CONFIG" "$GRUB_CONFIG.backup.$(date +%s)" 2>/dev/null || true
    
    if grep -q "^GRUB_THEME=" "$GRUB_CONFIG"; then
        sudo sed -i "s|^GRUB_THEME=.*|GRUB_THEME=\"$theme_path\"|" "$GRUB_CONFIG"
    else
        echo "GRUB_THEME=\"$theme_path\"" | sudo tee -a "$GRUB_CONFIG" > /dev/null
    fi
    
    echo -e "${YELLOW}⟳${NC} Updating GRUB configuration..."
    sudo grub-mkconfig -o /boot/grub/grub.cfg > /dev/null 2>&1
    
    echo ""
    echo -e "${GREEN}${BOLD}✓${NC} Theme ${CYAN}${BOLD}'$theme_name'${NC} successfully applied!"
    echo -e "${YELLOW}⚠${NC}  ${DIM}Reboot your system to see the changes.${NC}"
    echo ""
    sleep 1.5
}

install_menu() {
    while true; do
        clear
        show_logo
        
        echo -e "${CYAN}╔══════════════════════════════════════════════════════════════╗${NC}"
        echo -e "${CYAN}║${NC}  ${MAGENTA}${BOLD}GRUB THEMES INSTALLATION${NC}$(printf '%*s' 37 '')${CYAN}║${NC}"
        echo -e "${CYAN}╠══════════════════════════════════════════════════════════════╣${NC}"
        echo ""
        echo -e "   ${GREEN}${BOLD}[1]${NC} ${YELLOW}★${NC} Universal Collection"
        echo -e "   ${GREEN}${BOLD}[2]${NC} ${MAGENTA}◆${NC} Dark Side Collection ${DIM}(preferable)${NC}"
        echo ""
        echo -e "   ${CYAN}${BOLD}[3]${NC} Complete Collection ${DIM}(4K maximum)${NC}"
        echo -e "   ${CYAN}${BOLD}[4]${NC} Complete Collection ${DIM}(2K quality)${NC}"
        echo -e "   ${CYAN}${BOLD}[5]${NC} Complete Collection ${DIM}(1080p standard)${NC}"
        echo ""
        echo -e "   ${BLUE}${BOLD}[6]${NC} Widescreen Collection ${DIM}(Ultrawide 2K)${NC}"
        echo -e "   ${BLUE}${BOLD}[7]${NC} Widescreen Collection ${DIM}(Ultrawide 1K)${NC}"
        echo ""
        echo -e "   ${RED}${BOLD}[8]${NC} ${DIM}...they say installing everything is a bad idea...${NC}"
        echo ""
        echo -e "${CYAN}╠══════════════════════════════════════════════════════════════╣${NC}"
        echo -e "${CYAN}║${NC}  ${RED}[Q]${NC} Back$(printf '%*s' 52 '')${CYAN}║${NC}"
        echo -e "${CYAN}╚══════════════════════════════════════════════════════════════╝${NC}"
        echo ""
        echo -ne "${BOLD}Choice: ${NC}"
        
        IFS= read -rsn1 choice
        while read -r -t 0; do read -r -t 0.01; done
        
        case $choice in
            q|Q)
                return
                ;;
            1)
                echo ""
                echo -e "${YELLOW}Installing universal collection...${NC}"
                sudo pacman -S dracula-grub-theme-git catppuccin-mocha-grub-theme-git grub-theme-vimix-color-1080p-git grub-theme-whitesur-color-1080p-git grub-theme-tela-color-1080p-git grub-theme-stylish-color-1080p-git
                sleep 2
                ;;
            2)
                echo ""
                echo -e "${MAGENTA}Installing Dracula and Catppuccin collection...${NC}"
                sudo pacman -S dracula-grub-theme-git catppuccin-frappe-grub-theme-git catppuccin-latte-grub-theme-git catppuccin-macchiato-grub-theme-git catppuccin-mocha-grub-theme-git
                sleep 2
                ;;
            3)
                echo ""
                echo -e "${CYAN}Installing complete 4K collection...${NC}"
                sudo pacman -S grub-theme-stylish-color-4k-git grub-theme-stylish-white-4k-git grub-theme-stylish-whitesur-4k-git grub-theme-tela-color-4k-git grub-theme-tela-white-4k-git grub-theme-tela-whitesur-4k-git grub-theme-vimix-color-4k-git grub-theme-vimix-white-4k-git grub-theme-vimix-whitesur-4k-git grub-theme-whitesur-color-4k-git grub-theme-whitesur-white-4k-git grub-theme-whitesur-whitesur-4k-git
                sleep 2
                ;;
            4)
                echo ""
                echo -e "${CYAN}Installing complete 2K collection...${NC}"
                sudo pacman -S grub-theme-stylish-color-2k-git grub-theme-stylish-white-2k-git grub-theme-stylish-whitesur-2k-git grub-theme-tela-color-2k-git grub-theme-tela-white-2k-git grub-theme-tela-whitesur-2k-git grub-theme-vimix-color-2k-git grub-theme-vimix-white-2k-git grub-theme-vimix-whitesur-2k-git grub-theme-whitesur-color-2k-git grub-theme-whitesur-white-2k-git grub-theme-whitesur-whitesur-2k-git
                sleep 2
                ;;
            5)
                echo ""
                echo -e "${CYAN}Installing complete 1080p collection...${NC}"
                sudo pacman -S grub-theme-vimix grub-theme-stylish-color-1080p-git grub-theme-stylish-white-1080p-git grub-theme-stylish-whitesur-1080p-git grub-theme-tela-color-1080p-git grub-theme-tela-white-1080p-git grub-theme-tela-whitesur-1080p-git grub-theme-vimix-color-1080p-git grub-theme-vimix-white-1080p-git grub-theme-vimix-whitesur-1080p-git grub-theme-whitesur-color-1080p-git grub-theme-whitesur-white-1080p-git grub-theme-whitesur-whitesur-1080p-git
                sleep 2
                ;;
            6)
                echo ""
                echo -e "${BLUE}Installing Ultrawide 2K collection...${NC}"
                sudo pacman -S grub-theme-stylish-color-ultrawide2k-git grub-theme-stylish-white-ultrawide2k-git grub-theme-stylish-whitesur-ultrawide2k-git grub-theme-tela-color-ultrawide2k-git grub-theme-tela-white-ultrawide2k-git grub-theme-tela-whitesur-ultrawide2k-git grub-theme-vimix-color-ultrawide2k-git grub-theme-vimix-white-ultrawide2k-git grub-theme-vimix-whitesur-ultrawide2k-git
                sleep 2
                ;;
            7)
                echo ""
                echo -e "${BLUE}Installing Ultrawide 1K collection...${NC}"
                sudo pacman -S grub-theme-stylish-color-ultrawide-git grub-theme-stylish-white-ultrawide-git grub-theme-stylish-whitesur-ultrawide-git grub-theme-tela-color-ultrawide-git grub-theme-tela-white-ultrawide-git grub-theme-tela-whitesur-ultrawide-git grub-theme-vimix-color-ultrawide-git grub-theme-vimix-white-ultrawide-git grub-theme-vimix-whitesur-ultrawide-git
                sleep 2
                ;;
            8)
                echo ""
                echo -e "${RED}${BOLD}⚠ Serious Warning ⚠${NC}"
                echo ""
                echo -e "${DIM}Security log, entry #347:${NC}"
                echo -e "${YELLOW}Installing all available GRUB themes...${NC}"
                echo -e "${RED}May require significant disk space.${NC}"
                echo ""
                echo -ne "${BOLD}Enter '0' to confirm (1/5): ${NC}"
                IFS= read -rsn1 conf1
                while read -r -t 0; do read -r -t 0.01; done
                
                if [ "$conf1" != "0" ]; then
                    echo -e "${CYAN}Operation cancelled.${NC}"
                    sleep 1
                    continue
                fi
                
                echo ""
                echo -e "${DIM}Technical note:${NC}"
                echo -e "${RED}Disk overflow may cause boot failure.${NC}"
                echo -ne "${BOLD}Enter '1' to confirm (2/5): ${NC}"
                IFS= read -rsn1 conf2
                while read -r -t 0; do read -r -t 0.01; done
                
                if [ "$conf2" != "1" ]; then
                    echo -e "${CYAN}Operation cancelled.${NC}"
                    sleep 1
                    continue
                fi
                
                echo ""
                echo -e "${DIM}Installation statistics:${NC}"
                echo -e "${RED}Process may take considerable time.${NC}"
                echo -ne "${BOLD}Enter '2' to confirm (3/5): ${NC}"
                IFS= read -rsn1 conf3
                while read -r -t 0; do read -r -t 0.01; done
                
                if [ "$conf3" != "2" ]; then
                    echo -e "${CYAN}Operation cancelled.${NC}"
                    sleep 1
                    continue
                fi
                
                echo ""
                echo -e "${DIM}Pre-final check:${NC}"
                echo -e "${RED}Make sure you have at least 500MB free space.${NC}"
                echo -ne "${BOLD}Enter '3' to confirm (4/5): ${NC}"
                IFS= read -rsn1 conf4
                while read -r -t 0; do read -r -t 0.01; done
                
                if [ "$conf4" != "3" ]; then
                    echo -e "${CYAN}Operation cancelled.${NC}"
                    sleep 1
                    continue
                fi
                
                echo ""
                echo -e "${RED}${BOLD}FINAL CONFIRMATION${NC}"
                echo -e "${DIM}...but if you really want to, you can...${NC}"
                echo ""
                echo -ne "${BOLD}Type 'yes, i confirm this' or 'да, я подтверждаю это' (5/5): ${NC}"
                read -r final_conf
                
                if [ "$final_conf" != "yes, i confirm this" ] && [ "$final_conf" != "да, я подтверждаю это" ]; then
                    echo -e "${CYAN}Wise decision.${NC}"
                    sleep 1
                    continue
                fi
                
                echo ""
                echo -e "${YELLOW}Installing all GRUB themes...${NC}"
                sudo pacman -S $(pacman -Ssq grub-theme)
                sleep 2
                ;;
        esac
    done
}

reboot_system() {
    local r_count=0
    
    echo ""
    echo -e "${YELLOW}${BOLD}⚠ SYSTEM REBOOT ⚠${NC}"
    echo -e "${DIM}Press 'R' twice to confirm${NC}"
    echo ""
    
    while [ $r_count -lt 2 ]; do
        echo -ne "${BOLD}Confirmation ($(($r_count + 1))/2): ${NC}"
        IFS= read -rsn1 conf
        while read -r -t 0; do read -r -t 0.01; done
        
        if [ "$conf" = "r" ] || [ "$conf" = "R" ]; then
            ((r_count++))
            echo -e "${GREEN}✓${NC}"
        else
            echo -e "${RED}✗${NC}"
            echo -e "${CYAN}Reboot cancelled.${NC}"
            sleep 1
            return
        fi
    done
    
    echo ""
    echo -e "${GREEN}Rebooting system...${NC}"
    sleep 1
    sudo reboot
}

uninstall_all_themes() {
    echo ""
    echo -e "${RED}${BOLD}⚠ UNINSTALL ALL THEMES ⚠${NC}"
    echo -e "${DIM}Press 'U' to confirm${NC}"
    echo ""
    
    echo -ne "${BOLD}Confirmation: ${NC}"
    IFS= read -rsn1 conf
    while read -r -t 0; do read -r -t 0.01; done
    
    if [ "$conf" = "u" ] || [ "$conf" = "U" ]; then
        echo -e "${GREEN}✓${NC}"
    else
        echo -e "${RED}✗${NC}"
        echo -e "${CYAN}Uninstall cancelled.${NC}"
        sleep 1
        return
    fi
    
    echo ""
    echo -e "${YELLOW}Uninstalling all GRUB themes...${NC}"
    sudo pacman -Rns $(pacman -Qq | grep grub-theme) --noconfirm 2>/dev/null || true
    sudo sed -i '/^GRUB_THEME=/d' "$GRUB_CONFIG"
    sudo grub-mkconfig -o /boot/grub/grub.cfg > /dev/null 2>&1
    echo ""
    echo -e "${GREEN}${BOLD}✓${NC} All themes uninstalled!"
    echo ""
    sleep 1.5
}

main() {
    if [ "$EUID" -eq 0 ]; then
        echo -e "${RED}Do not run the script with root privileges directly!${NC}"
        echo -e "${YELLOW}The script will request sudo when needed.${NC}"
        exit 1
    fi
    
    get_installed_themes || exit 1
    get_current_theme
    
    local current_page=0
    local total_pages=$(( (${#themes[@]} + THEMES_PER_PAGE - 1) / THEMES_PER_PAGE ))
    
    while true; do
        show_page $current_page
        
        IFS= read -rsn1 choice
        while read -r -t 0; do read -r -t 0.01; done
        
        case $choice in
            q|Q)
                clear
                echo -e "${CYAN}Exiting...${NC}"
                exit 0
                ;;
            i|I)
                install_menu
                get_installed_themes
                get_current_theme
                current_page=0
                total_pages=$(( (${#themes[@]} + THEMES_PER_PAGE - 1) / THEMES_PER_PAGE ))
                ;;
            r|R)
                reboot_system
                ;;
            u|U)
                uninstall_all_themes
                get_installed_themes
                get_current_theme
                current_page=0
                total_pages=$(( (${#themes[@]} + THEMES_PER_PAGE - 1) / THEMES_PER_PAGE ))
                ;;
            '`'|'~')
                if [ $current_page -gt 0 ]; then
                    ((current_page--))
                fi
                ;;
            '-'|'_')
                if [ $((current_page + 1)) -lt $total_pages ]; then
                    ((current_page++))
                fi
                ;;
            [1-9])
                local num=$((choice))
                local start_idx=$((current_page * THEMES_PER_PAGE))
                local theme_idx=$((start_idx + num - 1))
                
                if [ $theme_idx -lt ${#themes[@]} ]; then
                    apply_theme "${themes[$theme_idx]}"
                    get_current_theme
                fi
                ;;
            0)
                local start_idx=$((current_page * THEMES_PER_PAGE))
                local theme_idx=$((start_idx + 9))
                
                if [ $theme_idx -lt ${#themes[@]} ]; then
                    apply_theme "${themes[$theme_idx]}"
                    get_current_theme
                fi
                ;;
        esac
    done
}

main