diff --git a/NoiceGRUB.py b/NoiceGRUB.py index 9b38921..8daea67 100644 --- a/NoiceGRUB.py +++ b/NoiceGRUB.py @@ -11,17 +11,24 @@ from rich.panel import Panel import os +init() console = Console() richprint(Panel("[cyan bold]" + banner + "[/cyan bold]",width=65,border_style="cyan")) table,preset_dict = preset_table() console.print(table) richprint("[cyan bold][ 0 ][/cyan bold] [green bold]Instructions for creating a preset[/green bold]") +richprint("[cyan bold][ 99 ][/cyan bold] [green bold]Remove installed NoiceGRUB theme[/green bold]") -choice = IntPrompt.ask("[yellow]Choice[/yellow]",choices=[str(i) for i in range(len(preset_dict)+1)]) +choice = IntPrompt.ask("[yellow]Choice[/yellow]",choices=gen_choices(preset_dict)) if choice == 0: console.print(Markdown(open('noicegrub/createpreset.md').read())) exit() +elif choice == 99: + richprint('\n[green bold]Executing scripts/remove.sh ... [/green bold]') + os.system('sudo ./scripts/remove.sh') + richprint('[green bold]Done[/green bold]') + exit() print() preset = get_preset(preset_dict[choice]) @@ -50,6 +57,5 @@ choice = Confirm.ask("[yellow bold]Would you like to install the theme ?[/yellow bold]") if choice: richprint('\n[green bold]Executing scripts/install.sh ... [/green bold]') - os.system('chmod +x ./scripts/install.sh') os.system('sudo ./scripts/install.sh') richprint('[green bold]Done[/green bold]') \ No newline at end of file diff --git a/noicegrub/__init__.py b/noicegrub/__init__.py index ce4b66b..d9240a7 100644 --- a/noicegrub/__init__.py +++ b/noicegrub/__init__.py @@ -5,6 +5,15 @@ def get_preset(name): data=toml.load(open(f'./presets/{name}.toml')) return [data[i] for i in data] +def gen_choices(presetDict): + ch_list = [str(i) for i in range(len(presetDict)+1)] + ch_list.append('99') + return ch_list + +def init(): + os.system('chmod +x ./scripts/functions.sh') + os.system('chmod +x ./scripts/install.sh') + os.system('chmod +x ./scripts/remove.sh') #================= rich tables def preset_table(): @@ -56,4 +65,4 @@ def gen_font_name(font_name,size): 8 `b8 8 8 8 8 . 8. 8 8 8 8 8 8 8 8 8 `8 `YooP' 8 `YooP' `Yooo' `YooP8 8 8 `YooP' 8oooP' ..:::..:.....::..:.....::.....::....8 :..:::..:.....::......: -:::::::: @1337kid ::::::::::::::::::8 :::::::: v2.0 :::::::::\n''' \ No newline at end of file +:::::::: @1337kid ::::::::::::::::::8 :::::::: v2.0.1 :::::::\n''' \ No newline at end of file diff --git a/scripts/functions.sh b/scripts/functions.sh new file mode 100755 index 0000000..5b0b302 --- /dev/null +++ b/scripts/functions.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +check_uid() { + if [[ $(id -u) != "0" ]] + then + printf "\033[91mCurrent user does not have root perms\n" + exit + fi +} + +update_grub_func() { + if [[ $(which dnf) != "" ]];then + fedora_version=$(cat /etc/fedora-release | awk '{print $3}') + if [[ fedora_version -gt 34 ]];then + grub2-mkconfig -o /boot/grub2/grub.cfg + else + grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg + fi + else + update-grub + fi +} + +get_path() { + if [[ -d "/boot/grub2" ]]; then + GRUB_PATH='/boot/grub2/' + elif [[ -d "/boot/grub" ]]; then + GRUB_PATH='/boot/grub/' + elif [[ -d "/boot/efi/EFI/fedora" ]]; then + GRUB_PATH='/boot/efi/EFI/fedora/' + fi +} diff --git a/scripts/install.sh b/scripts/install.sh index 98dd034..5c4cdcb 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,17 +1,9 @@ #!/bin/bash GRUB_PATH='' -THEMES_PATH='' +THEME_PATH='' -get_path() { - if [[ -d "/boot/grub2" ]]; then - GRUB_PATH='/boot/grub2/' - elif [[ -d "/boot/grub" ]]; then - GRUB_PATH='/boot/grub/' - elif [[ -d "/boot/efi/EFI/fedora" ]]; then - GRUB_PATH='/boot/efi/EFI/fedora/' - fi -} +source ./scripts/functions.sh makefont() { font=$(ls ./export | grep -E '.ttf|.otf') @@ -42,16 +34,7 @@ install() { #========= GRUB update # printf "\033[92m[+] \033[94mUpdating GRUB config\n\033[92m" - if [[ $(which dnf) != "" ]];then - fedora_version=$(cat /etc/fedora-release | awk '{print $3}') - if [[ fedora_version -gt 34 ]];then - grub2-mkconfig -o /boot/grub2/grub.cfg - else - grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg - fi - else - update-grub - fi + update_grub_func } #========================= @@ -66,14 +49,9 @@ cat </dev/null +#===== grub config +sed -i 's/.*GRUB_THEME=.*//' /etc/default/grub +sed -i 's/.*GRUB_FONT=.*//' /etc/default/grub +#===== +printf "\033[92m[+] \033[94mUpdating GRUB config\n\033[92m" +update_grub_func \ No newline at end of file