yea this idea is a good one
@manuel, this is what Iβve done so far:
#/bin/bash
function cleanup() {
printf '\e[?25h' # unhide cursor
stty echo
}
trap cleanup EXIT
stty -echo
printf '\e[?25l' # hide cursor
CSI_fg=$'\e[38;2;'
CSI_bg=$'\e[48;2;'
esc_reset=$'\e[0m'
esc=(
"0;0;0m" # black
"0;0;168m" # blue
"0;168;0m" # green
"0;168;168m" # cyan
"168;0;0m" # red
"168;0;168m" # magenta
"168;84;0m" # brown
"168;168;168m" # light-gray
"84;84;84m" # dark-gray
"84;84;254m" # light-blue
"84;254;84m" # light-green
"84;254;254m" # light-cyan
"254;84;84m" # light-red
"254;84;254m" # light-magenta
"254;254;84m" # yellow
"254;254;254m" # white
)
# make black opaque for truecolor terminal emulators:
[[ $COLORTERM = "truecolor" ]] && esc[0]="1;1;1m"
cname=(
"black"
"blue"
"green"
"cyan"
"red"
"magenta"
"brown"
"light-gray"
"dark-gray"
"light-blue"
"light-green"
"light-cyan"
"light-red"
"light-magenta"
"yellow"
"white"
)
val=(0 9 1 11) #normal bg, normal fg, highlighted bg, highlighted fg
selected=0;
print_menu() {
gb=$CSI_bg${esc[0]}$CSI_fg${esc[7]}
no=$CSI_bg${esc[${val[0]}]}$CSI_fg${esc[${val[1]}]}
hl=$CSI_bg${esc[${val[2]}]}$CSI_fg${esc[${val[3]}]}
cat \
<< EOF
$gb Colour Picker for GRUB - EXAMPLE $esc_reset
$gb $noββββββββββββββββββββββββββββββββββββββββββββββ$gb $esc_reset
$gb $noβ Normal option β$gb $esc_reset
$gb $noβ Normal option β$gb $esc_reset
$gb $noβ$hl Highlighted option $noβ$gb $esc_reset
$gb $noβ Normal option β$gb $esc_reset
$gb $noβ β$gb $esc_reset
$gb $noβ β$gb $esc_reset
$gb $noβ β$gb $esc_reset
$gb $noββββββββββββββββββββββββββββββββββββββββββββββ$gb $esc_reset
$gb Use the arrow keys to change the values below. $esc_reset
$gb Press ENTER when done. $esc_reset
$gb $esc_reset
EOF
local SO
local SC
SO[$selected]='>'
SC[$selected]='<'
printf "%s Normal background: %-2s%-14s%s%2s %s\n" \
"$gb" "${SO[0]}" "${cname[${val[0]}]}" "$CSI_fg${esc[${val[0]}]}ββ$gb" \
"${SC[0]}" "$esc_reset"
printf "%s Normal foreground: %-2s%-14s%s%2s %s\n" \
"$gb" "${SO[1]}" "${cname[${val[1]}]}" "$CSI_fg${esc[${val[1]}]}ββ$gb" \
"${SC[1]}" "$esc_reset"
printf "%s Highlighted background: %-2s%-14s%s%2s %s\n" \
"$gb" "${SO[2]}" "${cname[${val[2]}]}" "$CSI_fg${esc[${val[2]}]}ββ$gb" \
"${SC[2]}" "$esc_reset"
printf "%s Highlighted foreground: %-2s%-14s%s%2s %s\n" \
"$gb" "${SO[3]}" "${cname[${val[3]}]}" "$CSI_fg${esc[${val[3]}]}ββ$gb" \
"${SC[3]}" "$esc_reset"
}
move_cursor_top() {
#printf "\e[17F" # does not work on some terminals?
printf "\e[17A\r" # same thing
}
while true; do
print_menu
# wait for input
read -rsn1 key
[[ $key = $'' ]] && break
[[ $key = $'\u1b' ]] && {
read -rsn2 key
}
[[ -n $key ]] && {
case "$key" in
'[D'|h ) val[$selected]=$(((val[selected]+15)%16)) ;;
'[B'|j ) selected=$((selected >= 3 ? 3 : selected+1)) ;;
'[A'|k ) selected=$((selected <= 0 ? 0 : selected-1)) ;;
'[C'|l ) val[$selected]=$(((val[selected]+1) % 16)) ;;
#q ) break ;;
#* ) continue ;;
esac
}
move_cursor_top
done
move_cursor_top
selected=5
print_menu
cat << EOF
To apply the changes, add the following two lines
to your /etc/default/grub file:
$CSI_fg${esc[7]}GRUB_COLOR_NORMAL="${cname[${val[1]}]}/${cname[${val[0]}]}"
GRUB_COLOR_HIGHLIGHT="${cname[${val[3]}]}/${cname[${val[2]}]}"$esc_reset
Do not forget to run:
sudo grub-mkconfig -o /boot/grub/grub.cfg
EOF
A big thanks to @dalto who helped me determine the RGB values of GRUB colours.
For now, it only works in a terminal that supports truecolor (like Konsole). I will make it so that it works on terminals that support only 16 colours, but the values will not be accurate, of course.
Currently, it does not edit /etc/default/grub
, but simply tells the user what two lines to add. This could be implemented, but Iβm not sure I would trust a script to do it instead of me. If you want me to do it, let me know, it shouldnβt be a problem.
This is now quite off topic.
EDIT: Updated the script. It looks good now in Konsole and in the TTY, needs testing on other terminal emulators.
EDIT2: thanks to @keybreak for reporting that the script did not work properly in Cool Retro Term. The issue is fixed now.
Thanks for your hard work and others who helped as well!
One idea is to have an option like --save
for this. Then user can decide.
But anyway, it is up to you if you are willing to make more changes.
Iβll try your script as soon as I have more time, hopefully later today.
Iβm certainly willing to implement that, itβs not too difficult. What I am not 100% sure Iβm able to do is offer 24/7 tech support for n00bs who used this script and, due to some unforeseen conflict with some other option, made their computers unbootable1. And Iβm certainly not willing to take any blame for that.
1I can already see it, all over reddit: βKresimirβs script bricked my Manjaro PC, whaaaaaaaa β
Tried your script with xfce4-terminal, qterminal and terminator.
The graphics worked well on all of them.
Great work! And thanks!
No problem, we can add disclaimer:
This is EndeavourOS community software - made by Kresimir.
No warranty whatsoever. Use it at your own risk.
But seriously, the script as-is should already be very useful for many people.
Did you already have any (command) name in mind for it?
How about HUGE letters in UI itself - MADE BY KRESIMIR!!!
Canβt wait for reddit & Manjaroβ¦
I donβt knowβ¦ grub-colour-chooser
? Iβm bad at namesβ¦
Iβll implement writing the changes to a file. It will be a very simple sed
script that will just comment out all lines starting with GRUB_COLOR_NORMAL=
or GRUB_COLOR_HIGHLIGHT=
and add the two lines at the end of the file.
The name sounds OK to me.
Just a suggestion: write also a comment in the end of file saying something like:
# modified by "the-name-of-your-script" GRUB_COLOR_NORMAL=...
Then people will know why there are modifications.
Oh I love this image. Do you have it in 1440p? Or at least in 1080p? I want to use it as my SDDM background!
I can scale it for you in an hour or so
Thanks, I can scale it myself in GIMP, I just asked if someone had a better quality version.
@anon12581665, this is not good, unfortunately, the water lily is cropped poorly.
I just found it on the net. Maybe there are some others?
Edit: As @anon12581665 has posted a link.
2560x1600
By the way, looks like the GRUB_THEME
variable needs to be commented out if it isnβt.
Otherwise the color variables seem to have no effect.
So maybe the easiest change in the end of file /etc/default/grub is:
# modified by grub-colour-chooser
GRUB_COLOR_NORMAL=...
GRUB_COLOR_HIGHLIGHT=...
unset GRUB_THEME
?
Yeah, Iβll figure it out, it shouldnβt be difficult. Today or tomorrow, when I get some time to focus on it.
No hurry! We all do voluntary stuff here!