You are not logged in.

#1 2023-09-03 19:08:46

M440
Member
Registered: 2023-08-24
Posts: 28

arch-grub-renamer bash script changing labels according to version

The bash script renames grub kernel labels according to pacman installed package version (pacman -Q --info linux | grep version).

https://github.com/M8850/arch-grub-renamer

Usage:
grubnamer <grub.cfg file>

If the file is "/boot/grub/grub.cfg" the script will generate the file first (by initiating: grub-mkconfig -o /boot/grub/grub.cfg). That way it is convenient to run it after any change in "/etc/default/grub" or kernel package update.

It is recommended to set the flag "GRUB_DISABLE_SUBMENU=y" (/etc/default/grub) so all kernels will be visible without the need to access the submenu.

Example:

Linux linux ----> 6.4.12.arch1-1
Linux linux-lts ----> 6.1.51.lts-1
Linux linux-zen ----> 6.4.12.zen1-1

'Arch Linux,  6.4.12.arch1-1'
'Arch Linux,  6.1.51.lts-1'
'Arch Linux,  6.4.12.zen1-1'

'Loading 6.4.12.arch1-1 ...'
'Loading 6.1.51.lts-1 ...'
'Loading 6.4.12.zen1-1 ...'


#!/bin/sh
if [ -z "$1" ]; then
  echo "No file"
  exit 2
fi


if [  "$1" == "/boot/grub/grub.cfg"  ]; then
  grub-mkconfig -o /boot/grub/grub.cfg
fi

echo

pacman -Q --info linux-zen | grep Versio
pacman -Q --info linux-lts | grep Versio
pacman -Q --info linux | grep Versio

echo

linux=$(pacman -Q --info linux | grep Version | sed 's/ //g'| sed 's/Version://')
linuxzen=$(pacman -Q --info linux-zen | grep Version | sed 's/ //g'| sed 's/Version://')
linuxlts=$(pacman -Q --info linux-lts | grep Version | sed 's/ //g'| sed 's/Version://'| sed 's/-/.lts-/')

linuxltsreplace=$"Linux linux-lts"
linuxzenreplace=$"Linux linux-zen"
linuxreplace=$"Linux linux"



echo $linuxzen
echo $linuxlts
echo $linux
echo
echo $linuxzenreplace
echo $linuxltsreplace
echo $linuxreplace
echo


#echo ($linux   $linuxreplace)
#echo ($linuxzen   $linuxzenreplace)
#echo ($linuxlts   $linuxltsreplace)
#echo " "


echo -n $linuxzenreplace
echo -n " ----> "
echo $linuxzen
echo -n $linuxltsreplace
echo -n " ----> "
echo  $linuxlts
echo -n $linuxreplace 
echo -n " ----> "
echo $linux
echo
echo $1
echo

#sed -i 's/Linux linux-lts/Linux-LTS 6.1.50/g' /boot/grub/grub.cfg
#sed -i 's/Linux linux-zen/Linux-ZEN 6.4.12/g' /boot/grub/grub.cfg
#sed -i 's/Linux linux/Linux 6.4.12/g' /boot/grub/grub.cfg
sed -i "s/$linuxltsreplace/$linuxlts/g" $1
sed -i "s/$linuxzenreplace/$linuxzen/g" $1
sed -i "s/$linuxreplace/$linux/g" $1
sed -i "s/with//g" $1

cat $1 | grep Loading | sed 's/echo//g'
echo

Last edited by M440 (2023-09-03 19:46:59)

Offline

Board footer

Powered by FluxBB