GRUB: Boot another OS once

Description
If you like me have GNU/Linux as the primary OS and a Windows system for gaming you sometimes have to reboot the system and wait for grub to start. Once grub has started you have a couple of seconds to change to Windows or GNU/Linux will boot. As I often don't feel like waiting while the system reboots I do something else and misses grub and have to reboot again. This guide will tell you how to make grub start windows upon the next reboot only and how to use this method to do other similar tasks like toogle OS upon restart.

As I've understood some distributions (e.g. opensuse and other rpm-based) ship a tool called "grubonce" which "should" replace grub-set-default (method 2), however it is not part of grub and is merely a wrapper script. It does the same thing as "echo --once | grub --batch" except method 1 works on all grub installations.

Method 1 (preferred)
In some newer versions of GNU/Linux, there is no (eg. Debian 3.1, Fedora Core 4,5). While some distributions like Gentoo still has, this method is preferred. With this method you don't need to edit, or anything else either.

Remember to replace "2" to match your own config!

When you reboot your computer (echo "savedefault --default=2 --once" | grub --batch; reboot), GRUB will bypass (only once) "timeout" and "default" settings from, and boot to your selected OS. After next reboot, GRUB will use "timeout" and "default" settings from, again.

Method 2 (deprecated)
This method is deprecated and won't work on some distributions.

Edit the ( on some systems) and change "default" to "saved". I'm using the following settings:

Note: To make this work you have to run followed by the entry you wish to use as default before you restart the system.

Changing the default settings from a script
This is really simple, either just run to change or use a small wrapper like this:

creates the file containing which OS to start. GRUB can change this from it's shell and thus when the bootscreen appears. Remember to replace "2" to match your own config!

Make GRUB restore to the primary OS
Edit to run savedefault when starting Windows.

That should do it. Now running the script changes the default entry to 2 (Wintendo) and when GRUB starts that entry it changes the default entry to 1.