]> code.delx.au - refind/commitdiff
Support for multiple default_selection options, to set a series of
authorsrs5694 <srs5694@users.sourceforge.net>
Sun, 15 Dec 2013 06:05:54 +0000 (01:05 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Sun, 15 Dec 2013 06:05:54 +0000 (01:05 -0500)
values in case one isn't available.

NEWS.txt
docs/refind/configfile.html
docs/refind/todo.html
refind.conf-sample
refind/config.c
refind/menu.c

index 163936cd85afaee7e4dcb8c5847adfe1931f40b3..da463e5045c1fa3651bd2673d164a8a6dc89306c 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,6 +1,12 @@
 0.7.6 (12/??/2013):
 -------------------
 
+- Added support for multiple "default_selection" targets. These MUST be
+  comma-separated AND enclosed in quotes, as in:
+  default_selection "fred,ginger"
+  This example will launch "fred" by default if it's available; and if
+  it's not, rEFInd will attempt to launch "ginger" as the default.
+
 - Added support for time-sensitive "default_selection" setting. This token
   may now have either one or three options. If one, it's interpreted as it
   has been in the past, as setting a default that's independent of times.
index 9f78ba9c0a87f405fee9b85f14989791770fb6d6..87fcbfa4b5d4670645a0c6c8bb29a6d7196a3c07 100644 (file)
@@ -319,7 +319,7 @@ timeout 20
 <tr>
    <td><tt>default_selection</tt></td>
    <td>a substring of a boot loader's title, or a numeric position; optionally followed by two times in <tt class="variable">HH:MM</tt> format</td>
-   <td>Sets the default boot OS based on the loader's title, which appears in the main menu beneath the icons when you select the loader. You can enter any substring of the title as the <tt>default_selection</tt>, so long as it's two or more characters in length. It's best to use a unique substring, since rEFInd stops searching when it finds the first match. Because rEFInd sorts entries within a directory in descending order by file modification time, if you specify a directory (or volume name, for loaders in a partition's root directory) as the <tt>default_selection</tt>, the most recent loader in that directory will be the default. One-character entries are matched against the first character of the title, except for digits, which refer to the numeric order of the boot loader entries. You may optionally follow the match string by two times, in 24-hour format, in which case the entry applies only between those two times. For instance, <tt>default_selection Safety 1:30 2:30</tt> boots the entry called <tt>Safety</tt> by default between the hours of 1:30 and 2:30. These times are specified in whatever format the motherboard clock uses (local time or UTC). If the first value is larger than the second, as in <tt>23:00 1:00</tt>, it is interpreted as crossing midnight&mdash;11:00 PM to 1:00 AM in this example. The last <tt>default_selection</tt> setting takes precedence over preceding ones <i>if</i> the time value matches. Thus, you can set a main <tt>default_selection</tt> without a time specification and then set one or more others to override the main setting at specific times.</td>
+   <td>Sets the default boot OS based on the loader's title, which appears in the main menu beneath the icons when you select the loader. You can enter any substring of the title as the <tt>default_selection</tt>, so long as it's two or more characters in length. It's best to use a unique substring, since rEFInd stops searching when it finds the first match. Because rEFInd sorts entries within a directory in descending order by file modification time, if you specify a directory (or volume name, for loaders in a partition's root directory) as the <tt>default_selection</tt>, the most recent loader in that directory will be the default. One-character entries are matched against the first character of the title, except for digits, which refer to the numeric order of the boot loader entries. If you specify a comma-delimited list of names <i><b>in quotation marks,</b></i> rEFInd will search on these in turn until it finds a match. For instance, <tt>default_selection "alpha,beta"</tt> will launch <tt>alpha</tt> if it's available, and <tt>beta</tt> if <tt>alpha</tt> is not available but <tt>beta</tt> is. You may optionally follow the match string by two times, in 24-hour format, in which case the entry applies only between those two times. For instance, <tt>default_selection Safety 1:30 2:30</tt> boots the entry called <tt>Safety</tt> by default between the hours of 1:30 and 2:30. These times are specified in whatever format the motherboard clock uses (local time or UTC). If the first value is larger than the second, as in <tt>23:00 1:00</tt>, it is interpreted as crossing midnight&mdash;11:00 PM to 1:00 AM in this example. The last <tt>default_selection</tt> setting takes precedence over preceding ones <i>if</i> the time value matches. Thus, you can set a main <tt>default_selection</tt> without a time specification and then set one or more others to override the main setting at specific times.</td>
 </tr>
 <tr>
    <td><tt>include</tt></td>
index cd5110faa570b42f4392d6350c04651bfc2f80c3..3beefd540c7532359e926df0f926a3224ce77726 100644 (file)
@@ -201,15 +201,6 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
        checks to substitute the GPT <i>partition</i> label if the
        <i>filesystem</i> label comes up empty.</li>
 
