Page 1 of 1

mintTool to select OS for next reboot

Posted: Fri Dec 26, 2008 6:01 am
by knuckles
i think a lot of people use a dual-Boot with a Windows installation.
i personally have made the complete jump to Linux for the normal PC work, but for games I must use Windows.

So when I'm in windows and have finished with playing i restart and Mint start automatically, because it is marked as default in grub.

But when I'm in Mint, and will play, i must choice in the dual-boot my Windows, so i must be in front of the screen while the reboot :(

OpenSuse had in there KDE3-time with the kickoff menu an option "Boot in Windows" or so. But know with KDE4 they have remove that option or not implant it.

A MintTool or an addition in the MintMenu would be great to realizes somethink like that.

Re: mintTool to select OS for next reboot

Posted: Tue Dec 30, 2008 12:56 pm
by @go
I agree!!!! I was writing the same topic!!! This functionality is still there in openSUSE KDE4, in a different way though. I miss this functionality a lot!!

Re: mintTool to select OS for next reboot

Posted: Thu Jul 09, 2009 10:44 pm
by curt_grymala
Plus one from me. This was always a feature I greatly valued in the KDE version of SuSE. I would love to see it somehow added to the Gnome version (and any other version) of Mint.

Re: mintTool to select OS for next reboot

Posted: Thu Jul 09, 2009 11:53 pm
by Fred

Actually, that isn't a bad idea. :-) Maybe with a little sub-menu to select the OS to reboot, not just Windows. Believe it or not, one or two of us don't use Windows. :-)



Re: mintTool to select OS for next reboot

Posted: Thu Jul 09, 2009 11:55 pm
by johnnyj

Code: Select all

echo "savedefault --default=2 --once" | grub --batch
According to, this will make grub boot into the second choice on the grub menu on the next boot, without changing your default OS. I haven't tested it, but it seems like a good starting point. Then you could probably write a program to find out the first entry, the second entry, etc. and have the user choose which one to boot into on their next boot.

Re: mintTool to select OS for next reboot

Posted: Fri Jul 10, 2009 12:42 am
by lagagnon
This is a good idea. It would not be difficult to implement because the command to use would be "grub-reboot" (see man "grub-reboot"). It requires root access, a number corresponding to the OS entry in /boot/grub/menu.lst.

It would not even require Python programming because I am sure Zenity could be used as the onscreen dialog boxes, so a simple script would do it.

Re: mintTool to select OS for next reboot

Posted: Fri Jul 10, 2009 1:13 am
by lagagnon
NewsFlash! Exactly this tool has already been written for Fedora, in Python - here it is: ... /bootnext/

I've converted the RPM to DEB using "alien" and am testing the Python code now....
OK, here it is - I changed one line and it works great:

Code: Select all


# bootnext: Tell GRUB what kernel to boot for the next boot only, and reboot
# Allows user to choose which OS to reboot into for next reboot only.
# Useful for folks who dual-boot another OS occasionaly but don't want to
# permanently change the default.
# Default menu choice is set to match expression DEFAULT_TITLE_RE.
# If a command line argument is present, that is used instead 
# of DEFAULT_TITLE_RE.  In either case, expressions are Python regexs.
# Must be run with superuser privileges.
# The menu is graphical, and requires that X be running and zenity is
# installed.
# For non-Fedora distros,  change GRUB_CONFIG accordingly.
# Written by Jack Spaar <jspaar-at-myrealbox-dot-com>
# Released under the terms of the GNU General Public License.
# Changelog:
# Wed Feb 11 20:01:30 PST 2004 -- Created.
# Wed Mar  3 18:05:05 PST 2004 -- added OK/Cancel prompt.
# Sun Mar 14 22:28:07 PST 2004 -- use zenity to choose grub title to boot.
# Fri Jun 11 14:04:33 PDT 2004 -- use --batch with grub.
# Tue Nov 30 20:47:31 PST 2004 -- use --no-floppy to avoid probe hang on FC3.
# Thu Jan 27 22:32:41 PST 2005 -- allow a regex for finding default title
# Wed Feb  2 19:56:11 PST 2005 -- allow default title on command line
# Tue Aug 23 18:42:37 PDT 2005 -- packaged as rpm
# Sat Dec  2 00:00:34 PST 2006 -- use absolute path for zenity, tweak win width
# Fri Jun  1 15:18:47 PDT 2007 -- use /boot/grub/grub.conf instead of /etc/...
# v0.12

import re, os, sys

progName = "bootnext"

# Edit the following to set the default menu selection
# 	Note: command line argument overrides this default.
DEFAULT_TITLE_RE = "(?!.*Fedora)"	# match first non-Fedora title.

# Non-Fedora distros often use /boot/grub/menu.lst instead
GRUB_CONFIG = "/boot/grub/menu.lst"

GRUB_PATH =  "/sbin/grub --batch --no-floppy"
DIALOG_TEXT = "Select which OS to boot:"

ZENITY_PATH = "/usr/bin/zenity"

REBOOT_COMMAND = "/sbin/shutdown -r now &"

def grub_title_list():
	f = open(GRUB_CONFIG, 'r')
	lines = f.readlines()

	p = re.compile('^\s*title\s*(.*)')
	tlist = []

	for line in lines:
		m = p.match(line)
		if m : 
			tlist = tlist + [ ]

	return tlist


if (len(sys.argv) > 1) :
    default_title_re = sys.argv[1]
    default_title_re = DEFAULT_TITLE_RE

titles = grub_title_list()

# form a zenity command to allow user to select from the grub title list
zen = '%s --width %d --height %d --list --radiolist --title "%s" --text "%s" --column "Selected" --column  "Boot Title"  ' % (ZENITY_PATH, ZENITY_WIDTH, ZENITY_HEIGHT, progName, DIALOG_TEXT)

p = re.compile(default_title_re)
default_found = 0
for title in titles:
	# Turn on radio button for 1st title matching DEFAULT_TITLE_RE
	if ((not default_found) and (p.match(title))):
		zen += " TRUE "		
		default_found = 1
		zen += " FALSE "
	zen += "\"%s\"" % (title)

# run zenity and grab the user's choice
pipe = os.popen(zen, 'r')
choice ="\n")
okCancel = pipe.close()
if (okCancel != None):
	print "Cancelled."

# convert the title to a grub index number
num = 0
for title in titles:
	if (title == choice):
	num += 1

# Now tell GRUB we want that other OS for the next boot only
grubCommands ='savedefault --default=%s --once\nquit\n'%(num)

pipe = os.popen(GRUB_PATH, 'w')

# Now reboot


Re: mintTool to select OS for next reboot

Posted: Sun Jul 12, 2009 12:50 pm
by emorrp1
yeah, I know many people who want to tweak their boot setup, so this would be a welcome addition once you add a gui