As an exercise for my own satisfaction, the following is a quick and dirty way to do it. I haven't tested it because the shutdown and reboot commands stopped working on my laptop a couple of months ago for some reason, but the theory behind it should be correct, albeit the Bash script may need tweaking.
A. Setting it all up:
The example below assumes I have four entries in my Grub2 menu. The script can be modified easily according to my actual Grub2 menu.
1. Create the simple Bash script shown below in my home directory. I'll call the script reboot.sh for example:
- Code: Select all
#!/bin/bash
select CHOICE in Sabayon Sabayon_Safe_Mode Windows_Recovery Windows Shutdown Cancel
do
case "$CHOICE" in
"Sabayon")
echo "Rebooting to Sabayon"
sudo /sbin/grub2-set-default 1
sudo shutdown -r now
;;
"Sabayon_Safe_Mode")
echo "Rebooting to Sabayon Safe Mode"
sudo /sbin/grub2-set-default 2
sudo shutdown -r now
;;
"Windows_Recovery")
echo "Rebooting to Windows 7 Factory Restore Partition"
sudo /sbin/grub2-set-default 3
sudo shutdown -r now
;;
"Windows")
echo "Rebooting to Windows 7"
sudo /sbin/grub2-set-default 4
sudo shutdown -r now
;;
"Shutdown")
echo "Shutting down"
sudo shutdown -h now
;;
"Cancel")
echo "Cancel"
exit
;;
esac
done
2. Make the script executable:
- Code: Select all
$ chmod +x ~/reboot.sh
3. Create an icon (Desktop Config File) on my Desktop (right-click on the Desktop and select Create New > Link to Application...), configure it to execute the command
sh reboot.sh in a terminal, and give it a nice icon (the default shutdown icon shown below would suffice). I'll drag it onto my Panel so it's always visible and only needs a single click to activate.

4. Edit the file /etc/default/grub to have
GRUB_DEFAULT=saved and
GRUB_SAVEDEFAULT=true (if it is not already like that).
5. Regenerate /boot/grub/grub.cfg (this would only be necessary if I changed anything in /etc/default/grub):
- Code: Select all
# grub-mkconfig -o /boot/grub/grub.cfg
B. How to use it:
1. Click on the new icon on my Panel.
2. Upon being presented with the following menu:
- Code: Select all
1) Sabayon
2) Sabayon_Safe_Mode
3) Windows_Recovery
4) Windows
5) Shutdown
6) Cancel
enter the number of the menu item I want and press Enter.
3. Enter my password when prompted. (If I had wanted to, I could have configured Linux to not require a password for this.)
The PC should reboot to the Grub2 menu item I selected (1 to 4), or shut down the PC if I selected that option (5) or exit the script and do nothing if I selected the Cancel option (6).