Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Importing 0.3

  • Loading branch information...
commit 2eca658cbedda3fe2e7bc6c59e6db4d2a36234c0 1 parent 77e479a
David Mohr authored
View
1  .gitignore
@@ -0,0 +1 @@
+grub-choose-default.8
View
2  ChangeLog
@@ -0,0 +1,2 @@
+Version 0.3, 2008-05-29
+ Applied patches from Kjell Braden to fix some crashes and to add a manpage.
View
2  Makefile
@@ -0,0 +1,2 @@
+grub-choose-default.8: grub-choose-default.sgml
+ docbook-to-man $< > $@
View
20 README
@@ -1,9 +1,9 @@
/============================================================================\
| grub-choose-default.py |
| |
-| Copyright 2007, David Mohr <david@mcbf.net> |
+| Copyright 2007-2008, David Mohr <david@mcbf.net> |
| |
-| Version 0.2, 2007-07-28 |
+| Version 0.3, 2008-05-29 |
| |
| Released under the GNU GPL v2 or higher |
| This is free software; see the source for copying conditions. There is NO |
@@ -11,6 +11,8 @@
| |
\============================================================================/
+Homepage: http://da.mcbf.net/wiki/GrubChooseDefault
+
A simple python GUI program to set your grub default for the next reboot.
It should run fine both under Linux and Windows. Note though that under Windows
you need to get filesystem access to your /boot to modify the grub
@@ -27,7 +29,8 @@ What it does is:
It uses Tkinter, because that's included in every python installation.
-************************************************************************
+
+*****************************************************************************
* Reboot
********
@@ -51,5 +54,16 @@ but I won't include that until someone complains to me, as that's rare
nowadays).
+*****************************************************************************
+
+Right now grub-choose-default only works with legacy grub (0.xx). If there is
+demand for grub 2 compatability, let the author know and an update will be
+considered :-).
+
+
Please email me with any questions, comments or if you should find a bug at
david@mcbf.net.
+
+
+Many thanks to Kjell Braden for sending some patches and getting
+grub-choose-default into debian!
View
19 grub-choose-default.py
@@ -172,7 +172,7 @@ def get_win_menu():
m = get_menu(drive)
if m != None:
return m
- raise IOError, "grub's menu.lst not found"
+ return None
def init():
global grub_menu, grub_default_file, grub_menu_locs
@@ -181,7 +181,13 @@ def init():
else:
grub_menu = get_menu("/")
-
+ if grub_menu is None:
+ print >> sys.stderr, "Could not find grub's menu.lst."
+ print >> sys.stderr, "Please make sure you're using legacy grub (ie. "\
+ "not grub2)"
+ print >> sys.stderr, "Aborting."
+ sys.exit(os.errno.ENOENT)
+
grub_default_file = os.path.join(os.path.split(grub_menu)[0], 'default')
print >> sys.stderr, "Using", grub_menu, "and", grub_default_file
@@ -213,10 +219,13 @@ def get_grub_default():
fdefault.close()
#print default_file
match = re.search("^\d+", default_file[0])
- old_default = match.group()
- #print old_default, "was the old default"
+ if match:
+ old_default = match.group()
+ #print old_default, "was the old default"
- return (default_file, int(old_default))
+ return (default_file, int(old_default))
+ else:
+ return (default_file, None)
def change_grub_config_default():
print >> sys.stderr, "Updating configuration with 'default saved' (backup saved as "+grub_menu+"~)"
View
141 grub-choose-default.sgml
@@ -0,0 +1,141 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+
+<!-- Process this file with docbook-to-man to generate an nroff manual
+ page: `docbook-to-man manpage.sgml > manpage.1'. You may view
+ the manual page with: `docbook-to-man manpage.sgml | nroff -man |
+ less'. A typical entry in a Makefile or Makefile.am is:
+
+manpage.1: manpage.sgml
+ docbook-to-man $< > $@
+
+
+ The docbook-to-man binary is found in the docbook-to-man package.
+ Please remember that if you create the nroff version in one of the
+ debian/rules file targets (such as build), you will need to include
+ docbook-to-man in your Build-Depends control field.
+
+ -->
+
+ <!-- Fill in your name for FIRSTNAME and SURNAME. -->
+ <!ENTITY dhfirstname "<firstname>Kjell</firstname>">
+ <!ENTITY dhsurname "<surname>Braden</surname>">
+ <!-- Please adjust the date whenever revising the manpage. -->
+ <!ENTITY dhdate "<date>2008-05-29</date>">
+ <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
+ allowed: see man(7), man(1). -->
+ <!ENTITY dhsection "<manvolnum>8</manvolnum>">
+ <!ENTITY dhemail "<email>fnord@pentabarf.de</email>">
+ <!ENTITY dhusername "Kjell Braden">
+ <!ENTITY dhucpackage "<refentrytitle>GRUB-CHOOSE-DEFAULT</refentrytitle>">
+ <!ENTITY dhpackage "grub-choose-default">
+
+ <!ENTITY debian "<productname>Debian</productname>">
+ <!ENTITY gnu "<acronym>GNU</acronym>">
+ <!ENTITY gpl "&gnu; <acronym>GPL</acronym>">
+]>
+
+<refentry>
+ <refentryinfo>
+ <address>
+ &dhemail;
+ </address>
+ <author>
+ &dhfirstname;
+ &dhsurname;
+ </author>
+ <copyright>
+ <year>2007</year>
+ <holder>&dhusername;</holder>
+ </copyright>
+ &dhdate;
+ </refentryinfo>
+ <refmeta>
+ &dhucpackage;
+
+ &dhsection;
+ </refmeta>
+ <refnamediv>
+ <refname><command>&dhpackage;</command></refname>
+
+ <refpurpose>control grub's default through a GUI</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>&dhpackage;</command>
+
+ <arg><option>-r</option></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>DESCRIPTION</title>
+
+ <para><command>&dhpackage;</command> is a small GUI program which displays
+ your grub entries in a menu and lets you quickly change the default
+ without having to go to the command line as well as looking up the index
+ of the new default.</para>
+
+ <para>Additionally <command>&dhpackage;</command> works also under the
+ certain other operating system which resembles an opening in the wall,
+ since it is written in Python. Other OSes have not been tested.</para>
+
+ <para>At this point in time it only works for legacy grub (0.xx).</para>
+
+ </refsect1>
+ <refsect1>
+ <title>OPTIONS</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><option>-r</option>
+ </term>
+ <listitem>
+ <para>If used, <command>&dhpackage;</command> will show the reboot
+ option, which is disabled by default.</para>
+ <para>Note that this only controls the display of the reboot button,
+ the actual reboot logic is outside of the scope of this program.
+ Please check the included support scripts, which provide the
+ functionality for some desktop environments.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1>
+ <title>AUTHOR</title>
+
+ <para>This manual page was originally written by &dhusername;
+ &lt;&dhemail;&gt; for the &debian; system (but may be used by others).
+ It has since been adopted by the upstream author.
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the &gnu; General Public License, Version 2 or any
+ later version published by the Free Software Foundation.
+ </para>
+ <para>The program itself is written by David Mohr &lt;david@mcbf.net&gt;
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the &gnu; General Public License, Version 2 or any
+ later version published by the Free Software Foundation.</para>
+ <para>
+ On Debian systems, the complete text of the GNU General Public
+ License can be found in /usr/share/common-licenses/GPL-2.
+ </para>
+
+ </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
+
+
View
4 reboot/xfce4
@@ -2,8 +2,10 @@
# xfce4-session-logout is the name of the binary under Debian,
# it's possible that it is xfce-session-logout on your system
-OUT=`gksudo -- ./grub-choose-default.py -r | grep -i reboot`
+BASE=`dirname $0`
+OUT=`gksudo -- $BASE/../grub-choose-default.py -r | grep -i reboot`
if [ -n "$OUT" ]; then
xfce4-session-logout
fi
+read a
Please sign in to comment.
Something went wrong with that request. Please try again.