From f4a7650094961325b989e080d9055ee3a152932b Mon Sep 17 00:00:00 2001
From: Andrew Robbins <contact@andrewrobbins.info>
Date: Mon, 7 Aug 2017 02:22:22 -0400
Subject: Replace hardcoded env variables, add keymap command

The command 'loadfont' was removed because the environment variable
'gfxterm_font' is inspected by GRUB and automatically sets the font to
its value if 'gfxterm' is in the list of active output terminals.
---
 projects/grub/install/txtmode/grub.cfg     | 14 +++++---------
 projects/grub/install/txtmode/grubtest.cfg | 14 +++++---------
 projects/grub/install/vesafb/grub.cfg      | 19 +++++++------------
 projects/grub/install/vesafb/grubtest.cfg  | 19 +++++++------------
 4 files changed, 24 insertions(+), 42 deletions(-)

diff --git a/projects/grub/install/txtmode/grub.cfg b/projects/grub/install/txtmode/grub.cfg
index c668544b..90946c01 100644
--- a/projects/grub/install/txtmode/grub.cfg
+++ b/projects/grub/install/txtmode/grub.cfg
@@ -1,5 +1,3 @@
-set prefix=(memdisk)/boot/grub
-
 insmod nativedisk
 insmod ehci
 insmod ohci
@@ -16,16 +14,14 @@ terminal_input --append  serial
 terminal_output --append serial
 terminal_input --append at_keyboard
 terminal_output --append cbmemc
-
-gfxpayload=keep
 terminal_output --append gfxterm
 
-# Default to first option, automatically boot after 1 second
-set default="0"
-set timeout=1
+load_env --file (cbfsdisk)/grubenv
 
-# This is useful when using 'cat' on long files on GRUB terminal
-set pager=1
+# User's preferred keyboard layout
+if [ -n "${keymap}" ]; then
+	keymap "${keymap}"
+fi
 
 function try_user_config {
 	set root="${1}"
diff --git a/projects/grub/install/txtmode/grubtest.cfg b/projects/grub/install/txtmode/grubtest.cfg
index 6ffeace7..d9ab637d 100644
--- a/projects/grub/install/txtmode/grubtest.cfg
+++ b/projects/grub/install/txtmode/grubtest.cfg
@@ -1,5 +1,3 @@
-set prefix=(memdisk)/boot/grub
-
 insmod nativedisk
 insmod ehci
 insmod ohci
@@ -16,16 +14,14 @@ terminal_input --append  serial
 terminal_output --append serial
 terminal_input --append at_keyboard
 terminal_output --append cbmemc
-
-gfxpayload=keep
 terminal_output --append gfxterm
 
-# Default to first option, automatically boot after 1 second
-set default="0"
-set timeout=1
+load_env --file (cbfsdisk)/grubenv
 
-# This is useful when using 'cat' on long files on GRUB terminal
-set pager=1
+# User's preferred keyboard layout
+if [ -n "${keymap}" ]; then
+	keymap "${keymap}"
+fi
 
 function try_user_config {
 	set root="${1}"
diff --git a/projects/grub/install/vesafb/grub.cfg b/projects/grub/install/vesafb/grub.cfg
index e057e88b..f61e2684 100644
--- a/projects/grub/install/vesafb/grub.cfg
+++ b/projects/grub/install/vesafb/grub.cfg
@@ -1,5 +1,3 @@
-set prefix=(memdisk)/boot/grub
-
 insmod nativedisk
 insmod ehci
 insmod ohci
@@ -17,20 +15,17 @@ terminal_input --append  serial
 terminal_output --append serial
 terminal_input --append at_keyboard
 terminal_output --append cbmemc
-
-gfxpayload=keep
 terminal_output --append gfxterm
 
-# Prettify GRUB
-background_image (cbfsdisk)/background.png
-loadfont (cbfsdisk)/dejavusansmono.pf2
+load_env --file (cbfsdisk)/grubenv
 
-# Default to first option, automatically boot after 1 second
-set default="0"
-set timeout=1
+# User's preferred keyboard layout
+if [ -n "${keymap}" ]; then
+	keymap "${keymap}"
+fi
 
-# This is useful when using 'cat' on long files on GRUB terminal
-set pager=1
+# Prettify GRUB
+background_image "${gfxterm_background}"
 
 function try_user_config {
 	set root="${1}"
diff --git a/projects/grub/install/vesafb/grubtest.cfg b/projects/grub/install/vesafb/grubtest.cfg
index d0e0b46e..50beb915 100644
--- a/projects/grub/install/vesafb/grubtest.cfg
+++ b/projects/grub/install/vesafb/grubtest.cfg
@@ -1,5 +1,3 @@
-set prefix=(memdisk)/boot/grub
-
 insmod nativedisk
 insmod ehci
 insmod ohci
@@ -17,20 +15,17 @@ terminal_input --append  serial
 terminal_output --append serial
 terminal_input --append at_keyboard
 terminal_output --append cbmemc
-
-gfxpayload=keep
 terminal_output --append gfxterm
 
-# Prettify GRUB
-background_image (cbfsdisk)/background.png
-loadfont (memdisk)/dejavusansmono.pf2
+load_env --file (cbfsdisk)/grubenv
 
-# Default to first option, automatically boot after 1 second
-set default="0"
-set timeout=1
+# User's preferred keyboard layout
+if [ -n "${keymap}" ]; then
+	keymap "${keymap}"
+fi
 
-# This is useful when using 'cat' on long files on GRUB terminal
-set pager=1
+# Prettify GRUB
+background_image "${gfxterm_background}"
 
 function try_user_config {
 	set root="${1}"
-- 
cgit v1.2.3-70-g09d2