On 11/24/2010 09:21 AM, Colin Watson wrote:
What do people think of this?  It's a remarkably small change now that
Vladimir's implemented submenus, and I've had a number of requests for
it.

<snip>

        * util/grub.d/10_linux.in: Put second and subsequent menu entries in
        a submenu.

<snip>

+    echo "submenu \"Previous Linux versions\" {"

Since most users don't need to know what kernel version is being used by default, I think we should simplify the title of the default menu entry (by removing the "with Linux ...") and have a submenu labeled "Advanced options for $OS". This submenu would include all kernel entries, including the first entry (which would also be booted if you just selected the main entry instead of going to the submenu). So the submenu would look exactly like the main menu currently does, except only listing kernel entries for one OS.

I've attached a proof of concept patch which does this.

--
Jordan Uggla (Jordan_U on irc.freenode.net)
=== modified file 'util/grub.d/10_linux.in'
--- util/grub.d/10_linux.in	2010-11-01 11:49:40 +0000
+++ util/grub.d/10_linux.in	2010-11-25 01:03:00 +0000
@@ -55,15 +55,25 @@
 {
   os="$1"
   version="$2"
-  recovery="$3"
+  type="$3"
   args="$4"
-  if ${recovery} ; then
-    title="$(gettext_quoted "%s, with Linux %s (recovery mode)")"
+
+  case $type in
+  simple)
+    title="$(gettext_quoted "%s")" ;;
+  recovery)
+    title="$(gettext_quoted "%s, with Linux %s (recovery mode)")" ;;
+  *)
+    title="$(gettext_quoted "%s, with Linux %s")" ;;
+  esac
+
+  if [ x$type = xsimple ]; then
+    printf "menuentry '${title}' ${CLASS} {\n" "${os}"
   else
-    title="$(gettext_quoted "%s, with Linux %s")"
+    printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}"
   fi
-  printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}"
-  if ! ${recovery} ; then
+
+  if [ x$type != xrecovery ] ; then
       save_default_entry | sed -e "s/^/\t/"
   fi
 
@@ -114,6 +124,8 @@
       done`
 prepare_boot_cache=
 
+is_first_entry=true
+
 while [ "x$list" != "x" ] ; do
   linux=`version_find_latest $list`
   echo "Found linux image: $linux" >&2
@@ -151,12 +163,26 @@
     linux_root_device_thisversion=${GRUB_DEVICE}
   fi
 
-  linux_entry "${OS}" "${version}" false \
+  if [ x$is_first_entry = xtrue ]; then
+    linux_entry "${OS}" "${version}" simple \
+    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+
+    cat << EOF
+submenu '$(gettext_quoted "Advanced options for ${OS}")' {
+EOF
+  fi
+
+  linux_entry "${OS}" "${version}" advanced \
       "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
   if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
-    linux_entry "${OS}" "${version}" true \
+    linux_entry "${OS}" "${version}" recovery \
 	"single ${GRUB_CMDLINE_LINUX}"
   fi
 
   list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+  is_first_entry=false
 done
+
+if [ x$is_first_entry != xtrue ]; then #At least 1 kernel found, submenu started
+  echo '}'
+fi

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to