diff --git a/README.md b/README.md index a6e52dd..ec03b1c 100644 --- a/README.md +++ b/README.md @@ -4,25 +4,38 @@ Usage: `sudo ./install.sh [OPTIONS...]` -| Options: | Description: | -|:-----------------------|:-------------| -| -t, --theme | theme variant(s) [tela/vimix/stylish/whitesur] (default is tela)" -| -i, --icon | icon variant(s) [color/white/whitesur] (default is color)" -| -s, --screen | screen resolution variant(s) [1080p/2k/4k/ultrawide/ultrawide2k] (default is 1080p)" -| -r, --remove [THEME] | Uninstall selected theme | -| -h, --help | Show this help | +``` + -t, --theme theme variant(s) [tela|vimix|stylish|whitesur] (default is tela) + -i, --icon icon variant(s) [color|white|whitesur] (default is color) + -s, --screen screen display variant(s) [1080p|2k|4k|ultrawide|ultrawide2k] (default is 1080p) + -r, --remove Remove theme [tela|vimix|stylish|whitesur] (must add theme name option, default is tela) + + -b, --boot install theme into '/boot/grub' or '/boot/grub2' + -g, --generate do not install but generate theme into chosen directory (must add your directory) + + -h, --help Show this help +``` _If no options are used, a user interface `dialog` will show up instead_ ### Examples: - Install Tela theme on 2k display device: - - `sudo ./install.sh -t tela -s 2k` + +```sh +sudo ./install.sh -t tela -s 2k +``` - Install Tela theme into /boot/grub/themes: - - `sudo ./install.sh -b -t tela` + +```sh +sudo ./install.sh -b -t tela +``` - Uninstall Tela theme: - - `sudo ./install.sh -r -t tela` + +```sh +sudo ./install.sh -r -t tela +``` ## Issues / tweaks: @@ -37,7 +50,11 @@ _If no options are used, a user interface `dialog` will show up instead_ - Make sure you have `imagemagick` installed, or at least something that provides `convert` - Find the resolution of your display, and make sure your background matches the resolution - - (1920x1080 -> --1080p, 2560x1080 -> --ultrawide, 2560x1440 -> --2k, 3440x1440 -> --ultrawide2k, 3840x2160 -> --4k) + - 1920x1080 >> 1080p + - 2560x1080 >> ultrawide + - 2560x1440 >> 2k + - 3440x1440 >> ultrawide2k + - 3840x2160 >> 4k - Place your custom background inside the root of the project, and name it `background.jpg` - Run the installer like normal, but with -s `[YOUR_RESOLUTION]` and -t `[THEME]` and -i `[ICON]` - Make sure to replace `[YOUR_RESOLUTION]` with your resolution and `[THEME]` with the theme @@ -50,7 +67,6 @@ _If no options are used, a user interface `dialog` will show up instead_ - If any issues occur, report then to the [issue](https://github.com/vinceliuice/grub2-themes/issues) page ## Preview: -Images shown: tela/vimix/stylish/whitesur ![preview](preview.png?raw=true) ## Documents diff --git a/assets/assets-color/icons-1080p/archcraft.png b/assets/assets-color/icons-1080p/archcraft.png new file mode 100644 index 0000000..6db77a3 Binary files /dev/null and b/assets/assets-color/icons-1080p/archcraft.png differ diff --git a/assets/assets-color/icons-1080p/brunch-settings.png b/assets/assets-color/icons-1080p/brunch-settings.png new file mode 100644 index 0000000..223be0b Binary files /dev/null and b/assets/assets-color/icons-1080p/brunch-settings.png differ diff --git a/assets/assets-color/icons-1080p/brunch.png b/assets/assets-color/icons-1080p/brunch.png new file mode 100644 index 0000000..75769e5 Binary files /dev/null and b/assets/assets-color/icons-1080p/brunch.png differ diff --git a/assets/assets-color/icons-2k/archcraft.png b/assets/assets-color/icons-2k/archcraft.png new file mode 100644 index 0000000..c22c8aa Binary files /dev/null and b/assets/assets-color/icons-2k/archcraft.png differ diff --git a/assets/assets-color/icons-2k/brunch-settings.png b/assets/assets-color/icons-2k/brunch-settings.png new file mode 100644 index 0000000..3c43d25 Binary files /dev/null and b/assets/assets-color/icons-2k/brunch-settings.png differ diff --git a/assets/assets-color/icons-2k/brunch.png b/assets/assets-color/icons-2k/brunch.png new file mode 100644 index 0000000..1aa177c Binary files /dev/null and b/assets/assets-color/icons-2k/brunch.png differ diff --git a/assets/assets-color/icons-4k/archcraft.png b/assets/assets-color/icons-4k/archcraft.png new file mode 100644 index 0000000..f2c6801 Binary files /dev/null and b/assets/assets-color/icons-4k/archcraft.png differ diff --git a/assets/assets-color/icons-4k/brunch-settings.png b/assets/assets-color/icons-4k/brunch-settings.png new file mode 100644 index 0000000..948b057 Binary files /dev/null and b/assets/assets-color/icons-4k/brunch-settings.png differ diff --git a/assets/assets-color/icons-4k/brunch.png b/assets/assets-color/icons-4k/brunch.png new file mode 100644 index 0000000..ea6f7c9 Binary files /dev/null and b/assets/assets-color/icons-4k/brunch.png differ diff --git a/assets/assets-white/icons-1080p/archcraft.png b/assets/assets-white/icons-1080p/archcraft.png new file mode 100644 index 0000000..b33ded9 Binary files /dev/null and b/assets/assets-white/icons-1080p/archcraft.png differ diff --git a/assets/assets-white/icons-1080p/brunch-settings.png b/assets/assets-white/icons-1080p/brunch-settings.png new file mode 100644 index 0000000..ed04dcb Binary files /dev/null and b/assets/assets-white/icons-1080p/brunch-settings.png differ diff --git a/assets/assets-white/icons-1080p/brunch.png b/assets/assets-white/icons-1080p/brunch.png new file mode 100644 index 0000000..5d4f38f Binary files /dev/null and b/assets/assets-white/icons-1080p/brunch.png differ diff --git a/assets/assets-white/icons-2k/archcraft.png b/assets/assets-white/icons-2k/archcraft.png new file mode 100644 index 0000000..820618e Binary files /dev/null and b/assets/assets-white/icons-2k/archcraft.png differ diff --git a/assets/assets-white/icons-2k/brunch-settings.png b/assets/assets-white/icons-2k/brunch-settings.png new file mode 100644 index 0000000..685364d Binary files /dev/null and b/assets/assets-white/icons-2k/brunch-settings.png differ diff --git a/assets/assets-white/icons-2k/brunch.png b/assets/assets-white/icons-2k/brunch.png new file mode 100644 index 0000000..aef05dd Binary files /dev/null and b/assets/assets-white/icons-2k/brunch.png differ diff --git a/assets/assets-white/icons-4k/archcraft.png b/assets/assets-white/icons-4k/archcraft.png new file mode 100644 index 0000000..1b80697 Binary files /dev/null and b/assets/assets-white/icons-4k/archcraft.png differ diff --git a/assets/assets-white/icons-4k/brunch-settings.png b/assets/assets-white/icons-4k/brunch-settings.png new file mode 100644 index 0000000..23cb7fd Binary files /dev/null and b/assets/assets-white/icons-4k/brunch-settings.png differ diff --git a/assets/assets-white/icons-4k/brunch.png b/assets/assets-white/icons-4k/brunch.png new file mode 100644 index 0000000..d30fb1e Binary files /dev/null and b/assets/assets-white/icons-4k/brunch.png differ diff --git a/assets/assets-whitesur/icons-1080p/archcraft.png b/assets/assets-whitesur/icons-1080p/archcraft.png new file mode 100644 index 0000000..65f6157 Binary files /dev/null and b/assets/assets-whitesur/icons-1080p/archcraft.png differ diff --git a/assets/assets-whitesur/icons-1080p/brunch-settings.png b/assets/assets-whitesur/icons-1080p/brunch-settings.png new file mode 100644 index 0000000..30efa56 Binary files /dev/null and b/assets/assets-whitesur/icons-1080p/brunch-settings.png differ diff --git a/assets/assets-whitesur/icons-1080p/brunch.png b/assets/assets-whitesur/icons-1080p/brunch.png new file mode 100644 index 0000000..85f9f86 Binary files /dev/null and b/assets/assets-whitesur/icons-1080p/brunch.png differ diff --git a/assets/assets-whitesur/icons-2k/archcraft.png b/assets/assets-whitesur/icons-2k/archcraft.png new file mode 100644 index 0000000..3acb23d Binary files /dev/null and b/assets/assets-whitesur/icons-2k/archcraft.png differ diff --git a/assets/assets-whitesur/icons-2k/brunch-settings.png b/assets/assets-whitesur/icons-2k/brunch-settings.png new file mode 100644 index 0000000..130c8ce Binary files /dev/null and b/assets/assets-whitesur/icons-2k/brunch-settings.png differ diff --git a/assets/assets-whitesur/icons-2k/brunch.png b/assets/assets-whitesur/icons-2k/brunch.png new file mode 100644 index 0000000..8df452e Binary files /dev/null and b/assets/assets-whitesur/icons-2k/brunch.png differ diff --git a/assets/assets-whitesur/icons-4k/archcraft.png b/assets/assets-whitesur/icons-4k/archcraft.png new file mode 100644 index 0000000..e9ad927 Binary files /dev/null and b/assets/assets-whitesur/icons-4k/archcraft.png differ diff --git a/assets/assets-whitesur/icons-4k/brunch-settings.png b/assets/assets-whitesur/icons-4k/brunch-settings.png new file mode 100644 index 0000000..92e5a2e Binary files /dev/null and b/assets/assets-whitesur/icons-4k/brunch-settings.png differ diff --git a/assets/assets-whitesur/icons-4k/brunch.png b/assets/assets-whitesur/icons-4k/brunch.png new file mode 100644 index 0000000..769b88c Binary files /dev/null and b/assets/assets-whitesur/icons-4k/brunch.png differ diff --git a/assets/logos-color.svg b/assets/logos-color.svg index bd28689..2027c82 100644 --- a/assets/logos-color.svg +++ b/assets/logos-color.svg @@ -1,6 +1,6 @@ .cls-1{fill:#0097f4;}.cls-2{fill:#fff;} + id="circle1230" /> diff --git a/assets/logos-white.svg b/assets/logos-white.svg index f419664..4d0a880 100644 --- a/assets/logos-white.svg +++ b/assets/logos-white.svg @@ -1,6 +1,6 @@ + + + + + + + + + + + + + + + + diff --git a/assets/logos-whitesur.svg b/assets/logos-whitesur.svg index dd98a1e..d74c4d9 100644 --- a/assets/logos-whitesur.svg +++ b/assets/logos-whitesur.svg @@ -1,6 +1,6 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/logos.txt b/assets/logos.txt index c97211c..5c595d3 100644 --- a/assets/logos.txt +++ b/assets/logos.txt @@ -45,6 +45,8 @@ zorin nixos gpart ubuntuDDE +archcraft +brunch recovery restart @@ -62,3 +64,4 @@ type tz unset submenu +brunch-settings diff --git a/flake.nix b/flake.nix index 2c3258e..df45cb4 100644 --- a/flake.nix +++ b/flake.nix @@ -14,10 +14,12 @@ in with nixpkgs.lib; rec { - nixosModule = { config, ... }: + nixosModules.default = { config, ... }: let cfg = config.boot.loader.grub2-theme; splashImage = if cfg.splashImage == null then "" else cfg.splashImage; + hasBootMenuConfig = cfg.bootMenuConfig != null; + hasTerminalConfig = cfg.terminalConfig != null; resolutions = { "1080p" = "1920x1080"; "ultrawide" = "2560x1080"; @@ -37,11 +39,30 @@ --icon ${cfg.icon}; if [ -n "${splashImage}" ]; then - cp ${splashImage} $out/grub/themes/${cfg.theme}/background.jpg; + filename=$(basename -- "${splashImage}") + extension="''${filename##*.}" + rm $out/grub/themes/${cfg.theme}/background.jpg; + cp ${splashImage} $out/grub/themes/${cfg.theme}/background.$extension; + cp ${splashImage} $out/grub/themes/${cfg.theme}/background; + sed -i "s/background.jpg/background.$extension/g" $out/grub/themes/${cfg.theme}/theme.txt; fi; if [ ${pkgs.lib.trivial.boolToString cfg.footer} == "false" ]; then sed -i ':again;$!N;$!b again; s/\+ image {[^}]*}//g' $out/grub/themes/${cfg.theme}/theme.txt; fi; + if [ ${pkgs.lib.trivial.boolToString hasBootMenuConfig} == "true" ]; then + sed -i ':again;$!N;$!b again; s/\+ boot_menu {[^}]*}//g' $out/grub/themes/${cfg.theme}/theme.txt; + cat << EOF >> $out/grub/themes/${cfg.theme}/theme.txt + + boot_menu { + ${if cfg.bootMenuConfig == null then "" else cfg.bootMenuConfig} + } + EOF + fi; + if [ ${pkgs.lib.trivial.boolToString hasTerminalConfig} == "true" ]; then + sed -i 's/^terminal-.*$//g' $out/grub/themes/${cfg.theme}/theme.txt + cat << EOF >> $out/grub/themes/${cfg.theme}/theme.txt + ${if cfg.terminalConfig == null then "" else cfg.terminalConfig} + EOF + fi; ''; }; resolution = resolutions."${cfg.screen}"; @@ -86,7 +107,25 @@ example = "/my/path/background.jpg"; type = types.nullOr types.path; description = '' - The path of the image to use for background (must be jpg). + The path of the image to use for background (must be jpg or png). + ''; + }; + bootMenuConfig = mkOption { + default = null; + example = "left = 30%"; + type = types.nullOr types.string; + description = '' + Grub theme definition for boot_menu. + Refer to config/theme-*.txt for reference. + ''; + }; + terminalConfig = mkOption { + default = null; + example = "terminal-font: \"Terminus Regular 18\""; + type = types.nullOr types.string; + description = '' + Replaces grub theme definition for terminial-*. + Refer to config/theme-*.txt for reference. ''; }; footer = mkOption { @@ -103,17 +142,22 @@ environment.systemPackages = [ grub2-theme ]; - boot.loader.grub = { - theme = "${grub2-theme}/grub/themes/${cfg.theme}"; - splashImage = "${grub2-theme}/grub/themes/${cfg.theme}/background.jpg"; - gfxmodeEfi = "${resolution},auto"; - gfxmodeBios = "${resolution},auto"; - extraConfig = '' - insmod gfxterm - insmod png - set icondir=($root)/theme/icons - ''; - }; + boot.loader.grub = + let + ext = if cfg.splashImage == null then "jpg" else last (splitString "." cfg.splashImage); + in + { + theme = "${grub2-theme}/grub/themes/${cfg.theme}"; + splashImage = + "${grub2-theme}/grub/themes/${cfg.theme}/background.${ext}"; + gfxmodeEfi = "${resolution},auto"; + gfxmodeBios = "${resolution},auto"; + extraConfig = '' + insmod gfxterm + insmod png + set icondir=($root)/theme/icons + ''; + }; }]); }; }; diff --git a/install.sh b/install.sh index ee44220..9270792 100755 --- a/install.sh +++ b/install.sh @@ -57,17 +57,33 @@ function has_command() { } usage() { - printf "%s\n" "Usage: ${0##*/} [OPTIONS...]" - printf "\n%s\n" "OPTIONS:" - printf " %-25s%s\n" "-t, --theme" "theme variant(s) [tela|vimix|stylish|whitesur] (default is tela)" - printf " %-25s%s\n" "-i, --icon" "icon variant(s) [color|white|whitesur] (default is color)" - printf " %-25s%s\n" "-s, --screen" "screen display variant(s) [1080p|2k|4k|ultrawide|ultrawide2k] (default is 1080p)" - printf " %-25s%s\n" "-r, --remove" "Remove theme (must add theme name option)" - printf " %-25s%s\n" "-g, --generate" "do not install, but generate theme into chosen directory" - printf " %-25s%s\n" "-h, --help" "Show this help" +cat << EOF + +Usage: $0 [OPTION]... + +OPTIONS: + -t, --theme theme variant(s) [tela|vimix|stylish|whitesur] (default is tela) + -i, --icon icon variant(s) [color|white|whitesur] (default is color) + -s, --screen screen display variant(s) [1080p|2k|4k|ultrawide|ultrawide2k] (default is 1080p) + -r, --remove Remove theme [tela|vimix|stylish|whitesur] (must add theme name option, default is tela) + + -b, --boot install theme into '/boot/grub' or '/boot/grub2' + -g, --generate do not install but generate theme into chosen directory (must add your directory) + + -h, --help Show this help + +EOF } generate() { + if [[ "${install_boot}" == 'true' ]]; then + if [[ -d "/boot/grub" ]]; then + THEME_DIR='/boot/grub/themes' + elif [[ -d "/boot/grub2" ]]; then + THEME_DIR='/boot/grub2/themes' + fi + fi + # Make a themes directory if it doesn't exist prompt -s "\n Checking for the existence of themes directory..." @@ -120,9 +136,7 @@ install() { prompt -s "\n Setting ${theme} as default..." # Backup grub config - if [[ ! -f "/etc/default/grub.bak" ]]; then - cp -an /etc/default/grub /etc/default/grub.bak - fi + cp -an /etc/default/grub /etc/default/grub.bak # Fedora workaround to fix the missing unicode.pf2 file (tested on fedora 34): https://bugzilla.redhat.com/show_bug.cgi?id=1739762 # This occurs when we add a theme on grub2 with Fedora. @@ -193,31 +207,39 @@ install() { fi # Update grub config - prompt -s "\n Updating grub config...\n" + prompt -s "\n Updating grub config..." updating_grub prompt -w "\n * At the next restart of your computer you will see your new Grub theme: '$theme' " #Check if password is cached (if cache timestamp has not expired yet) elif sudo -n true 2> /dev/null && echo; then - sudo "$0" -t ${theme} -i ${icon} -s ${screen} + if [[ "${install_boot}" == 'true' ]]; then + sudo "$0" -t ${theme} -i ${icon} -s ${screen} -b + else + sudo "$0" -t ${theme} -i ${icon} -s ${screen} + fi else - + #Ask for password if [[ -n ${tui_root_login} ]] ; then if [[ -n "${theme}" && -n "${screen}" ]]; then - sudo -S $0 -t ${theme} -i ${icon} -s ${screen} <<< ${tui_root_login} + if [[ "${install_boot}" == 'true' ]]; then + sudo -S $0 -t ${theme} -i ${icon} -s ${screen} -b <<< ${tui_root_login} + else + sudo -S $0 -t ${theme} -i ${icon} -s ${screen} <<< ${tui_root_login} + fi fi else - prompt -e "\n [ Error! ] -> Run me as root! " read -r -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s - if sudo -S echo <<< $REPLY 2> /dev/null && echo; then - #Correct password, use with sudo's stdin - sudo -S "$0" -t ${theme} -i ${icon} -s ${screen} <<< ${REPLY} + if [[ "${install_boot}" == 'true' ]]; then + sudo -S "$0" -t ${theme} -i ${icon} -s ${screen} -b <<< ${REPLY} + else + sudo -S "$0" -t ${theme} -i ${icon} -s ${screen} <<< ${REPLY} + fi else - #block for 3 seconds before allowing another attempt sleep 3 prompt -e "\n [ Error! ] -> Incorrect password!\n" @@ -314,11 +336,11 @@ updating_grub() { grub2-mkconfig -o /boot/grub2/grub.cfg elif has_command dnf; then if [[ -f /boot/efi/EFI/fedora/grub.cfg ]] && (( $(cat /etc/fedora-release | awk '{print $3}') < 34 )); then - prompt -i "Find config file on /boot/efi/EFI/fedora/grub.cfg ...\n" + prompt -i "\n Find config file on /boot/efi/EFI/fedora/grub.cfg ...\n" grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg fi if [[ -f /boot/grub2/grub.cfg ]]; then - prompt -i "Find config file on /boot/grub2/grub.cfg ...\n" + prompt -i "\n Find config file on /boot/grub2/grub.cfg ...\n" grub2-mkconfig -o /boot/grub2/grub.cfg fi fi @@ -353,10 +375,19 @@ remove() { # Check for root access and proceed if it is present if [ "$UID" -eq "$ROOT_UID" ]; then - - echo -e "Checking for the existence of themes directory..." + prompt -i "\n Checking for the existence of themes directory..." if [[ -d "${THEME_DIR}/${theme}" ]]; then + prompt -s "\n Find installed theme: '${THEME_DIR}/${theme}'..." rm -rf "${THEME_DIR}/${theme}" + prompt -w "\n Removed: '${THEME_DIR}/${theme}'..." + elif [[ -d "/boot/grub/themes/${theme}" ]]; then + prompt -s "\n Find installed theme: '/boot/grub/themes/${theme}'..." + rm -rf "/boot/grub/themes/${theme}" + prompt -w "\n Removed: '/boot/grub/themes/${theme}'..." + elif [[ -d "/boot/grub2/themes/${theme}" ]]; then + prompt -s "\n Find installed theme: '/boot/grub2/themes/${theme}'..." + rm -rf "/boot/grub2/themes/${theme}" + prompt -w "\n Removed: '/boot/grub2/themes/${theme}'..." else prompt -e "\n Specified ${theme} theme does not exist!" exit 0 @@ -364,13 +395,10 @@ remove() { local grub_config_location="" if [[ -f "/etc/default/grub" ]]; then - grub_config_location="/etc/default/grub" elif [[ -f "/etc/default/grub.d/kali-themes.cfg" ]]; then - grub_config_location="/etc/default/grub.d/kali-themes.cfg" else - prompt -e "\nCannot find grub config file in default locations!" prompt -e "\nPlease inform the developers by opening an issue on github." prompt -e "\nExiting..." @@ -380,16 +408,12 @@ remove() { local current_theme="" # Declaration and assignment should be done seperately ==> https://github.com/koalaman/shellcheck/wiki/SC2155 current_theme="$(grep 'GRUB_THEME=' $grub_config_location | grep -v \#)" if [[ -n "$current_theme" ]]; then - # Backup with --in-place option to grub.bak within the same directory; then remove the current theme. sed --in-place='.bak' "s|$current_theme|#GRUB_THEME=|" "$grub_config_location" - rm -rf "$grub_config_location".bak - # Update grub config prompt -s "\n Resetting grub theme...\n" updating_grub else - prompt -e "\nNo active theme found." prompt -e "\nExiting..." exit 1 @@ -399,7 +423,7 @@ remove() { #Check if password is cached (if cache timestamp not expired yet) if sudo -n true 2> /dev/null && echo; then #No need to ask for password - sudo "$0" "${PROG_ARGS[@]}" + sudo "$0" -t ${theme} "${PROG_ARGS[@]}" else #Ask for password prompt -e "\n [ Error! ] -> Run me as root! " @@ -407,7 +431,7 @@ remove() { if sudo -S echo <<< $REPLY 2> /dev/null && echo; then #Correct password, use with sudo's stdin - sudo -S "$0" "${PROG_ARGS[@]}" <<< $REPLY + sudo -S "$0" -t ${theme} "${PROG_ARGS[@]}" <<< $REPLY else #block for 3 seconds before allowing another attempt sleep 3 @@ -462,7 +486,35 @@ while [[ $# -gt 0 ]]; do case "${1}" in -r|--remove) remove='true' - shift 1 + shift + for theme in "${@}"; do + case "${theme}" in + tela) + themes+=("${THEME_VARIANTS[0]}") + shift + ;; + vimix) + themes+=("${THEME_VARIANTS[1]}") + shift + ;; + stylish) + themes+=("${THEME_VARIANTS[2]}") + shift + ;; + whitesur) + themes+=("${THEME_VARIANTS[3]}") + shift + ;; + -*) + break + ;; + *) + prompt -e "ERROR: Unrecognized theme variant '$1'." + prompt -i "Try '$0 --help' for more information." + exit 1 + ;; + esac + done ;; -g|--generate) shift 1 @@ -470,6 +522,10 @@ while [[ $# -gt 0 ]]; do install=generate shift 1 ;; + -b|--boot) + install_boot='true' + shift 1 + ;; -t|--theme) shift for theme in "${@}"; do diff --git a/preview.png b/preview.png index ec25360..b56989c 100644 Binary files a/preview.png and b/preview.png differ