Skip to content

Commit

Permalink
Merge pull request #9 from 1337kid/dev
Browse files Browse the repository at this point in the history
v2.0.1 - Bug fixes & remove theme feature
  • Loading branch information
1337kid committed Jan 11, 2024
2 parents 1e71d89 + e06e835 commit 2d3dc09
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 30 deletions.
10 changes: 8 additions & 2 deletions NoiceGRUB.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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]')
11 changes: 10 additions & 1 deletion noicegrub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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'''
:::::::: @1337kid ::::::::::::::::::8 :::::::: v2.0.1 :::::::\n'''
32 changes: 32 additions & 0 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 5 additions & 27 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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
}
#=========================

Expand All @@ -66,14 +49,9 @@ cat <<EOF
EOF

if [[ $(id -u) != "0" ]]
then
printf "\033[91mCurrent user does not have root perms\n"
exit
fi

check_uid
get_path
THEME_PATH=$GRUB_PATH"themes/noicegrub"
printf "\033[1m\033[93m"
echo "Generated theme will be placed in $THEMES_PATH"
echo "Generated theme will be placed in $THEME_PATH"
install
18 changes: 18 additions & 0 deletions scripts/remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

GRUB_PATH=''

source ./scripts/functions.sh

printf "\033[1m"
check_uid
get_path
THEME_PATH=$GRUB_PATH"themes/noicegrub"
printf "\033[92m[+] \033[94mRemoving NoiceGRUB theme\n\033[92m"
rm -rf $THEME_PATH 2>/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

0 comments on commit 2d3dc09

Please sign in to comment.