Skip to content

Commit 2d3dc09

Browse files
authored
Merge pull request #9 from 1337kid/dev
v2.0.1 - Bug fixes & remove theme feature
2 parents 1e71d89 + e06e835 commit 2d3dc09

File tree

5 files changed

+73
-30
lines changed

5 files changed

+73
-30
lines changed

NoiceGRUB.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,24 @@
1111
from rich.panel import Panel
1212
import os
1313

14+
init()
1415
console = Console()
1516

1617
richprint(Panel("[cyan bold]" + banner + "[/cyan bold]",width=65,border_style="cyan"))
1718
table,preset_dict = preset_table()
1819
console.print(table)
1920
richprint("[cyan bold][ 0 ][/cyan bold] [green bold]Instructions for creating a preset[/green bold]")
21+
richprint("[cyan bold][ 99 ][/cyan bold] [green bold]Remove installed NoiceGRUB theme[/green bold]")
2022

21-
choice = IntPrompt.ask("[yellow]Choice[/yellow]",choices=[str(i) for i in range(len(preset_dict)+1)])
23+
choice = IntPrompt.ask("[yellow]Choice[/yellow]",choices=gen_choices(preset_dict))
2224
if choice == 0:
2325
console.print(Markdown(open('noicegrub/createpreset.md').read()))
2426
exit()
27+
elif choice == 99:
28+
richprint('\n[green bold]Executing scripts/remove.sh ... [/green bold]')
29+
os.system('sudo ./scripts/remove.sh')
30+
richprint('[green bold]Done[/green bold]')
31+
exit()
2532

2633
print()
2734
preset = get_preset(preset_dict[choice])
@@ -50,6 +57,5 @@
5057
choice = Confirm.ask("[yellow bold]Would you like to install the theme ?[/yellow bold]")
5158
if choice:
5259
richprint('\n[green bold]Executing scripts/install.sh ... [/green bold]')
53-
os.system('chmod +x ./scripts/install.sh')
5460
os.system('sudo ./scripts/install.sh')
5561
richprint('[green bold]Done[/green bold]')

noicegrub/__init__.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ def get_preset(name):
55
data=toml.load(open(f'./presets/{name}.toml'))
66
return [data[i] for i in data]
77

8+
def gen_choices(presetDict):
9+
ch_list = [str(i) for i in range(len(presetDict)+1)]
10+
ch_list.append('99')
11+
return ch_list
12+
13+
def init():
14+
os.system('chmod +x ./scripts/functions.sh')
15+
os.system('chmod +x ./scripts/install.sh')
16+
os.system('chmod +x ./scripts/remove.sh')
817

918
#================= rich tables
1019
def preset_table():
@@ -56,4 +65,4 @@ def gen_font_name(font_name,size):
5665
8 `b8 8 8 8 8 . 8. 8 8 8 8 8 8 8 8
5766
8 `8 `YooP' 8 `YooP' `Yooo' `YooP8 8 8 `YooP' 8oooP'
5867
..:::..:.....::..:.....::.....::....8 :..:::..:.....::......:
59-
:::::::: @1337kid ::::::::::::::::::8 :::::::: v2.0 :::::::::\n'''
68+
:::::::: @1337kid ::::::::::::::::::8 :::::::: v2.0.1 :::::::\n'''

scripts/functions.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
check_uid() {
4+
if [[ $(id -u) != "0" ]]
5+
then
6+
printf "\033[91mCurrent user does not have root perms\n"
7+
exit
8+
fi
9+
}
10+
11+
update_grub_func() {
12+
if [[ $(which dnf) != "" ]];then
13+
fedora_version=$(cat /etc/fedora-release | awk '{print $3}')
14+
if [[ fedora_version -gt 34 ]];then
15+
grub2-mkconfig -o /boot/grub2/grub.cfg
16+
else
17+
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
18+
fi
19+
else
20+
update-grub
21+
fi
22+
}
23+
24+
get_path() {
25+
if [[ -d "/boot/grub2" ]]; then
26+
GRUB_PATH='/boot/grub2/'
27+
elif [[ -d "/boot/grub" ]]; then
28+
GRUB_PATH='/boot/grub/'
29+
elif [[ -d "/boot/efi/EFI/fedora" ]]; then
30+
GRUB_PATH='/boot/efi/EFI/fedora/'
31+
fi
32+
}

scripts/install.sh

+5-27
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
#!/bin/bash
22

33
GRUB_PATH=''
4-
THEMES_PATH=''
4+
THEME_PATH=''
55

6-
get_path() {
7-
if [[ -d "/boot/grub2" ]]; then
8-
GRUB_PATH='/boot/grub2/'
9-
elif [[ -d "/boot/grub" ]]; then
10-
GRUB_PATH='/boot/grub/'
11-
elif [[ -d "/boot/efi/EFI/fedora" ]]; then
12-
GRUB_PATH='/boot/efi/EFI/fedora/'
13-
fi
14-
}
6+
source ./scripts/functions.sh
157

168
makefont() {
179
font=$(ls ./export | grep -E '.ttf|.otf')
@@ -42,16 +34,7 @@ install() {
4234
#========= GRUB update
4335
#
4436
printf "\033[92m[+] \033[94mUpdating GRUB config\n\033[92m"
45-
if [[ $(which dnf) != "" ]];then
46-
fedora_version=$(cat /etc/fedora-release | awk '{print $3}')
47-
if [[ fedora_version -gt 34 ]];then
48-
grub2-mkconfig -o /boot/grub2/grub.cfg
49-
else
50-
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
51-
fi
52-
else
53-
update-grub
54-
fi
37+
update_grub_func
5538
}
5639
#=========================
5740

@@ -66,14 +49,9 @@ cat <<EOF
6649
6750
EOF
6851

69-
if [[ $(id -u) != "0" ]]
70-
then
71-
printf "\033[91mCurrent user does not have root perms\n"
72-
exit
73-
fi
74-
52+
check_uid
7553
get_path
7654
THEME_PATH=$GRUB_PATH"themes/noicegrub"
7755
printf "\033[1m\033[93m"
78-
echo "Generated theme will be placed in $THEMES_PATH"
56+
echo "Generated theme will be placed in $THEME_PATH"
7957
install

scripts/remove.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
GRUB_PATH=''
4+
5+
source ./scripts/functions.sh
6+
7+
printf "\033[1m"
8+
check_uid
9+
get_path
10+
THEME_PATH=$GRUB_PATH"themes/noicegrub"
11+
printf "\033[92m[+] \033[94mRemoving NoiceGRUB theme\n\033[92m"
12+
rm -rf $THEME_PATH 2>/dev/null
13+
#===== grub config
14+
sed -i 's/.*GRUB_THEME=.*//' /etc/default/grub
15+
sed -i 's/.*GRUB_FONT=.*//' /etc/default/grub
16+
#=====
17+
printf "\033[92m[+] \033[94mUpdating GRUB config\n\033[92m"
18+
update_grub_func

0 commit comments

Comments
 (0)