]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Add default/grub support
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 23 May 2010 12:11:11 +0000 (14:11 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 23 May 2010 12:11:11 +0000 (14:11 +0200)
docs/grub.texi
util/grub-mkconfig.in
util/grub.d/00_header.in

index 704f8b2a35e9b167ff8e682f2284348a25b444b6..938fedbafec15c7aaf1f40c47004dee5e139bb7a 100644 (file)
@@ -80,6 +80,7 @@ This edition documents version @value{VERSION}.
 * Configuration::               Writing your own configuration file
 * Network::                     Downloading OS images from a network
 * Serial terminal::             Using GRUB via a serial line
+* Vendor power-on keys::        Changing GRUB behaviour on vendor power-on keys
 * Preset Menu::                 Embedding a configuration file into GRUB
 * Images::                      GRUB image files
 * Filesystem::                  Filesystem syntax and semantics
@@ -747,6 +748,21 @@ implements few VT100 escape sequences. If you specify this option then
 GRUB provides you with an alternative menu interface, because the normal
 menu requires several fancy features of your terminal.
 
+@node Vendor power-on keys
+@chapter Using GRUB with vendor power-on keys
+Some laptop vendor provide an additional power-on button which boots another OS.
+GRUB supports such buttons with GRUB_TIMEOUT_BUTTON, GRUB_DEFAULT_BUTTON,
+GRUB_HIDDEN_TIMEOUT_BUTTON and GRUB_BUTTON_CMOS_ADDRESS variables in
+default/grub. GRUB_TIMEOUT_BUTTON, GRUB_DEFAULT_BUTTON and 
+GRUB_HIDDEN_TIMEOUT_BUTTON are used instead of corresponding variables without
+_BUTTON suffix when powered using special button.
+GRUB_BUTTON_CMOS_ADDRESS is vendor specific and partially model-specific.
+Values known to GRUB team are:
+
+@table @key
+@item Dell XPS M1530
+85:3
+@end table
 
 @node Filesystem
 @chapter Filesystem syntax and semantics
index d1abfa36a06c08ae0b38d38e3245b4ab174afba2..0095e1ce870de7e19ac42283679515da63a9fd36 100644 (file)
@@ -246,6 +246,10 @@ export GRUB_DEFAULT \
   GRUB_HIDDEN_TIMEOUT \
   GRUB_HIDDEN_TIMEOUT_QUIET \
   GRUB_TIMEOUT \
+  GRUB_DEFAULT_BUTTON \
+  GRUB_HIDDEN_TIMEOUT_BUTTON \
+  GRUB_TIMEOUT_BUTTON \
+  GRUB_BUTTON_CMOS_ADDRESS \
   GRUB_DISTRIBUTOR \
   GRUB_CMDLINE_LINUX \
   GRUB_CMDLINE_LINUX_DEFAULT \
index d181fdffc93de39b2ed116c00da1c90d548da91b..df8f5dfaa13e2f7290b0ce1e5f33c06f16afa05b 100644 (file)
@@ -38,11 +38,29 @@ if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
 if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
 if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
 
+if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
+if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi
+if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi
+
 cat << EOF
 if [ -s \$prefix/grubenv ]; then
   load_env
 fi
+EOF
+if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
+    cat <<EOF
+if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
+   set default="${GRUB_DEFAULT_BUTTON}"
+else
+   set default="${GRUB_DEFAULT}"
+fi
+EOF
+else
+    cat <<EOF
 set default="${GRUB_DEFAULT}"
+EOF
+fi
+cat <<EOF
 if [ \${prev_saved_entry} ]; then
   set saved_entry=\${prev_saved_entry}
   save_env saved_entry
@@ -186,21 +204,36 @@ insmod gettext
 EOF
 fi
 
-if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
-  if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
-    verbose=
-  else
-    verbose=" --verbose"
-  fi
-  cat << EOF
-if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then
-  set timeout=${GRUB_TIMEOUT}
+make_timeout ()
+{
+    if [ "x${1}" != "x" ] ; then
+       if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
+           verbose=
+       else
+           verbose=" --verbose"
+       fi
+       cat << EOF
+if sleep$verbose --interruptible ${1} ; then
+  set timeout=${2}
 fi
 EOF
-else
-  cat << EOF
-set timeout=${GRUB_TIMEOUT}
+    else
+       cat << EOF
+set timeout=${2}
 EOF
+    fi
+}
+
+if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
+    cat <<EOF
+if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
+EOF
+make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}"
+echo else
+make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
+echo fi
+else
+make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
 fi
 
 # Play an initial tune