-    <li>The <tt>default_selection</tt> option in <tt>refind.conf</tt> could
-       be improved by supporting a list of default options, so that if the
-       first item isn't found, rEFInd will try to boot the second one in
-       the list, and so on. This could be handy in case a driver fails to
-       load, or to provide an override in case the user inserts a specific
-       removable disk&mdash;by placing the removable disk's name first in
-       the list, it will take precedence over the normal hard disk
-       default.</li>
-
     <li>Along the lines of the previous item, the
        <tt>default_selection</tt> might be expanded to support some form
        of specification of disk types, as in a special entry for any
index 71237d5032fefa82ea218ac29ec8be96794071f0..30dd55e8fd37885013a2d5a49a800b06e6476873 100644 (file)
@@ -272,8 +272,23 @@ scan_all_linux_kernels
 #    will be the default. 
 #  - Any substring that corresponds to a portion of the loader's title
 #    (usually the OS's name or boot loader's path).
+# You may also specify multiple selectors by separating them with commas
+# and enclosing the list in quotes.
+# If you follow the selector(s) with two times, in 24-hour format, the
+# default will apply only between those times. The times are in the
+# motherboard's time standard, whether that's UTC or local time, so if
+# you use UTC, you'll need to adjust this from local time manually.
+# Times may span midnight as in "23:30 00:30", which applies to 11:30 PM
+# to 12:30 AM. You may specify multiple default_selection lines, in which
+# case the last one to match takes precedence. Thus, you can set a main
+# option without a time followed by one or more that include times to
+# set different defaults for different times of day.
 #
 #default_selection 1
+#default_selection Microsoft
+#default_selection "bzImage,vmlinuz"
+#default_selection Maintenance 23:30 2:00
+#default_selection "Maintenance,OS X" 1:00 2:30
 
 # Include a secondary configuration file within this one. This secondary
 # file is loaded as if its options appeared at the point of the "include"
index f86edc836fb8fc597446e45c1459eba2312db1e8..e9d2e559f1248fde8171e56151270d26e73fb135 100644 (file)
@@ -397,6 +397,8 @@ static VOID SetDefaultByTime(IN CHAR16 **TokenList, OUT CHAR16 **Default) {
 
    if ((StartTime <= LAST_MINUTE) && (EndTime <= LAST_MINUTE)) {
       Status = refit_call2_wrapper(GetTime, &CurrentTime, NULL);
+      if (Status != EFI_SUCCESS)
+         return;
       Now = CurrentTime.Hour * 60 + CurrentTime.Minute;
 
       if (Now > LAST_MINUTE) { // Shouldn't happen; just being paranoid
index c2ad279baab2692f196eeed66d59cbc25825ac2a..eb49b926ba196d0c6c4771780ce96fa8abed1c0c 100644 (file)
@@ -305,29 +305,34 @@ VOID AddMenuEntry(IN REFIT_MENU_SCREEN *Screen, IN REFIT_MENU_ENTRY *Entry)
 }
 
 
-static INTN FindMenuShortcutEntry(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *Shortcut)
+static INTN FindMenuShortcutEntry(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *Defaults)
 {
-    UINTN i;
-
-    if (Shortcut == NULL)
-       return (-1);
-
-    if (StrLen(Shortcut) == 1) {
-      if (Shortcut[0] >= 'a' && Shortcut[0] <= 'z')
-         Shortcut[0] -= ('a' - 'A');
-      if (Shortcut[0]) {
-         for (i = 0; i < Screen->EntryCount; i++) {
-               if (Screen->Entries[i]->ShortcutDigit == Shortcut[0] || Screen->Entries[i]->ShortcutLetter == Shortcut[0]) {
-                  return i;
-               } // if
-         } // for
-      } // if
-    } else if (StrLen(Shortcut) > 1) {
-       for (i = 0; i < Screen->EntryCount; i++) {
-          if (StriSubCmp(Shortcut, Screen->Entries[i]->Title))
-             return i;
-       } // for
-    }
+    UINTN i, j = 0;
+    CHAR16 *Shortcut;
+
+    while ((Shortcut = FindCommaDelimited(Defaults, j)) != NULL) {
+       if (StrLen(Shortcut) == 1) {
+         if (Shortcut[0] >= 'a' && Shortcut[0] <= 'z')
+            Shortcut[0] -= ('a' - 'A');
+         if (Shortcut[0]) {
+            for (i = 0; i < Screen->EntryCount; i++) {
+                  if (Screen->Entries[i]->ShortcutDigit == Shortcut[0] || Screen->Entries[i]->ShortcutLetter == Shortcut[0]) {
+                     MyFreePool(Shortcut);
+                     return i;
+                  } // if
+            } // for
+         } // if
+       } else if (StrLen(Shortcut) > 1) {
+          for (i = 0; i < Screen->EntryCount; i++) {
+             if (StriSubCmp(Shortcut, Screen->Entries[i]->Title)) {
+                MyFreePool(Shortcut);
+                return i;
+             } // if
+          } // for
+       }
+       MyFreePool(Shortcut);
+       j++;
+    } // while()
     return -1;
 }