You are not logged in.
Pages: 1
I wanted to make a custom boot message saying "Welcome to Arch Linux!" because I want to have that on the booting screen, but not the init messages and the "Arch Linux" in another color. So I enabled (actually it was already enabled
) quiet boot and managed to add my custom boot message. But now I'm stuck at the color. How can I colorize this part of my boot message text? I've read that ANSI is supported, but I've never worked with that before and thus I don't know how to include that, and I can't find anything helpful when researching for this particular situation. I'd be very thankful for any kind of help
Greetings
EdsLx
Last edited by EdsLx (2023-02-06 18:51:49)
Offline
This works for me in /etc/issue:
Welcome to \e{lightmagenta}Arch Linux!\e{reset}See also agetty(1).
EDIT: hold on, that's not what you mean, is it? Please provide the exact steps taken so far, your vague description is too ambiguous, at least for me. Which bootloader are you using?
Last edited by Head_on_a_Stick (2023-02-05 21:22:39)
Jin, Jîyan, Azadî
Offline
EDIT: hold on, that's not what you mean, is it? Please provide the exact steps taken so far, your vague description is too ambiguous, at least for me. Which bootloader are you using?
I've created files in /etc/initcpio/hooks and /etc/initcpio/install and I created a file named bootmsg in /etc. I also appended bootmsg to the HOOKS array in /etc/mkinitcpio.conf and then used the command
sudo mkinitcpio -P This got the boot message on my booting screen. Now I try to colorize the "Arch Linux" in the output, but have no idea how to do that, which is my problem.
I use Grub and can post the content of the mentioned files if necessary.
Last edited by EdsLx (2023-02-05 21:34:28)
Offline
Please provide the hook, the install file, /etc/bootmsg and the GRUB files. Thanks.
I'll be afk until tomorrow though, or maybe later.
Jin, Jîyan, Azadî
Offline
/etc/bootmsg is so hyperspecific that the OP probably got it from https://www.reddit.com/r/linuxquestions … e_on_boot/
The thread also explains that "Welcome to Arch Linux!" comes from systemd: https://cgit.freedesktop.org/systemd/sy … in.c#n1214
You can edit the ansi colors and text in /etc/os-release
Offline
/etc/bootmsg is so hyperspecific that the OP probably got it from https://www.reddit.com/r/linuxquestions … e_on_boot/
Yes, this is exactly what I've used to get my boot message displayed, and I pretty much just pasted the contents of the files on the website into the files I've created (except for /etc/bootmsg).
The thread also explains that "Welcome to Arch Linux!" comes from systemd: https://cgit.freedesktop.org/systemd/sy … in.c#n1214
Well, I didn't quite catch that part...
You can edit the ansi colors and text in /etc/os-release
Doesn't that just change how the "Arch Linux" is displayed when quiet boot is disabled? But I don't want the init messages being displayed, this is why I used a custom boot message. Do you now any other way of doing that? But even if there was another way, I'd still wanted to know how to colorize boot messages, because with them, I can write whatever I want ![]()
Please provide the hook, the install file, /etc/bootmsg and the GRUB files. Thanks.
/etc/initcpio/hooks/bootmsg:
#!/usr/bin/ash
run_hook() {
cat /etc/bootmsg
}/etc/initcpio/install/bootmsg:
#!/usr/bin/ash
build() {
add_file /etc/bootmsg && add_runscript
}
help() {
cat <<HELPEOF
This hooks allows to output an arbitrary boot message.
HELPEOF
}/etc/bootmsg:
Welcome to Arch Linux!Which GRUB files do you need exactly?
Greetings
EdsLx
Offline
cat isn't gonna handle escape sequences, try
printf "$(cat /etc/bootmsg)"(Trilby might know whether there's a cat-free variant for this on ash) or print the desired message directly.
printcolors.sh I somewhen stole together from the internet.
#!/bin/sh
if [ "$1" = "256" ]; then
for fgbg in 38 48 ; do # Foreground / Background
echo "\\e[${fgbg};5;<number>m"
for color in {0..255} ; do # Colors
# Display the color
printf "\e[${fgbg};5;%sm %3s \e[0m" $color $color
# Display 16 colors per lines
if [ $((($color + 1) % 16)) == 0 ] ; then
echo # New line
fi
done
echo # New line
done
else
for x in 0 1 4 5 7 8; do
for i in {30..37}; do
for a in {40..47}; do
printf "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "
done
echo
done
done
echo
fiOffline
cat isn't gonna handle escape sequences, try
printf "$(cat /etc/bootmsg)"
It didn't work, but that might be because I'm using the Ansi escape codes in a wrong way. This is how I try to include them (content of /etc/bootmsg):
Welcome to \u001b[35mArch Linux\u001b[0m!I don't know if that's correct because as I've already mentioned, I've never worked with Ansi before.
printcolors.sh I somewhen stole together from the internet.
#!/bin/sh if [ "$1" = "256" ]; then for fgbg in 38 48 ; do # Foreground / Background echo "\\e[${fgbg};5;<number>m" for color in {0..255} ; do # Colors # Display the color printf "\e[${fgbg};5;%sm %3s \e[0m" $color $color # Display 16 colors per lines if [ $((($color + 1) % 16)) == 0 ] ; then echo # New line fi done echo # New line done else for x in 0 1 4 5 7 8; do for i in {30..37}; do for a in {40..47}; do printf "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m " done echo done done echo fi
I don't quite understand that. Where does that file belong to? (sorry for being so newbie, I'm pretty new to Linux)
Greetings
EdsLx
Offline
You can save that file wherever you want, chmod +x and run it.
It'll print the color escape sequences you can use.
"\e[0m" resets to default.
Offline
Try this in /etc/initcpio/hooks/bootmsg (no need for /etc/bootmsg in this case):
#!/usr/bin/ash
run_hook() {
printf 'Welcome to \e[35;1mArch Linux\e[0m!\n'
}That's the shorthand version :-)
ANSI codes here: https://gist.github.com/fnky/458719343a … a4f7296797
EDIT: used bold code instead of aixterm spec.
Last edited by Head_on_a_Stick (2023-02-06 18:21:52)
Jin, Jîyan, Azadî
Offline
Try this in /etc/initcpio/hooks/bootmsg (no need for /etc/bootmsg in this case):
#!/usr/bin/ash run_hook() { printf 'Welcome to \e[35;1mArch Linux\e[0m!\n' }That's the shorthand version :-)
ANSI codes here: https://gist.github.com/fnky/458719343a … a4f7296797
EDIT: used bold code instead of aixterm spec.
That worked, thanks a lot!
Offline
Pages: 1