Compare commits
30 Commits
2021-12-05
...
2022-10-30
Author | SHA1 | Date | |
---|---|---|---|
e77cbfa662 | |||
967a302d8f | |||
7ab56dc587 | |||
8303aa2825 | |||
b10a5fd4c8 | |||
8627f86ce5 | |||
fd78958d50 | |||
c6e2967f06 | |||
6b58676c4d | |||
fa74d1b6af | |||
29dd80dd70 | |||
20a8f12488 | |||
b5b4780418 | |||
3f5624833d | |||
f4f3354233 | |||
a4bff7bf91 | |||
86caf618c3 | |||
4f3b99cdf3 | |||
53f899da9c | |||
2fd6eb9b66 | |||
824064faa9 | |||
70ff68055b | |||
e5b869f186 | |||
9e440c4bbc | |||
468bee78f5 | |||
9d244c9d07 | |||
d27e1caf5f | |||
2824010b86 | |||
f1e03b4949 | |||
41de75c50e |
@ -6,8 +6,7 @@ Usage: `sudo ./install.sh [OPTIONS...]`
|
|||||||
|
|
||||||
| Options: | Description: |
|
| Options: | Description: |
|
||||||
|:-----------------------|:-------------|
|
|:-----------------------|:-------------|
|
||||||
| -b, --boot | Install grub theme into `/boot/grub/themes` |
|
| -t, --theme | theme variant(s) [tela/vimix/stylish/whitesur] (default is tela)"
|
||||||
| -t, --theme | theme variant(s) [tela/vimix/stylish/slaze/whitesur] (default is tela)"
|
|
||||||
| -i, --icon | icon variant(s) [color/white/whitesur] (default is color)"
|
| -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)"
|
| -s, --screen | screen resolution variant(s) [1080p/2k/4k/ultrawide/ultrawide2k] (default is 1080p)"
|
||||||
| -r, --remove [THEME] | Uninstall selected theme |
|
| -r, --remove [THEME] | Uninstall selected theme |
|
||||||
@ -51,6 +50,7 @@ _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
|
- If any issues occur, report then to the [issue](https://github.com/vinceliuice/grub2-themes/issues) page
|
||||||
|
|
||||||
## Preview:
|
## Preview:
|
||||||
|
Images shown: tela/vimix/stylish/whitesur
|
||||||

|

|
||||||
|
|
||||||
## Documents
|
## Documents
|
||||||
|
Before Width: | Height: | Size: 527 B After Width: | Height: | Size: 527 B |
Before Width: | Height: | Size: 527 B After Width: | Height: | Size: 527 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 527 B After Width: | Height: | Size: 527 B |
Before Width: | Height: | Size: 527 B After Width: | Height: | Size: 527 B |
BIN
assets/assets-color/icons-1080p/nixos.png
Normal file
After Width: | Height: | Size: 1023 B |
BIN
assets/assets-color/icons-1080p/ubuntuDDE.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 763 B After Width: | Height: | Size: 770 B |
Before Width: | Height: | Size: 763 B After Width: | Height: | Size: 770 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 763 B After Width: | Height: | Size: 770 B |
Before Width: | Height: | Size: 763 B After Width: | Height: | Size: 770 B |
BIN
assets/assets-color/icons-2k/nixos.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/assets-color/icons-2k/ubuntuDDE.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1006 B After Width: | Height: | Size: 1005 B |
Before Width: | Height: | Size: 1006 B After Width: | Height: | Size: 1005 B |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 1006 B After Width: | Height: | Size: 1005 B |
Before Width: | Height: | Size: 1006 B After Width: | Height: | Size: 1005 B |
BIN
assets/assets-color/icons-4k/nixos.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
assets/assets-color/icons-4k/ubuntuDDE.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
assets/assets-white/icons-1080p/nixos.png
Normal file
After Width: | Height: | Size: 608 B |
BIN
assets/assets-white/icons-1080p/ubuntuDDE.png
Normal file
After Width: | Height: | Size: 641 B |
BIN
assets/assets-white/icons-2k/nixos.png
Normal file
After Width: | Height: | Size: 916 B |
BIN
assets/assets-white/icons-2k/ubuntuDDE.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
assets/assets-white/icons-4k/nixos.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
assets/assets-white/icons-4k/ubuntuDDE.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 587 B |
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 587 B |
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 587 B |
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 587 B |
BIN
assets/assets-whitesur/icons-1080p/nixos.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
assets/assets-whitesur/icons-1080p/ubuntuDDE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 803 B After Width: | Height: | Size: 822 B |
Before Width: | Height: | Size: 803 B After Width: | Height: | Size: 822 B |
Before Width: | Height: | Size: 803 B After Width: | Height: | Size: 822 B |
Before Width: | Height: | Size: 803 B After Width: | Height: | Size: 822 B |
BIN
assets/assets-whitesur/icons-2k/nixos.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/assets-whitesur/icons-2k/ubuntuDDE.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 987 B After Width: | Height: | Size: 994 B |
Before Width: | Height: | Size: 987 B After Width: | Height: | Size: 994 B |
Before Width: | Height: | Size: 987 B After Width: | Height: | Size: 994 B |
Before Width: | Height: | Size: 987 B After Width: | Height: | Size: 994 B |
BIN
assets/assets-whitesur/icons-4k/nixos.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/assets-whitesur/icons-4k/ubuntuDDE.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 124 KiB |
Before Width: | Height: | Size: 175 KiB After Width: | Height: | Size: 197 KiB |
@ -42,7 +42,9 @@ neon
|
|||||||
artix
|
artix
|
||||||
kernel
|
kernel
|
||||||
zorin
|
zorin
|
||||||
|
nixos
|
||||||
gpart
|
gpart
|
||||||
|
ubuntuDDE
|
||||||
|
|
||||||
recovery
|
recovery
|
||||||
restart
|
restart
|
||||||
|
120
flake.nix
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
{
|
||||||
|
description = "Flake to manage grub2 themes from vinceliuice";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/master";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
with nixpkgs.lib;
|
||||||
|
rec {
|
||||||
|
nixosModule = { config, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.boot.loader.grub2-theme;
|
||||||
|
splashImage = if cfg.splashImage == null then "" else cfg.splashImage;
|
||||||
|
resolutions = {
|
||||||
|
"1080p" = "1920x1080";
|
||||||
|
"ultrawide" = "2560x1080";
|
||||||
|
"2k" = "2560x1440";
|
||||||
|
"4k" = "3840x2160";
|
||||||
|
"ultrawide2k" = "3440x1440";
|
||||||
|
};
|
||||||
|
grub2-theme = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "grub2-theme";
|
||||||
|
src = "${self}";
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/grub/themes;
|
||||||
|
bash ./install.sh \
|
||||||
|
--generate $out/grub/themes \
|
||||||
|
--screen ${cfg.screen} \
|
||||||
|
--theme ${cfg.theme} \
|
||||||
|
--icon ${cfg.icon};
|
||||||
|
|
||||||
|
if [ -n "${splashImage}" ]; then
|
||||||
|
cp ${splashImage} $out/grub/themes/${cfg.theme}/background.jpg;
|
||||||
|
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;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
resolution = resolutions."${cfg.screen}";
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
options = {
|
||||||
|
boot.loader.grub2-theme = {
|
||||||
|
enable = mkOption {
|
||||||
|
default = true;
|
||||||
|
example = true;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Enable grub2 theming
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
theme = mkOption {
|
||||||
|
default = "tela";
|
||||||
|
example = "tela";
|
||||||
|
type = types.enum [ "tela" "vimix" "stylish" "whitesur" ];
|
||||||
|
description = ''
|
||||||
|
The theme to use for grub2.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
icon = mkOption {
|
||||||
|
default = "white";
|
||||||
|
example = "white";
|
||||||
|
type = types.enum [ "color" "white" "whitesur" ];
|
||||||
|
description = ''
|
||||||
|
The icon to use for grub2.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
screen = mkOption {
|
||||||
|
default = "1080p";
|
||||||
|
example = "1080p";
|
||||||
|
type = types.enum [ "1080p" "2k" "4k" "ultrawide" "ultrawide2k" ];
|
||||||
|
description = ''
|
||||||
|
The screen resolution to use for grub2.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
splashImage = mkOption {
|
||||||
|
default = null;
|
||||||
|
example = "/my/path/background.jpg";
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
description = ''
|
||||||
|
The path of the image to use for background (must be jpg).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
footer = mkOption {
|
||||||
|
default = true;
|
||||||
|
example = true;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Whether to include the image footer.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = mkIf cfg.enable (mkMerge [{
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}]);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
225
install.sh
@ -1,10 +1,8 @@
|
|||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
# Grub2 Themes
|
# Exit Immediately if a command fails
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
|
||||||
[ GLOBAL::CONF ]
|
|
||||||
{
|
|
||||||
readonly ROOT_UID=0
|
readonly ROOT_UID=0
|
||||||
readonly Project_Name="GRUB2::THEMES"
|
readonly Project_Name="GRUB2::THEMES"
|
||||||
readonly MAX_DELAY=20 # max delay for user to enter root password
|
readonly MAX_DELAY=20 # max delay for user to enter root password
|
||||||
@ -12,13 +10,15 @@ tui_root_login=
|
|||||||
|
|
||||||
THEME_DIR="/usr/share/grub/themes"
|
THEME_DIR="/usr/share/grub/themes"
|
||||||
REO_DIR="$(cd $(dirname $0) && pwd)"
|
REO_DIR="$(cd $(dirname $0) && pwd)"
|
||||||
}
|
|
||||||
|
|
||||||
THEME_VARIANTS=('tela' 'vimix' 'stylish' 'whitesur')
|
THEME_VARIANTS=('tela' 'vimix' 'stylish' 'whitesur')
|
||||||
ICON_VARIANTS=('color' 'white' 'whitesur')
|
ICON_VARIANTS=('color' 'white' 'whitesur')
|
||||||
SCREEN_VARIANTS=('1080p' '2k' '4k' 'ultrawide' 'ultrawide2k')
|
SCREEN_VARIANTS=('1080p' '2k' '4k' 'ultrawide' 'ultrawide2k')
|
||||||
|
|
||||||
#COLORS
|
#################################
|
||||||
|
# :::::: C O L O R S :::::: #
|
||||||
|
#################################
|
||||||
|
|
||||||
CDEF=" \033[0m" # default color
|
CDEF=" \033[0m" # default color
|
||||||
CCIN=" \033[0;36m" # info color
|
CCIN=" \033[0;36m" # info color
|
||||||
CGSC=" \033[0;32m" # success color
|
CGSC=" \033[0;32m" # success color
|
||||||
@ -30,6 +30,10 @@ b_CGSC=" \033[1;32m" # bold success color
|
|||||||
b_CRER=" \033[1;31m" # bold error color
|
b_CRER=" \033[1;31m" # bold error color
|
||||||
b_CWAR=" \033[1;33m" # bold warning color
|
b_CWAR=" \033[1;33m" # bold warning color
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# :::::: F U N C T I O N S :::::: #
|
||||||
|
#######################################
|
||||||
|
|
||||||
# echo like ... with flag type and display message colors
|
# echo like ... with flag type and display message colors
|
||||||
prompt () {
|
prompt () {
|
||||||
case ${1} in
|
case ${1} in
|
||||||
@ -49,30 +53,30 @@ prompt () {
|
|||||||
|
|
||||||
# Check command availability
|
# Check command availability
|
||||||
function has_command() {
|
function has_command() {
|
||||||
command -v $1 > /dev/null
|
command -v $1 &> /dev/null #with "&>", all output will be redirected.
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf "%s\n" "Usage: ${0##*/} [OPTIONS...]"
|
printf "%s\n" "Usage: ${0##*/} [OPTIONS...]"
|
||||||
printf "\n%s\n" "OPTIONS:"
|
printf "\n%s\n" "OPTIONS:"
|
||||||
printf " %-25s%s\n" "-b, --boot" "install grub theme into /boot/grub/themes"
|
|
||||||
printf " %-25s%s\n" "-t, --theme" "theme variant(s) [tela|vimix|stylish|whitesur] (default is tela)"
|
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" "-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" "-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" "-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"
|
printf " %-25s%s\n" "-h, --help" "Show this help"
|
||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
generate() {
|
||||||
local theme=${1}
|
if [[ "${install_boot}" == 'true' ]]; then
|
||||||
local icon=${2}
|
if [[ -d "/boot/grub" ]]; then
|
||||||
local screen=${3}
|
THEME_DIR='/boot/grub/themes'
|
||||||
|
elif [[ -d "/boot/grub2" ]]; then
|
||||||
|
THEME_DIR='/boot/grub2/themes'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for root access and proceed if it is present
|
# Make a themes directory if it doesn't exist
|
||||||
if [[ "$UID" -eq "$ROOT_UID" ]]; then
|
|
||||||
clear
|
|
||||||
|
|
||||||
# Create themes directory if it didn't exist
|
|
||||||
prompt -s "\n Checking for the existence of themes directory..."
|
prompt -s "\n Checking for the existence of themes directory..."
|
||||||
|
|
||||||
[[ -d "${THEME_DIR}/${theme}" ]] && rm -rf "${THEME_DIR}/${theme}"
|
[[ -d "${THEME_DIR}/${theme}" ]] && rm -rf "${THEME_DIR}/${theme}"
|
||||||
@ -106,6 +110,19 @@ install() {
|
|||||||
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-select/select-${screen}/"*.png "${THEME_DIR}/${theme}"
|
cp -a --no-preserve=ownership "${REO_DIR}/assets/assets-select/select-${screen}/"*.png "${THEME_DIR}/${theme}"
|
||||||
cp -a --no-preserve=ownership "${REO_DIR}/assets/info-${screen}.png" "${THEME_DIR}/${theme}/info.png"
|
cp -a --no-preserve=ownership "${REO_DIR}/assets/info-${screen}.png" "${THEME_DIR}/${theme}/info.png"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install() {
|
||||||
|
local theme=${1}
|
||||||
|
local icon=${2}
|
||||||
|
local screen=${3}
|
||||||
|
|
||||||
|
# Check for root access and proceed if it is present
|
||||||
|
if [[ "$UID" -eq "$ROOT_UID" ]]; then
|
||||||
|
clear
|
||||||
|
|
||||||
|
# Generate the theme in "/usr/share/grub/themes"
|
||||||
|
generate "${theme}" "${icon}" "${screen}"
|
||||||
|
|
||||||
# Set theme
|
# Set theme
|
||||||
prompt -s "\n Setting ${theme} as default..."
|
prompt -s "\n Setting ${theme} as default..."
|
||||||
@ -182,33 +199,38 @@ install() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Update grub config
|
# Update grub config
|
||||||
prompt -s "\n Updating grub config...\n"
|
prompt -s "\n Updating grub config..."
|
||||||
|
|
||||||
updating_grub
|
updating_grub
|
||||||
|
|
||||||
prompt -w "\n * At the next restart of your computer you will see your new Grub theme: '$theme' "
|
prompt -w "\n * At the next restart of your computer you will see your new Grub theme: '$theme' "
|
||||||
else
|
|
||||||
#Check if password is cached (if cache timestamp not expired yet)
|
|
||||||
sudo -n true 2> /dev/null && echo
|
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
#Check if password is cached (if cache timestamp has not expired yet)
|
||||||
#No need to ask for password
|
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
|
else
|
||||||
|
sudo "$0" -t ${theme} -i ${icon} -s ${screen}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
|
||||||
#Ask for password
|
#Ask for password
|
||||||
if [[ -n ${tui_root_login} ]] ; then
|
if [[ -n ${tui_root_login} ]] ; then
|
||||||
if [[ -n "${theme}" && -n "${screen}" ]]; then
|
if [[ -n "${theme}" && -n "${screen}" ]]; then
|
||||||
|
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}
|
sudo -S $0 -t ${theme} -i ${icon} -s ${screen} <<< ${tui_root_login}
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
prompt -e "\n [ Error! ] -> Run me as root! "
|
prompt -e "\n [ Error! ] -> Run me as root! "
|
||||||
read -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s
|
read -r -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s
|
||||||
|
if sudo -S echo <<< $REPLY 2> /dev/null && echo; then
|
||||||
sudo -S echo <<< $REPLY 2> /dev/null && echo
|
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
#Correct password, use with sudo's stdin
|
#Correct password, use with sudo's stdin
|
||||||
|
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}
|
sudo -S "$0" -t ${theme} -i ${icon} -s ${screen} <<< ${REPLY}
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
#block for 3 seconds before allowing another attempt
|
#block for 3 seconds before allowing another attempt
|
||||||
sleep 3
|
sleep 3
|
||||||
@ -217,16 +239,13 @@ install() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_dialog() {
|
run_dialog() {
|
||||||
if [[ -x /usr/bin/dialog ]]; then
|
if [[ -x /usr/bin/dialog ]]; then
|
||||||
if [[ "$UID" -ne "$ROOT_UID" ]]; then
|
if [[ "$UID" -ne "$ROOT_UID" ]]; then
|
||||||
#Check if password is cached (if cache timestamp not expired yet)
|
#Check if password is cached (if cache timestamp not expired yet)
|
||||||
sudo -n true 2> /dev/null && echo
|
if sudo -n true 2> /dev/null && echo; then
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
#No need to ask for password
|
#No need to ask for password
|
||||||
sudo $0
|
sudo $0
|
||||||
else
|
else
|
||||||
@ -237,9 +256,7 @@ run_dialog() {
|
|||||||
--passwordbox "require root permission" 8 50 \
|
--passwordbox "require root permission" 8 50 \
|
||||||
--output-fd 1 )
|
--output-fd 1 )
|
||||||
|
|
||||||
sudo -S echo <<< $tui_root_login 2> /dev/null && echo
|
if sudo -S echo <<< $tui_root_login 2> /dev/null && echo; then
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
#Correct password, use with sudo's stdin
|
#Correct password, use with sudo's stdin
|
||||||
sudo -S "$0" <<< $tui_root_login
|
sudo -S "$0" <<< $tui_root_login
|
||||||
else
|
else
|
||||||
@ -310,12 +327,12 @@ updating_grub() {
|
|||||||
elif has_command zypper; then
|
elif has_command zypper; then
|
||||||
grub2-mkconfig -o /boot/grub2/grub.cfg
|
grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||||
elif has_command dnf; then
|
elif has_command dnf; then
|
||||||
if [[ -f /boot/efi/EFI/fedora/grub.cfg ]]; 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
|
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
|
||||||
fi
|
fi
|
||||||
if [[ -f /boot/grub2/grub.cfg ]]; then
|
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
|
grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -324,20 +341,24 @@ updating_grub() {
|
|||||||
prompt -s "\n * All done!"
|
prompt -s "\n * All done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function install_program () {
|
||||||
|
if has_command zypper; then
|
||||||
|
zypper in "$@"
|
||||||
|
elif has_command apt-get; then
|
||||||
|
apt-get install "$@"
|
||||||
|
elif has_command dnf; then
|
||||||
|
dnf install -y "$@"
|
||||||
|
elif has_command yum; then
|
||||||
|
yum install "$@"
|
||||||
|
elif has_command pacman; then
|
||||||
|
pacman -S --noconfirm "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
install_dialog() {
|
install_dialog() {
|
||||||
if [ ! "$(which dialog 2> /dev/null)" ]; then
|
if [ ! "$(which dialog 2> /dev/null)" ]; then
|
||||||
prompt -w "\n 'dialog' need to be installed for this shell"
|
prompt -w "\n 'dialog' need to be installed for this shell"
|
||||||
if has_command zypper; then
|
install_program "dialog"
|
||||||
sudo zypper in dialog
|
|
||||||
elif has_command apt-get; then
|
|
||||||
sudo apt-get install dialog
|
|
||||||
elif has_command dnf; then
|
|
||||||
sudo dnf install -y dialog
|
|
||||||
elif has_command yum; then
|
|
||||||
sudo yum install dialog
|
|
||||||
elif has_command pacman; then
|
|
||||||
sudo pacman -S --noconfirm dialog
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,49 +367,63 @@ remove() {
|
|||||||
|
|
||||||
# Check for root access and proceed if it is present
|
# Check for root access and proceed if it is present
|
||||||
if [ "$UID" -eq "$ROOT_UID" ]; then
|
if [ "$UID" -eq "$ROOT_UID" ]; then
|
||||||
echo -e "\n Checking for the existence of themes directory..."
|
prompt -i "\n Checking for the existence of themes directory..."
|
||||||
if [[ -d "${THEME_DIR}/${theme}" ]]; then
|
if [[ -d "${THEME_DIR}/${theme}" ]]; then
|
||||||
|
prompt -s "\n Find installed theme: '${THEME_DIR}/${theme}'..."
|
||||||
rm -rf "${THEME_DIR}/${theme}"
|
rm -rf "${THEME_DIR}/${theme}"
|
||||||
|
prompt -w "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
|
else
|
||||||
prompt -e "\n ${theme} grub theme not exist!"
|
prompt -e "\n Specified ${theme} theme does not exist!"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Backup grub config
|
local grub_config_location=""
|
||||||
if [[ -f "/etc/default/grub.bak" ]]; then
|
if [[ -f "/etc/default/grub" ]]; then
|
||||||
rm -rf /etc/default/grub && mv /etc/default/grub.bak /etc/default/grub
|
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
|
else
|
||||||
prompt -e "\n grub.bak not exist!"
|
prompt -e "\nCannot find grub config file in default locations!"
|
||||||
exit 0
|
prompt -e "\nPlease inform the developers by opening an issue on github."
|
||||||
fi
|
prompt -e "\nExiting..."
|
||||||
|
exit 1
|
||||||
# For Kali linux
|
|
||||||
if [[ -f "/etc/default/grub.d/kali-themes.cfg.bak" ]]; then
|
|
||||||
rm -rf /etc/default/grub.d/kali-themes.cfg && mv /etc/default/grub.d/kali-themes.cfg.bak /etc/default/grub.d/kali-themes.cfg
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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"
|
||||||
# Update grub config
|
# Update grub config
|
||||||
prompt -s "\n Resetting grub theme...\n"
|
prompt -s "\n Resetting grub theme...\n"
|
||||||
|
|
||||||
updating_grub
|
updating_grub
|
||||||
|
else
|
||||||
|
prompt -e "\nNo active theme found."
|
||||||
|
prompt -e "\nExiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
#Check if password is cached (if cache timestamp not expired yet)
|
#Check if password is cached (if cache timestamp not expired yet)
|
||||||
sudo -n true 2> /dev/null && echo
|
if sudo -n true 2> /dev/null && echo; then
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
#No need to ask for password
|
#No need to ask for password
|
||||||
sudo "$0" "${PROG_ARGS[@]}"
|
sudo "$0" -t ${theme} "${PROG_ARGS[@]}"
|
||||||
else
|
else
|
||||||
#Ask for password
|
#Ask for password
|
||||||
prompt -e "\n [ Error! ] -> Run me as root! "
|
prompt -e "\n [ Error! ] -> Run me as root! "
|
||||||
read -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s
|
read -r -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s #when using "read" command, "-r" option must be supplied ==> https://github.com/koalaman/shellcheck/wiki/SC2162
|
||||||
|
|
||||||
sudo -S echo <<< $REPLY 2> /dev/null && echo
|
if sudo -S echo <<< $REPLY 2> /dev/null && echo; then
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
#Correct password, use with sudo's stdin
|
#Correct password, use with sudo's stdin
|
||||||
sudo -S "$0" "${PROG_ARGS[@]}" <<< $REPLY
|
sudo -S "$0" -t ${theme} "${PROG_ARGS[@]}" <<< $REPLY
|
||||||
else
|
else
|
||||||
#block for 3 seconds before allowing another attempt
|
#block for 3 seconds before allowing another attempt
|
||||||
sleep 3
|
sleep 3
|
||||||
@ -404,19 +439,16 @@ dialog_installer() {
|
|||||||
if [[ ! -x /usr/bin/dialog ]]; then
|
if [[ ! -x /usr/bin/dialog ]]; then
|
||||||
if [[ $UID -ne $ROOT_UID ]]; then
|
if [[ $UID -ne $ROOT_UID ]]; then
|
||||||
#Check if password is cached (if cache timestamp not expired yet)
|
#Check if password is cached (if cache timestamp not expired yet)
|
||||||
sudo -n true 2> /dev/null && echo
|
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
if sudo -n true 2> /dev/null && echo; then
|
||||||
#No need to ask for password
|
#No need to ask for password
|
||||||
exec sudo $0
|
exec sudo $0
|
||||||
else
|
else
|
||||||
#Ask for password
|
#Ask for password
|
||||||
prompt -e "\n [ Error! ] -> Run me as root! "
|
prompt -e "\n [ Error! ] -> Run me as root! "
|
||||||
read -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s
|
read -r -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s
|
||||||
|
|
||||||
sudo -S echo <<< $REPLY 2> /dev/null && echo
|
if sudo -S echo <<< $REPLY 2> /dev/null && echo; then
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
#Correct password, use with sudo's stdin
|
#Correct password, use with sudo's stdin
|
||||||
sudo $0 <<< $REPLY
|
sudo $0 <<< $REPLY
|
||||||
else
|
else
|
||||||
@ -431,20 +463,33 @@ dialog_installer() {
|
|||||||
fi
|
fi
|
||||||
run_dialog
|
run_dialog
|
||||||
install "${theme}" "${icon}" "${screen}"
|
install "${theme}" "${icon}" "${screen}"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################################################
|
||||||
|
# :::::: A R G U M E N T H A N D L I N G :::::: #
|
||||||
|
#######################################################
|
||||||
|
|
||||||
|
install=install
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
PROG_ARGS+=("${1}")
|
PROG_ARGS+=("${1}")
|
||||||
dialog='false'
|
dialog='false'
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-b|--boot)
|
|
||||||
THEME_DIR="/boot/grub/themes"
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
-r|--remove)
|
-r|--remove)
|
||||||
remove='true'
|
remove='true'
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
-g|--generate)
|
||||||
|
shift 1
|
||||||
|
THEME_DIR="${1}"
|
||||||
|
install=generate
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
-b|--boot)
|
||||||
|
install_boot='true'
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
-t|--theme)
|
-t|--theme)
|
||||||
shift
|
shift
|
||||||
for theme in "${@}"; do
|
for theme in "${@}"; do
|
||||||
@ -465,7 +510,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
themes+=("${THEME_VARIANTS[3]}")
|
themes+=("${THEME_VARIANTS[3]}")
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-*|--*)
|
-*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -492,7 +537,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
icons+=("${ICON_VARIANTS[2]}")
|
icons+=("${ICON_VARIANTS[2]}")
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-*|--*)
|
-*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -527,7 +572,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
screens+=("${SCREEN_VARIANTS[4]}")
|
screens+=("${SCREEN_VARIANTS[4]}")
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-*|--*)
|
-*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -550,13 +595,17 @@ while [[ $# -gt 0 ]]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# :::::: M A I N :::::: #
|
||||||
|
#############################
|
||||||
|
|
||||||
# Show terminal user interface for better use
|
# Show terminal user interface for better use
|
||||||
if [[ "${dialog:-}" == 'false' ]]; then
|
if [[ "${dialog:-}" == 'false' ]]; then
|
||||||
if [[ "${remove:-}" != 'true' ]]; then
|
if [[ "${remove:-}" != 'true' ]]; then
|
||||||
for theme in "${themes[@]-${THEME_VARIANTS[0]}}"; do
|
for theme in "${themes[@]-${THEME_VARIANTS[0]}}"; do
|
||||||
for icon in "${icons[@]-${ICON_VARIANTS[0]}}"; do
|
for icon in "${icons[@]-${ICON_VARIANTS[0]}}"; do
|
||||||
for screen in "${screens[@]-${SCREEN_VARIANTS[0]}}"; do
|
for screen in "${screens[@]-${SCREEN_VARIANTS[0]}}"; do
|
||||||
install "${theme}" "${icon}" "${screen}"
|
$install "${theme}" "${icon}" "${screen}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -569,4 +618,4 @@ if [[ "${dialog:-}" == 'false' ]]; then
|
|||||||
dialog_installer
|
dialog_installer
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 1
|
exit 0
|
||||||
|