mintTool to select OS for next reboot

Write suggestions and new ideas in here
More ideas here
Forum rules
  • Only post ideas here that are specifically about the Linux Mint distribution or its websites.
  • So that developers and users from any distribution can discuss ideas in one place, post ideas about improving software to the collaboration website for that software instead.
Post Reply
User avatar
Level 3
Level 3
Posts: 168
Joined: Sun Aug 24, 2008 2:41 am
Location: Luxembourg

mintTool to select OS for next reboot

Post 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.
Sorry for my BAD English!!
Level 1
Level 1
Posts: 29
Joined: Thu Jun 21, 2007 3:36 am

Re: mintTool to select OS for next reboot

Post 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!!
Level 3
Level 3
Posts: 128
Joined: Fri Sep 12, 2008 10:16 pm

Re: mintTool to select OS for next reboot

Post 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.
User avatar
Level 10
Level 10
Posts: 3337
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: mintTool to select OS for next reboot

Post 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. :-)


Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
Level 1
Level 1
Posts: 13
Joined: Wed Jul 08, 2009 2:39 pm

Re: mintTool to select OS for next reboot

Post 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.
User avatar
Level 7
Level 7
Posts: 1878
Joined: Wed Jun 17, 2009 7:38 pm
Location: an island in the Pacific...

Re: mintTool to select OS for next reboot

Post 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.
User avatar
Level 7
Level 7
Posts: 1878
Joined: Wed Jun 17, 2009 7:38 pm
Location: an island in the Pacific...

Re: mintTool to select OS for next reboot

Post 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

Level 8
Level 8
Posts: 2158
Joined: Thu Feb 26, 2009 8:58 pm

Re: mintTool to select OS for next reboot

Post 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
If you have a question that has been answered and solved, then please edit your original post and put a [SOLVED] at the end of your subject header
Hint - use a google search including the search term
Post Reply

Return to “Suggestions & New Ideas”