#795136 grub-common: Possibility to prevent effect from GRUB_TIMEOUT=0 by keyboard during boot.

Package:
grub-common
Source:
grub2
Description:
GRand Unified Bootloader (common files)
Submitter:
Oleksandr Gavenko
Date:
2015-08-10 20:57:05 UTC
Severity:
normal
#795136#5
Date:
2015-08-10 20:54:17 UTC
From:
To:
I like GRUB_TIMEOUT=0 setting as always think that holding SHIFT or ESC key
during boot stop GRUB2 from automatically selecting menu entry.

Shift key come in mind from https://help.ubuntu.com/community/Grub2 article.

But holding shift does not stop GRUB from loading, this may be achieved by
config like (I test it):

  $ cat /sudo:root@deblaptop:/etc/grub.d/50_shift_key

  #!/bin/sh
  cat <<EOF
  if keystatus --shift ; then
      set timeout=-1
  fi
  EOF

I have filling that "keystatus --shift" check I already have seen in GRUB
configs (in more complicated condition check), but it was removed in newer
package versions.

I don't know proper number for script but /etc/grub.d/00_header and
/etc/grub.d/30_os-prober have assignment to $timeout so must come after them.

It is possible to rewrite condition into somewhat safer variant - change
behavior only when timeout too small (not tested for syntax correctness):

  if [ $timeout -ge 0 -a $timeout -le 2 ] ; then
    if keystatus --shift ; then
        set timeout=-1
    fi
  fi